|
From: <js...@us...> - 2010-12-29 18:05:44
|
Revision: 8855
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8855&view=rev
Author: jswhit
Date: 2010-12-29 18:05:38 +0000 (Wed, 29 Dec 2010)
Log Message:
-----------
add initial support for hammer projection (labelling of parallels does not yet work)
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
trunk/toolkits/basemap/src/PJ_hammer.c
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 14:18:30 UTC (rev 8854)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-12-29 18:05:38 UTC (rev 8855)
@@ -82,6 +82,7 @@
'nsper' : 'Near-Sided Perspective',
'sinu' : 'Sinusoidal',
'moll' : 'Mollweide',
+ 'hammer' : 'Hammer-Aitoff',
'robin' : 'Robinson',
'vandg' : 'van der Grinten',
'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic',
@@ -93,7 +94,7 @@
supported_projections = ''.join(supported_projections)
_cylproj = ['cyl','merc','mill','gall']
-_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg']
+_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg','hammer']
# projection specific parameters.
projection_params = {'cyl' : 'corners only (no width/height)',
@@ -121,6 +122,7 @@
'nsper' : 'lon_0,satellite_height,llcrnrx,llcrnry,urcrnrx,urcrnry,no width/height',
'sinu' : 'lon_0,lat_0,no corners or width/height',
'moll' : 'lon_0,lat_0,no corners or width/height',
+ 'hammer' : 'lon_0,lat_0,no corners or width/height',
'robin' : 'lon_0,lat_0,no corners or width/height',
'vandg' : 'lon_0,lat_0,no corners or width/height',
'mbtfpq' : 'lon_0,lat_0,no corners or width/height',
@@ -183,7 +185,7 @@
lat_0 center of desired map domain (in degrees).
============== ====================================================
- For ``sinu``, ``moll``, ``npstere``, ``spstere``, ``nplaea``, ``splaea``,
+ For ``sinu``, ``moll``, ``hammer``, ``npstere``, ``spstere``, ``nplaea``, ``splaea``,
``npaeqd``, ``spaeqd``, ``robin`` or ``mbtfpq``, the values of
llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, width and height are ignored
(because either they are computed internally, or entire globe is
@@ -1923,10 +1925,11 @@
nmax = int((self.ymax-self.ymin)/dy+1)
yy = np.linspace(self.llcrnry,self.urcrnry,nmax)
# mollweide inverse transform undefined at South Pole
- if self.projection == 'moll' and yy[0] < 1.e-4:
+ if self.projection == 'moll' and yy[0] < 1.e-4:
yy[0] = 1.e-4
if side == 'l':
- lons,lats = self(self.llcrnrx*np.ones(yy.shape,np.float32),yy,inverse=True)
+ xx = self.llcrnrx*np.ones(yy.shape,yy.dtype)
+ lons,lats = self(xx,yy,inverse=True)
lons = lons.tolist(); lats = lats.tolist()
else:
lons,lats = self(self.urcrnrx*np.ones(yy.shape,np.float32),yy,inverse=True)
@@ -2148,9 +2151,9 @@
lines.append(l)
linecolls[merid] = (lines,[])
# draw labels for meridians.
- # meridians not labelled for sinusoidal, mollweide, or
- # or full-disk orthographic/geostationary.
- if self.projection in ['sinu','moll','vandg'] and max(labels):
+ # meridians not labelled for sinusoidal, hammer, mollweide,
+ # VanDerGrinten or full-disk orthographic/geostationary.
+ if self.projection in ['sinu','moll','hammer','vandg'] and max(labels):
print 'Warning: Cannot label meridians on %s basemap' % _projnames[self.projection]
labels = [0,0,0,0]
if self.projection in ['ortho','geos','nsper','aeqd'] and max(labels):
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2010-12-29 14:18:30 UTC (rev 8854)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2010-12-29 18:05:38 UTC (rev 8855)
@@ -8,7 +8,7 @@
_rad2dg = math.degrees(1.)
_cylproj = ['cyl','merc','mill','gall']
-_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg']
+_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg','hammer']
_upper_right_out_of_bounds = (
'the upper right corner of the plot is not in the map projection region')
Modified: trunk/toolkits/basemap/src/PJ_hammer.c
===================================================================
--- trunk/toolkits/basemap/src/PJ_hammer.c 2010-12-29 14:18:30 UTC (rev 8854)
+++ trunk/toolkits/basemap/src/PJ_hammer.c 2010-12-29 18:05:38 UTC (rev 8855)
@@ -4,7 +4,7 @@
#define PJ_LIB__
# include <projects.h>
PROJ_HEAD(hammer, "Hammer & Eckert-Greifendorff")
- "\n\tMisc Sph, no inv.\n\tW= M=";
+ "\n\tMisc Sph, \n\tW= M=";
FORWARD(s_forward); /* spheroid */
double cosphi, d;
@@ -13,6 +13,13 @@
xy.y = P->rm * d * sin(lp.phi);
return (xy);
}
+INVERSE(s_inverse); /* spheroid */
+ double z;
+ z = sqrt(1. - (0.5 * P->w * xy.x) * (0.5 * P->w * xy.x) - (0.5 * xy.y) * (0.5 * xy.y));
+ lp.lam = aatan2(P->w * xy.x * z,2. * z * z - 1)/P->w;
+ lp.phi = aasin(z * xy.y);
+ return (lp);
+}
FREEUP; if (P) pj_dalloc(P); }
ENTRY0(hammer)
if (pj_param(P->params, "tW").i) {
@@ -25,5 +32,5 @@
P->m = 1.;
P->rm = 1. / P->m;
P->m /= P->w;
- P->es = 0.; P->fwd = s_forward;
+ P->es = 0.; P->fwd = s_forward; P->inv = s_inverse;
ENDENTRY(P)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|