From 3c9f470dede8ed39fbc78cd967a6181bf1afece3 Mon Sep 17 00:00:00 2001 From: bblay Date: Fri, 14 Sep 2012 16:39:29 +0100 Subject: [PATCH 1/3] rotated geodetic --- lib/cartopy/_crs.pyx | 19 ++++++++++++++++--- lib/cartopy/crs.py | 9 +++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/cartopy/_crs.pyx b/lib/cartopy/_crs.pyx index 29c4bdd56..174a1a12c 100644 --- a/lib/cartopy/_crs.pyx +++ b/lib/cartopy/_crs.pyx @@ -175,9 +175,22 @@ class Geodetic(CRS): """ # XXX Providing a default datum is bad. Providing the ellipse on its own is sufficient to define the ellipse, # and in some cases, can overwrite the desired, well defined ellipse. - def __init__(self, ellipse='WGS84', datum='WGS84'): - proj4_params = {'proj': 'lonlat', 'ellps': ellipse, 'datum': datum} - super(Geodetic, self).__init__(proj4_params) + def __init__(self, proj4_params=None, ellipse='WGS84', datum='WGS84'): + """Create the Geodetic. + + Use the provided proj4_params, if provided, + otherwise construct proj4 params from the ellipse and datum. + + Kwargs: + + * proj4_params - pre-build proj4 params + * ellipse - ellipsoid definiton used if proj4_params is not set + * datum - datum definiton used if proj4_params is not set + + """ + if proj4_params is None: + proj4_params = {'proj': 'lonlat', 'ellps': ellipse, 'datum': datum} + super(Geodetic, self).__init__(proj4_params) # XXX Implement fwd such as Basemap's Geod. Would be used in the tissot example. # Could come from http://geographiclib.sourceforge.net diff --git a/lib/cartopy/crs.py b/lib/cartopy/crs.py index c4d2961c9..a92c91351 100644 --- a/lib/cartopy/crs.py +++ b/lib/cartopy/crs.py @@ -31,6 +31,15 @@ import cartopy.trace +class RotatedGeodetic(Geodetic): + """Defines a rotated, spherical CRS.""" + def __init__(self, pole_longitude=0.0, pole_latitude=90.0): + proj4_params = {'proj': 'ob_tran', 'o_proj': 'latlon', 'o_lon_p': 0, + 'o_lat_p': pole_latitude, 'lon_0': 180 + pole_longitude, + 'to_meter': math.radians(1)} + Geodetic.__init__(self, proj4_params) + + class Projection(CRS): """ Defines a projected coordinate system with flat topology and Euclidean From 03f566e8aabe2849b54086fe8acc50c13ff5006a Mon Sep 17 00:00:00 2001 From: bblay Date: Fri, 21 Sep 2012 11:07:56 +0100 Subject: [PATCH 2/3] review actions --- lib/cartopy/_crs.pyx | 15 +++++---------- lib/cartopy/crs.py | 28 +++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/cartopy/_crs.pyx b/lib/cartopy/_crs.pyx index 174a1a12c..07d2597b9 100644 --- a/lib/cartopy/_crs.pyx +++ b/lib/cartopy/_crs.pyx @@ -175,21 +175,16 @@ class Geodetic(CRS): """ # XXX Providing a default datum is bad. Providing the ellipse on its own is sufficient to define the ellipse, # and in some cases, can overwrite the desired, well defined ellipse. - def __init__(self, proj4_params=None, ellipse='WGS84', datum='WGS84'): - """Create the Geodetic. - - Use the provided proj4_params, if provided, - otherwise construct proj4 params from the ellipse and datum. + def __init__(self, ellipse='WGS84', datum='WGS84'): + """Create a Geodetic CRS. Kwargs: - * proj4_params - pre-build proj4 params - * ellipse - ellipsoid definiton used if proj4_params is not set - * datum - datum definiton used if proj4_params is not set + * ellipse - Ellipsoid definiton. + * datum - Datum definiton. """ - if proj4_params is None: - proj4_params = {'proj': 'lonlat', 'ellps': ellipse, 'datum': datum} + proj4_params = {'proj': 'lonlat', 'ellps': ellipse, 'datum': datum} super(Geodetic, self).__init__(proj4_params) # XXX Implement fwd such as Basemap's Geod. Would be used in the tissot example. diff --git a/lib/cartopy/crs.py b/lib/cartopy/crs.py index a92c91351..ad31ef96d 100644 --- a/lib/cartopy/crs.py +++ b/lib/cartopy/crs.py @@ -31,13 +31,31 @@ import cartopy.trace -class RotatedGeodetic(Geodetic): - """Defines a rotated, spherical CRS.""" - def __init__(self, pole_longitude=0.0, pole_latitude=90.0): +class RotatedGeodetic(CRS): + """ + Defines a rotated latitude/longitude coordinate system with spherical topology + and geographical distance. + + Coordinates are measured in degrees. + + """ + def __init__(self, pole_longitude, pole_latitude, ellipse='WGS84', datum='WGS84'): + """Create a RotatedGeodetic CRS. + + Args: + + * pole_longitude, pole_latitude - Pole position, in unrotated degrees. + + Kwargs: + + * ellipse - Ellipsoid definiton. + * datum - Datum definiton. + + """ proj4_params = {'proj': 'ob_tran', 'o_proj': 'latlon', 'o_lon_p': 0, 'o_lat_p': pole_latitude, 'lon_0': 180 + pole_longitude, - 'to_meter': math.radians(1)} - Geodetic.__init__(self, proj4_params) + 'to_meter': math.radians(1), 'ellps': ellipse, 'datum': datum} + super(RotatedGeodetic, self).__init__(proj4_params) class Projection(CRS): From f026c4400eac97a543ba56cf3178558cfbe4a08b Mon Sep 17 00:00:00 2001 From: bblay Date: Fri, 21 Sep 2012 16:32:41 +0100 Subject: [PATCH 3/3] review actions --- lib/cartopy/_crs.pyx | 3 ++- lib/cartopy/crs.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/cartopy/_crs.pyx b/lib/cartopy/_crs.pyx index 07d2597b9..89f143b03 100644 --- a/lib/cartopy/_crs.pyx +++ b/lib/cartopy/_crs.pyx @@ -176,7 +176,8 @@ class Geodetic(CRS): # XXX Providing a default datum is bad. Providing the ellipse on its own is sufficient to define the ellipse, # and in some cases, can overwrite the desired, well defined ellipse. def __init__(self, ellipse='WGS84', datum='WGS84'): - """Create a Geodetic CRS. + """ + Create a Geodetic CRS. Kwargs: diff --git a/lib/cartopy/crs.py b/lib/cartopy/crs.py index ad31ef96d..c9ccf48f7 100644 --- a/lib/cartopy/crs.py +++ b/lib/cartopy/crs.py @@ -40,7 +40,8 @@ class RotatedGeodetic(CRS): """ def __init__(self, pole_longitude, pole_latitude, ellipse='WGS84', datum='WGS84'): - """Create a RotatedGeodetic CRS. + """ + Create a RotatedGeodetic CRS. Args: