Skip to content

Commit c488c33

Browse files
author
Jeff Whitaker
committed
Merge pull request #22 from jswhit/master
clarity logic that decides whether to draw map boundary, fix examples.
2 parents 42edcbb + 53eb5bd commit c488c33

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

doc/users/figures/plotsst.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22
from netCDF4 import Dataset, date2index, num2date
33
import numpy as np
44
import matplotlib.pyplot as plt
5-
import datetime
6-
# create datetime object for desired time
7-
date = datetime.datetime(2007,12,15,0)
8-
# open dataset.
9-
dataset =\
10-
Dataset('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst2/totalAmsrAgg')
11-
# find index of desired time.
12-
time = dataset.variables['time']
13-
nt = date2index(date, time, calendar='standard')
5+
date = '20071215' # date to plot.
6+
# open dataset for that date.
7+
dataset = \
8+
Dataset('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst2/%s/AVHRR-AMSR/amsr-avhrr-v2.%s.nc'%\
9+
(date[0:4],date))
1410
# read sst. Will automatically create a masked array using
15-
# missing_value variable attribute.
16-
sst = dataset.variables['sst'][nt]
11+
# missing_value variable attribute. 'squeeze out' singleton dimensions.
12+
sst = dataset.variables['sst'][:].squeeze()
1713
# read ice.
18-
ice = dataset.variables['ice'][nt]
14+
ice = dataset.variables['ice'][:].squeeze()
1915
# read lats and lons (representing centers of grid boxes).
2016
lats = dataset.variables['lat'][:]
2117
lons = dataset.variables['lon'][:]
@@ -28,7 +24,7 @@
2824
lats = (lats - 0.5*delat).tolist()
2925
lats.append(lats[-1]+delat)
3026
lats = np.array(lats,np.float64)
31-
# creat figure, axes instances.
27+
# create figure, axes instances.
3228
fig = plt.figure()
3329
ax = fig.add_axes([0.05,0.05,0.9,0.9])
3430
# create Basemap instance for Robinson projection.

examples/nsper_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# draw parallels and meridians.
2020
m.drawparallels(np.arange(-90.,120.,10.))
2121
m.drawmeridians(np.arange(0.,420.,20.))
22-
m.drawmapboundary()
22+
m.drawmapboundary(fill_color='aqua')
2323
plt.title('Near-Sided Perspective Map Centered on Lon=%s, Lat=%s, H=%g' %\
2424
(lon_0,lat_0,h/1000.),fontsize=10)
2525

@@ -36,7 +36,6 @@
3636
# draw parallels and meridians.
3737
m.drawparallels(np.arange(-90.,120.,30.))
3838
m.drawmeridians(np.arange(0.,420.,60.))
39-
m.drawmapboundary()
4039
plt.title('Near-Sided Perspective Map Centered on Lon=%s, Lat=%s, H=%g' %\
4140
(lon_0,lat_0,h/1000.),fontsize=10)
4241

lib/mpl_toolkits/basemap/__init__.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,22 +2820,23 @@ def set_axes_limits(self,ax=None):
28202820
ax.update_datalim( corners )
28212821
ax.set_xlim((self.llcrnrx, self.urcrnrx))
28222822
ax.set_ylim((self.llcrnry, self.urcrnry))
2823-
# if map boundary not yet drawn, draw it with default values.
2824-
if not self._mapboundarydrawn:
2825-
# is the map boundary already drawn on the current axes?
2826-
if self._mapboundarydrawn not in ax.patches:
2827-
# elliptical map, turn off axis_frame, draw boundary manually.
2828-
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2829-
self._fulldisk) or self.round or self.projection in _pseudocyl:
2830-
# turn off axes frame.
2831-
ax.set_frame_on(False)
2832-
# first draw boundary, no fill
2833-
limb1 = self.drawmapboundary(fill_color='none')
2834-
# draw another filled patch, with no boundary.
2835-
limb2 = self.drawmapboundary(linewidth=0)
2836-
self._mapboundarydrawn = True
2837-
else: # square map, just turn on axis frame.
2838-
ax.set_frame_on(True)
2823+
# if map boundary not yet drawn for elliptical maps, draw it with default values.
2824+
if not self._mapboundarydrawn or self._mapboundarydrawn not in ax.patches:
2825+
# elliptical map, draw boundary manually.
2826+
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2827+
self._fulldisk) or self.round or self.projection in _pseudocyl:
2828+
# first draw boundary, no fill
2829+
limb1 = self.drawmapboundary(fill_color='none')
2830+
# draw another filled patch, with no boundary.
2831+
limb2 = self.drawmapboundary(linewidth=0)
2832+
self._mapboundarydrawn = limb2
2833+
# for elliptical map, always turn off axis_frame.
2834+
if (self.projection in ['ortho','geos','nsper','aeqd'] and
2835+
self._fulldisk) or self.round or self.projection in _pseudocyl:
2836+
# turn off axes frame.
2837+
ax.set_frame_on(False)
2838+
else: # square map, always turn on axis frame.
2839+
ax.set_frame_on(True)
28392840
# make sure aspect ratio of map preserved.
28402841
# plot is re-centered in bounding rectangle.
28412842
# (anchor instance var determines where plot is placed)

0 commit comments

Comments
 (0)