Skip to content

Commit 861583f

Browse files
committed
Public module variables cleanup
1 parent 92cce32 commit 861583f

File tree

4 files changed

+234
-139
lines changed

4 files changed

+234
-139
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ ProPlot v1.0.0 (2020-##-##)
1515
This will be published when some major refactoring tasks are completed.
1616
See :pr:`45`, :pr:`46`, and :pr:`50`.
1717

18+
ProPlot v0.2.4 (2019-12-07)
19+
===========================
20+
Deprecated
21+
----------
22+
- Rename `colordict` to `~proplot.styletools.colors`, clean up top-level variables,
23+
clean up `~proplot.styletools.show_fonts`.
24+
1825
ProPlot v0.2.3 (2019-12-05)
1926
===========================
2027
Bug fixes

docs/api.rst

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ Projection tools
4444

4545
.. automodule:: proplot.projs
4646

47-
.. rubric:: Classes
47+
.. rubric:: Variables
4848

4949
.. automodsumm:: proplot.projs
50-
:classes-only:
50+
:variables-only:
5151
:toctree: api
5252

5353
.. rubric:: Functions
@@ -56,44 +56,44 @@ Projection tools
5656
:functions-only:
5757
:toctree: api
5858

59-
.. rubric:: Variables
59+
.. rubric:: Classes
6060

6161
.. automodsumm:: proplot.projs
62-
:variables-only:
62+
:classes-only:
6363
:toctree: api
6464

6565
Axis tools
6666
==========
6767

6868
.. automodule:: proplot.axistools
6969

70-
.. rubric:: Classes
70+
.. rubric:: Variables
7171

7272
.. automodsumm:: proplot.axistools
7373
:toctree: api
74-
:classes-only:
74+
:variables-only:
7575

7676
.. rubric:: Functions
7777

7878
.. automodsumm:: proplot.axistools
7979
:toctree: api
8080
:functions-only:
8181

82-
.. rubric:: Variables
82+
.. rubric:: Classes
8383

8484
.. automodsumm:: proplot.axistools
8585
:toctree: api
86-
:variables-only:
86+
:classes-only:
8787

8888
Color and font tools
8989
====================
9090

9191
.. automodule:: proplot.styletools
9292

93-
.. rubric:: Classes
93+
.. rubric:: Variables
9494

9595
.. automodsumm:: proplot.styletools
96-
:classes-only:
96+
:variables-only:
9797
:toctree: api
9898

9999
.. rubric:: Functions
@@ -102,10 +102,10 @@ Color and font tools
102102
:functions-only:
103103
:toctree: api
104104

105-
.. rubric:: Variables
105+
.. rubric:: Classes
106106

107107
.. automodsumm:: proplot.styletools
108-
:variables-only:
108+
:classes-only:
109109
:toctree: api
110110

111111
Rc configuration tools
@@ -124,4 +124,3 @@ Miscellaneous tools
124124
.. automodsumm:: proplot.utils
125125
:functions-only:
126126
:toctree: api
127-

proplot/projs.py

Lines changed: 120 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
"""
77
from .utils import _warn_proplot
88
import numpy as np
9-
__all__ = [
10-
'Proj',
11-
'basemap_rc', 'cartopy_projs',
12-
'Aitoff', 'Hammer', 'KavrayskiyVII',
13-
'NorthPolarAzimuthalEquidistant', 'NorthPolarLambertAzimuthalEqualArea',
14-
'SouthPolarAzimuthalEquidistant', 'SouthPolarLambertAzimuthalEqualArea',
15-
'WinkelTripel',
16-
]
179
try:
1810
from cartopy.crs import (
1911
_WarpedRectangularProjection,
@@ -26,6 +18,33 @@
2618
Gnomonic = object
2719
_cartopy_installed = False
2820

21+
__all__ = [
22+
'Proj',
23+
'basemap_defaults', 'cartopy_projs',
24+
'Aitoff', 'Hammer', 'KavrayskiyVII',
25+
'NorthPolarAzimuthalEquidistant',
26+
'NorthPolarGnomonic',
27+
'NorthPolarLambertAzimuthalEqualArea',
28+
'SouthPolarAzimuthalEquidistant',
29+
'SouthPolarGnomonic',
30+
'SouthPolarLambertAzimuthalEqualArea',
31+
'WinkelTripel',
32+
]
33+
34+
_reso_doc = """Projection resolution."""
35+
_proj_doc = """
36+
Parameters
37+
----------
38+
central_longitude : float, optional
39+
The longitude of the central meridian in degrees. Default is 0.
40+
false_easting: float, optional
41+
X offset from planar origin in metres. Defaults to 0.
42+
false_northing: float, optional
43+
Y offset from planar origin in metres. Defaults to 0.
44+
globe : `~cartopy.crs.Globe`, optional
45+
If omitted, a default globe is created.
46+
"""
47+
2948

3049
def Proj(name, basemap=False, **kwargs):
3150
"""
@@ -127,7 +146,7 @@ def Proj(name, basemap=False, **kwargs):
127146
if basemap:
128147
import mpl_toolkits.basemap as mbasemap
129148
name = BASEMAP_TRANSLATE.get(name, name)
130-
kwproj = basemap_rc.get(name, {})
149+
kwproj = basemap_defaults.get(name, {})
131150
kwproj.update(kwargs)
132151
kwproj.setdefault('fix_aspect', True)
133152
if name[:2] in ('np', 'sp'):
@@ -165,84 +184,149 @@ def Proj(name, basemap=False, **kwargs):
165184
class Hammer(_WarpedRectangularProjection):
166185
"""The `Hammer <https://en.wikipedia.org/wiki/Hammer_projection>`__
167186
projection."""
168-
__name__ = 'hammer'
169187
#: Registered projection name.
170188
name = 'hammer'
171189

172-
def __init__(self, central_longitude=0, globe=None): # , threshold=1e2):
190+
def __init__(self, central_longitude=0, globe=None,
191+
false_easting=None, false_northing=None):
192+
from cartopy._crs import Globe
193+
from cartopy.crs import WGS84_SEMIMAJOR_AXIS
194+
if globe is None:
195+
globe = Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS, ellipse=None)
196+
197+
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
198+
b = globe.semiminor_axis or a
199+
if b != a or globe.ellipse is not None:
200+
_warn_proplot(f'The {self.name!r} projection does not handle '
201+
'elliptical globes.')
202+
173203
proj4_params = {'proj': 'hammer', 'lon_0': central_longitude}
174-
super().__init__(proj4_params, central_longitude, globe=globe)
204+
super().__init__(proj4_params, central_longitude,
205+
false_easting=false_easting,
206+
false_northing=false_northing,
207+
globe=globe)
175208

176209
@property
177210
def threshold(self): # how finely to interpolate line data, etc.
178-
"""Projection resolution."""
179-
return 1e4
211+
return 1e5
212+
213+
__init__.__doc__ = _proj_doc
214+
threshold.__doc__ = _reso_doc
180215

181216

182217
class Aitoff(_WarpedRectangularProjection):
183218
"""The `Aitoff <https://en.wikipedia.org/wiki/Aitoff_projection>`__
184219
projection."""
185-
__name__ = 'aitoff'
186220
#: Registered projection name.
187221
name = 'aitoff'
188222

189-
def __init__(self, central_longitude=0, globe=None): # , threshold=1e2):
223+
def __init__(self, central_longitude=0, globe=None,
224+
false_easting=None, false_northing=None):
225+
from cartopy._crs import Globe
226+
from cartopy.crs import WGS84_SEMIMAJOR_AXIS
227+
if globe is None:
228+
globe = Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS, ellipse=None)
229+
230+
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
231+
b = globe.semiminor_axis or a
232+
if b != a or globe.ellipse is not None:
233+
_warn_proplot(f'The {self.name!r} projection does not handle '
234+
'elliptical globes.')
235+
190236
proj4_params = {'proj': 'aitoff', 'lon_0': central_longitude}
191-
super().__init__(proj4_params, central_longitude, globe=globe)
237+
super().__init__(proj4_params, central_longitude,
238+
false_easting=false_easting,
239+
false_northing=false_northing,
240+
globe=globe)
192241

193242
@property
194243
def threshold(self): # how finely to interpolate line data, etc.
195-
"""Projection resolution."""
196-
return 1e4
244+
return 1e5
245+
246+
__init__.__doc__ = _proj_doc
247+
threshold.__doc__ = _reso_doc
197248

198249

199250
class KavrayskiyVII(_WarpedRectangularProjection):
200251
"""The `Kavrayskiy VII
201252
<https://en.wikipedia.org/wiki/Kavrayskiy_VII_projection>`__ projection."""
202-
__name__ = 'kavrayskiyVII'
203253
#: Registered projection name.
204254
name = 'kavrayskiyVII'
205255

206-
def __init__(self, central_longitude=0, globe=None):
256+
def __init__(self, central_longitude=0, globe=None,
257+
false_easting=None, false_northing=None):
258+
from cartopy._crs import Globe
259+
from cartopy.crs import WGS84_SEMIMAJOR_AXIS
260+
if globe is None:
261+
globe = Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS, ellipse=None)
262+
263+
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
264+
b = globe.semiminor_axis or a
265+
if b != a or globe.ellipse is not None:
266+
_warn_proplot(f'The {self.name!r} projection does not handle '
267+
'elliptical globes.')
268+
207269
proj4_params = {'proj': 'kav7', 'lon_0': central_longitude}
208-
super().__init__(proj4_params, central_longitude, globe=globe)
270+
super().__init__(proj4_params, central_longitude,
271+
false_easting=false_easting,
272+
false_northing=false_northing,
273+
globe=globe)
209274

210275
@property
211276
def threshold(self):
212-
"""Projection resolution."""
213-
return 1e4
277+
return 1e5
278+
279+
__init__.__doc__ = _proj_doc
280+
threshold.__doc__ = _reso_doc
214281

215282

216283
class WinkelTripel(_WarpedRectangularProjection):
217284
"""The `Winkel tripel (Winkel III)
218285
<https://en.wikipedia.org/wiki/Winkel_tripel_projection>`__ projection."""
219-
__name__ = 'winkeltripel'
220286
#: Registered projection name.
221287
name = 'winkeltripel'
222288

223-
def __init__(self, central_longitude=0, globe=None):
289+
def __init__(self, central_longitude=0, globe=None,
290+
false_easting=None, false_northing=None):
291+
from cartopy._crs import Globe
292+
from cartopy.crs import WGS84_SEMIMAJOR_AXIS
293+
if globe is None:
294+
globe = Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS, ellipse=None)
295+
296+
a = globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS
297+
b = globe.semiminor_axis or a
298+
if b != a or globe.ellipse is not None:
299+
_warn_proplot(f'The {self.name!r} projection does not handle '
300+
'elliptical globes.')
301+
224302
proj4_params = {'proj': 'wintri', 'lon_0': central_longitude}
225-
super(WinkelTripel, self).__init__(
226-
proj4_params, central_longitude, globe=globe)
303+
super().__init__(proj4_params, central_longitude,
304+
false_easting=false_easting,
305+
false_northing=false_northing,
306+
globe=globe)
227307

228308
@property
229309
def threshold(self):
230-
"""Projection resolution."""
231-
return 1e4
310+
return 1e5
311+
312+
__init__.__doc__ = _proj_doc
313+
threshold.__doc__ = _reso_doc
232314

233315

234316
class NorthPolarAzimuthalEquidistant(AzimuthalEquidistant):
235317
"""Analogous to `~cartopy.crs.NorthPolarStereo`."""
236318
def __init__(self, central_longitude=0.0, globe=None):
237319
super().__init__(central_latitude=90,
238320
central_longitude=central_longitude, globe=globe)
321+
__init__.__doc__ = _proj_doc
239322

240323

241324
class SouthPolarAzimuthalEquidistant(AzimuthalEquidistant):
242325
"""Analogous to `~cartopy.crs.SouthPolarStereo`."""
243326
def __init__(self, central_longitude=0.0, globe=None):
244327
super().__init__(central_latitude=-90,
245328
central_longitude=central_longitude, globe=globe)
329+
__init__.__doc__ = _proj_doc
246330

247331

248332
class NorthPolarLambertAzimuthalEqualArea(LambertAzimuthalEqualArea):
@@ -251,26 +335,31 @@ def __init__(self, central_longitude=0.0, globe=None):
251335
super().__init__(central_latitude=90,
252336
central_longitude=central_longitude, globe=globe)
253337

338+
__init__.__doc__ = _proj_doc
339+
254340

255341
class SouthPolarLambertAzimuthalEqualArea(LambertAzimuthalEqualArea):
256342
"""Analogous to `~cartopy.crs.SouthPolarStereo`."""
257343
def __init__(self, central_longitude=0.0, globe=None):
258344
super().__init__(central_latitude=-90,
259345
central_longitude=central_longitude, globe=globe)
346+
__init__.__doc__ = _proj_doc
260347

261348

262349
class NorthPolarGnomonic(Gnomonic):
263350
"""Analogous to `~cartopy.crs.SouthPolarStereo`."""
264351
def __init__(self, central_longitude=0.0, globe=None):
265352
super().__init__(central_latitude=90,
266353
central_longitude=central_longitude, globe=globe)
354+
__init__.__doc__ = _proj_doc
267355

268356

269357
class SouthPolarGnomonic(Gnomonic):
270358
"""Analogous to `~cartopy.crs.SouthPolarStereo`."""
271359
def __init__(self, central_longitude=0.0, globe=None):
272360
super().__init__(central_latitude=-90,
273361
central_longitude=central_longitude, globe=globe)
362+
__init__.__doc__ = _proj_doc
274363

275364

276365
# Hidden constants
@@ -288,7 +377,7 @@ def __init__(self, central_longitude=0.0, globe=None):
288377
#: Default keyword args for `~mpl_toolkits.basemap.Basemap` projections.
289378
#: `~mpl_toolkits.basemap` will raise an error if you don't provide them,
290379
#: so ProPlot imposes some sensible default behavior.
291-
basemap_rc = {
380+
basemap_defaults = {
292381
'eck4': {'lon_0': 0},
293382
'geos': {'lon_0': 0},
294383
'hammer': {'lon_0': 0},

0 commit comments

Comments
 (0)