Skip to content

Commit b756588

Browse files
author
Jeff Whitaker
committed
Merge pull request #60 from jswhit/master
preparing for 1.0.5 release (bug fixes for examples, updates to READMEs, Changelog)
2 parents 9109ff0 + 62c5647 commit b756588

File tree

8 files changed

+41
-19
lines changed

8 files changed

+41
-19
lines changed

Changelog

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
version 1.0.5 (not yet released)
2-
--------------------------------
1+
version 1.0.5 (git tag v1.0.5rel)
2+
---------------------------------
3+
* fix error in contour method that caused a bogus mask to be applied
4+
to the data (issue 58).
35
* fix further corner cases with splitting of parallels that cross
46
the dateline (issue 40).
57
* add latlon keyword to plotting methods. If latlon=True, x and y

KNOWN_BUGS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
always tries to fill the inside of a polygon. Under certain situations,
33
what is the inside of a coastline polygon can be ambiguous, and the
44
outside may be filled instead of the inside.
5-
Workaround - mask the land areas with the drawlsmask method instead of
5+
Workarounds - change the map projection region slightly or
6+
mask the land areas with the drawlsmask method instead of
67
filling the coastline polygons (this is illustrated in the ortho_demo.py example).

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ include Changelog
1111
include setup.py
1212
include nad2bin.c
1313
include src/*
14+
include examples/shiftdata.py
1415
include examples/allskymap.py
1516
include examples/allskymap_cr_example.py
1617
include examples/plothighsandlows.py

examples/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,6 @@ make_inset.py shows how to make an inset showing the location of the map project
153153
from a global perspective.
154154

155155
utmtest.py shows how to plot a UTM zone.
156+
157+
shiftdata.py shows how to use the 'latlon' keyword to automatically transform to map
158+
projection coordinates and shift the data longitudinally to fit the map projection region.

examples/ccsm_popgrid.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
plt.figure(figsize=(6,8))
5050
plt.subplot(2,1,1)
5151
# subplot 1 just shows POP grid cells.
52-
map = Basemap(projection='merc', lat_ts=20, llcrnrlon=-180, \
52+
m = Basemap(projection='merc', lat_ts=20, llcrnrlon=-180, \
5353
urcrnrlon=180, llcrnrlat=-84, urcrnrlat=84, resolution='c')
5454

55-
map.drawcoastlines()
56-
map.fillcontinents(color='white')
55+
m.drawcoastlines()
56+
m.fillcontinents(color='white')
5757

58-
x, y = map(tlon,tlat)
59-
im = map.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),
60-
shading='faceted', antialiased=True, cmap=plt.cm.cool,
58+
x, y = m(tlon,tlat)
59+
im = m.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),
60+
shading='faceted', antialiased=True, cmap=plt.cm.cool,
6161
vmin=0, vmax=0)
6262
# disclaimer: these are not really the grid cells because of the
6363
# way pcolor interprets the x and y args.
@@ -66,11 +66,11 @@
6666
# subplot 2 is a contour plot of surface temperature from the
6767
# CCSM ocean model.
6868
plt.subplot(2,1,2)
69-
map.drawcoastlines()
70-
map.fillcontinents(color='white')
69+
m.drawcoastlines()
70+
m.fillcontinents(color='white')
7171

72-
CS1 = map.contourf(x,y,temp,15)
73-
CS2 = map.contour(x,y,temp,15,colors='black',linewidths=0.5)
72+
CS1 = m.contourf(x,y,temp,15)
73+
CS2 = m.contour(x,y,temp,15,colors='black',linewidths=0.5)
7474
plt.title('(B) Surface Temp contours on POP Grid')
7575

7676
plt.show()

examples/fcstmaps_axesgrid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import print_function
2-
# this example reads today's numerical weather forecasts
2+
# this example reads today's numerical weather forecasts
33
# from the NOAA OpenDAP servers and makes a multi-panel plot.
44
# This version demonstrates the use of the AxesGrid toolkit.
55
import numpy as np
@@ -100,7 +100,7 @@
100100
ax.set_title('%d-h forecast valid '%fcsthr+verifdates[nt],fontsize=9)
101101
# figure title
102102
plt.figtext(0.5,0.95,
103-
"2-m temp (\N{DEGREE SIGN}C) forecasts from %s"%verifdates[0],
103+
u"2-m temp (\N{DEGREE SIGN}C) forecasts from %s"%verifdates[0],
104104
horizontalalignment='center',fontsize=14)
105105
# a single colorbar.
106106
cbar = fig.colorbar(cs, cax=grid.cbar_axes[0], orientation='horizontal')

examples/geos_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ def get_input(prompt):
2929
fig = plt.figure()
3030
m = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution='l')
3131
m.drawcoastlines()
32-
m.drawmapboundary(fill_color='aqua')
3332
m.fillcontinents(color='coral',lake_color='aqua')
33+
m.drawmapboundary(fill_color='aqua')
3434
m.drawcountries()
3535
# draw parallels and meridians.
3636
m.drawparallels(np.arange(-90.,120.,30.))
3737
m.drawmeridians(np.arange(0.,420.,60.))
38-
m.drawmapboundary()
3938
plt.title('Geostationary Map Centered on Lon=%s' % (lon_0))
4039
plt.show()

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ def __init__(self, llcrnrlon=None, llcrnrlat=None,
505505
self.boundinglat = boundinglat
506506
# is a round pole-centered plot desired?
507507
self.round = round
508+
# full disk projection?
509+
self._fulldisk = False # default value
508510

509511
# set up projection parameter dict.
510512
projparams = {}
@@ -1378,6 +1380,13 @@ def _getmapboundary(self):
13781380
n = n + 1
13791381
self.boundarylonmin = lons.min()
13801382
self.boundarylonmax = lons.max()
1383+
# for circular full disk projections where boundary is
1384+
# a latitude circle, set boundarylonmax and boundarylonmin
1385+
# to cover entire world (so parallels will be drawn).
1386+
if self._fulldisk and \
1387+
np.abs(self.boundarylonmax-self.boundarylonmin) < 1.:
1388+
self.boundarylonmin = -180.
1389+
self.boundarylonmax = 180.
13811390
b = np.empty((len(lons),2),np.float64)
13821391
b[:,0] = lons; b[:,1] = lats
13831392
boundaryll = _geoslib.Polygon(b)
@@ -3083,6 +3092,8 @@ def pcolor(self,x,y,data,**kwargs):
30833092
x = np.compress(mask,x)
30843093
y = np.compress(mask,y)
30853094
data = np.compress(mask,data)
3095+
# delete this keyword so it's not pass on to pcolor.
3096+
del kwargs['tri']
30863097
if masked:
30873098
triang = tri.Triangulation(x, y)
30883099
z = data[triang.triangles]
@@ -3091,8 +3102,6 @@ def pcolor(self,x,y,data,**kwargs):
30913102
ret = ax.tripcolor(triang,data,**kwargs)
30923103
else:
30933104
ret = ax.tripcolor(x,y,data,**kwargs)
3094-
# delete this keyword so it's not pass on to pcolor.
3095-
del kwargs['tri']
30963105
else:
30973106
# make x,y masked arrays
30983107
# (masked where data is outside of projection limb)
@@ -3249,6 +3258,8 @@ def contour(self,x,y,data,*args,**kwargs):
32493258
x = np.compress(mask,x)
32503259
y = np.compress(mask,y)
32513260
data = np.compress(mask,data)
3261+
# delete this keyword so it's not pass on to pcolor.
3262+
del kwargs['tri']
32523263
if masked:
32533264
triang = tri.Triangulation(x, y)
32543265
z = data[triang.triangles]
@@ -3457,6 +3468,11 @@ def streamplot(self, x, y, u, v, *args, **kwargs):
34573468
34583469
Other \*args and \**kwargs passed on to matplotlib.pyplot.streamplot.
34593470
"""
3471+
if _matplotlib_version < '1.2':
3472+
msg = dedent("""
3473+
streamplot method requires matplotlib 1.2 or higher,
3474+
you have %s""" % _matplotlib_version)
3475+
raise NotImplementedError(msg)
34603476
ax, plt = self._ax_plt_from_kw(kwargs)
34613477
# allow callers to override the hold state by passing hold=True|False
34623478
b = ax.ishold()

0 commit comments

Comments
 (0)