Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions doc/users/figures/plotsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@
from netCDF4 import Dataset, date2index, num2date
import numpy as np
import matplotlib.pyplot as plt
import datetime
# create datetime object for desired time
date = datetime.datetime(2007,12,15,0)
# open dataset.
dataset =\
Dataset('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst2/totalAmsrAgg')
# find index of desired time.
time = dataset.variables['time']
nt = date2index(date, time, calendar='standard')
date = '20071215' # date to plot.
# open dataset for that date.
dataset = \
Dataset('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst2/%s/AVHRR-AMSR/amsr-avhrr-v2.%s.nc'%\
(date[0:4],date))
# read sst. Will automatically create a masked array using
# missing_value variable attribute.
sst = dataset.variables['sst'][nt]
# missing_value variable attribute. 'squeeze out' singleton dimensions.
sst = dataset.variables['sst'][:].squeeze()
# read ice.
ice = dataset.variables['ice'][nt]
ice = dataset.variables['ice'][:].squeeze()
# read lats and lons (representing centers of grid boxes).
lats = dataset.variables['lat'][:]
lons = dataset.variables['lon'][:]
Expand All @@ -28,7 +24,7 @@
lats = (lats - 0.5*delat).tolist()
lats.append(lats[-1]+delat)
lats = np.array(lats,np.float64)
# creat figure, axes instances.
# create figure, axes instances.
fig = plt.figure()
ax = fig.add_axes([0.05,0.05,0.9,0.9])
# create Basemap instance for Robinson projection.
Expand All @@ -51,4 +47,4 @@
cb = m.colorbar(im1,"bottom", size="5%", pad="2%")
# add a title.
ax.set_title('SST and ICE analysis for %s'%date)
plt.savefig('plotsst.png')
plt.show()
3 changes: 1 addition & 2 deletions examples/nsper_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,10.))
m.drawmeridians(np.arange(0.,420.,20.))
m.drawmapboundary()
m.drawmapboundary(fill_color='aqua')
plt.title('Near-Sided Perspective Map Centered on Lon=%s, Lat=%s, H=%g' %\
(lon_0,lat_0,h/1000.),fontsize=10)

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

Expand Down
33 changes: 17 additions & 16 deletions lib/mpl_toolkits/basemap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2820,22 +2820,23 @@ def set_axes_limits(self,ax=None):
ax.update_datalim( corners )
ax.set_xlim((self.llcrnrx, self.urcrnrx))
ax.set_ylim((self.llcrnry, self.urcrnry))
# if map boundary not yet drawn, draw it with default values.
if not self._mapboundarydrawn:
# is the map boundary already drawn on the current axes?
if self._mapboundarydrawn not in ax.patches:
# elliptical map, turn off axis_frame, draw boundary manually.
if (self.projection in ['ortho','geos','nsper','aeqd'] and
self._fulldisk) or self.round or self.projection in _pseudocyl:
# turn off axes frame.
ax.set_frame_on(False)
# first draw boundary, no fill
limb1 = self.drawmapboundary(fill_color='none')
# draw another filled patch, with no boundary.
limb2 = self.drawmapboundary(linewidth=0)
self._mapboundarydrawn = True
else: # square map, just turn on axis frame.
ax.set_frame_on(True)
# if map boundary not yet drawn for elliptical maps, draw it with default values.
if not self._mapboundarydrawn or self._mapboundarydrawn not in ax.patches:
# elliptical map, draw boundary manually.
if (self.projection in ['ortho','geos','nsper','aeqd'] and
self._fulldisk) or self.round or self.projection in _pseudocyl:
# first draw boundary, no fill
limb1 = self.drawmapboundary(fill_color='none')
# draw another filled patch, with no boundary.
limb2 = self.drawmapboundary(linewidth=0)
self._mapboundarydrawn = limb2
# for elliptical map, always turn off axis_frame.
if (self.projection in ['ortho','geos','nsper','aeqd'] and
self._fulldisk) or self.round or self.projection in _pseudocyl:
# turn off axes frame.
ax.set_frame_on(False)
else: # square map, always turn on axis frame.
ax.set_frame_on(True)
# make sure aspect ratio of map preserved.
# plot is re-centered in bounding rectangle.
# (anchor instance var determines where plot is placed)
Expand Down