Skip to content

Commit 491e972

Browse files
author
Jeff Whitaker
committed
Merge pull request #23 from jswhit/master
update coastlines to gshhs 2.2.0
2 parents c488c33 + 2c33e42 commit 491e972

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+537059
-573098
lines changed

Changelog

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
version 1.0.3 (not yet released)
2-
* added hexbin method.
3-
* drawmapboundary now uses axes bgcolor as default fill_color. If
4-
no color fill wanted, set fill_color='none' (a string).
5-
* clip coastlines for nplaea,npaeqd,splaea,spaeqd in stereographic
6-
coordinates to avoid S. America disappearing in some south polar
7-
plots.
8-
* add 'round' keyword to Basemap.__init__ for pole-centered
2+
* update coastlines, rivers, political boundaries to GSHHS
3+
2.2.0/GMT 4.5.7. The fillcontinents bug (filling the outside
4+
instead of the inside of a coastline polygon) is now much
5+
harder to trigger.
6+
* add 'round' keyword keyword to Basemap.__init__ for pole-centered
97
projections to make them round (clipped at boundinglat) instead
10-
of square.
8+
of square.
9+
* added hexbin method.
10+
* drawmapboundary now uses axes bgcolor as default fill_color. If
11+
no color fill wanted, set fill_color='none' (a string).
12+
* clip coastlines for nplaea,npaeqd,splaea,spaeqd in stereographic
13+
coordinates to avoid S. America disappearing in some south polar
14+
plots.
1115
* fix broken daynight terminator function.
1216
* added kav7 (Kavrayskiy VII) and eck4 (Eckert IV) projections
1317
(https://github.com/matplotlib/basemap/issues/9).

KNOWN_BUGS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
* The fillcontinents method doesn't always do the right thing. Matplotlib
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
4-
outside may be filled instead of the inside. To trigger this,
5-
run the ortho_demo.py example with lon=-120,lat=60.
4+
outside may be filled instead of the inside.
65
Workaround - mask the land areas with the drawlsmask method instead of
76
filling the coastline polygons (this is illustrated in the ortho_demo.py example).

doc/users/figures/plotsst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from mpl_toolkits.basemap import Basemap
2-
from netCDF4 import Dataset, date2index, num2date
2+
from netCDF4 import Dataset
33
import numpy as np
44
import matplotlib.pyplot as plt
55
date = '20071215' # date to plot.

doc/users/figures/plotwindvec.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,31 @@
22
import matplotlib.pyplot as plt
33
import datetime
44
from mpl_toolkits.basemap import Basemap, shiftgrid
5-
from netCDF4 import Dataset, date2index, num2date
5+
from netCDF4 import Dataset
66
# specify date to plot.
7-
date = datetime.datetime(1993,3,14,0)
7+
yyyy=1993; mm=03; dd=14; hh=00
8+
date = datetime.datetime(yyyy,mm,dd,hh)
89
# set OpenDAP server URL.
9-
URL="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/pgb"
10+
URLbase="http://nomads.ncdc.noaa.gov/thredds/dodsC/modeldata/cmd_pgbh/"
11+
URL=URLbase+"%04i/%04i%02i/%04i%02i%02i/pgbh00.gdas.%04i%02i%02i%02i.grb2" %\
12+
(yyyy,yyyy,mm,yyyy,mm,dd,yyyy,mm,dd,hh)
1013
data = Dataset(URL)
11-
# read lats,lons,times.
12-
latitudes = data.variables['lat'][:]
14+
# read lats,lons
15+
# reverse latitudes so they go from south to north.
16+
latitudes = data.variables['lat'][::-1]
1317
longitudes = data.variables['lon'][:].tolist()
14-
times = data.variables['time']
15-
# get time index for desired date.
16-
ntime = date2index(date,times,calendar='standard')
1718
# get sea level pressure and 10-m wind data.
18-
slpdata = data.variables['presmsl']
19-
udata = data.variables['ugrdprs']
20-
vdata = data.variables['vgrdprs']
2119
# mult slp by 0.01 to put in units of hPa.
22-
slpin = 0.01*slpdata[ntime,:,:]
23-
uin = udata[ntime,0,:,:]
24-
vin = vdata[ntime,0,:,:]
20+
slpin = 0.01*data.variables['Pressure_msl'][:].squeeze()
21+
uin = data.variables['U-component_of_wind_height_above_ground'][:].squeeze()
22+
vin = data.variables['V-component_of_wind_height_above_ground'][:].squeeze()
2523
# add cyclic points manually (could use addcyclic function)
2624
slp = np.zeros((slpin.shape[0],slpin.shape[1]+1),np.float)
27-
slp[:,0:-1] = slpin; slp[:,-1] = slpin[:,0]
25+
slp[:,0:-1] = slpin[::-1]; slp[:,-1] = slpin[::-1,0]
2826
u = np.zeros((uin.shape[0],uin.shape[1]+1),np.float64)
29-
u[:,0:-1] = uin; u[:,-1] = uin[:,0]
27+
u[:,0:-1] = uin[::-1]; u[:,-1] = uin[::-1,0]
3028
v = np.zeros((vin.shape[0],vin.shape[1]+1),np.float64)
31-
v[:,0:-1] = vin; v[:,-1] = vin[:,0]
29+
v[:,0:-1] = vin[::-1]; v[:,-1] = vin[::-1,0]
3230
longitudes.append(360.); longitudes = np.array(longitudes)
3331
# make 2-d grid of lons, lats
3432
lons, lats = np.meshgrid(longitudes,latitudes)

examples/fcstmaps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@
5959
# unpack 2-meter temp forecast data.
6060

6161
t2mvar = data.variables['tmp2m']
62-
t2min = t2mvar[0:ntimes,:,:]
63-
t2m = np.zeros((ntimes,nlats,nlons+1),t2min.dtype)
62+
t2m = np.zeros((ntimes,nlats,nlons+1),np.float32)
6463
# create Basemap instance for Orthographic projection.
6564
m = Basemap(lon_0=-90,lat_0=60,projection='ortho')
6665
# add wrap-around point in longitude.
6766
for nt in range(ntimes):
68-
t2m[nt,:,:], lons = addcyclic(t2min[nt,:,:], lons1)
67+
t2m[nt,:,:], lons = addcyclic(t2mvar[nt,:,:], lons1)
6968
# convert to celsius.
7069
t2m = t2m-273.15
7170
# contour levels

examples/fcstmaps_axesgrid.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
# unpack 2-meter temp forecast data.
6262

6363
t2mvar = data.variables['tmp2m']
64-
t2min = t2mvar[0:ntimes,:,:]
65-
t2m = np.zeros((ntimes,nlats,nlons+1),t2min.dtype)
6664

6765
# create figure, set up AxesGrid.
6866
fig=plt.figure(figsize=(6,8))
@@ -79,8 +77,9 @@
7977
# create Basemap instance for Orthographic projection.
8078
m = Basemap(lon_0=-90,lat_0=60,projection='ortho')
8179
# add wrap-around point in longitude.
80+
t2m = np.zeros((ntimes,nlats,nlons+1),np.float32)
8281
for nt in range(ntimes):
83-
t2m[nt,:,:], lons = addcyclic(t2min[nt,:,:], lons1)
82+
t2m[nt,:,:], lons = addcyclic(t2mvar[nt,:,:], lons1)
8483
# convert to celsius.
8584
t2m = t2m-273.15
8685
# contour levels

examples/nsper_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# create Basemap instance for Near-Sided Perspective (satellite view) projection.
66
lon_0 = float(raw_input('enter reference longitude (lon_0):'))
7-
lat_0 = float(raw_input('enter reference longitude (lat_0):'))
7+
lat_0 = float(raw_input('enter reference latitude (lat_0):'))
88
h = float(raw_input('enter altitude of camera in km (h):'))
99
h=h*1000.
1010

examples/plotsst.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
from mpl_toolkits.basemap import Basemap
2-
from netCDF4 import Dataset, date2index, num2date
2+
from netCDF4 import Dataset
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.
@@ -50,5 +46,5 @@
5046
# add colorbar
5147
cb = m.colorbar(im1,"bottom", size="5%", pad="2%")
5248
# add a title.
53-
plt.title('SST and ICE analysis for %s'%date)
49+
ax.set_title('SST and ICE analysis for %s'%date)
5450
plt.show()

0 commit comments

Comments
 (0)