66"""
77from .utils import _warn_proplot
88import 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- ]
179try :
1810 from cartopy .crs import (
1911 _WarpedRectangularProjection ,
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
3049def 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):
165184class 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
182217class 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
199250class 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
216283class 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
234316class 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
241324class 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
248332class 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
255341class 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
262349class 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
269357class 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