Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 397bed2

Browse files
author
Jeff Whitaker
committed
changed opendap server (old one no longer works)
svn path=/trunk/toolkits/basemap/; revision=3877
1 parent e7f43ee commit 397bed2

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

examples/pnganim.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ def hrs_since_day1CE_todate(hrs):
4747
raise ValueError,'dates must be in same year'
4848

4949
# set OpenDAP server URL.
50-
URLbase="http://www.cdc.noaa.gov/cgi-bin/nph-nc/Datasets/ncep.reanalysis/surface/"
51-
URL=URLbase+'slp.'+YYYY+'.nc'
52-
URLu=URLbase+'uwnd.sig995.'+YYYY+'.nc'
53-
URLv=URLbase+'vwnd.sig995.'+YYYY+'.nc'
50+
URLbase="http://nomad3.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/"
51+
URL=URLbase+'pres'
52+
URLu=URLbase+'wind'
53+
URLv=URLbase+'wind'
5454
print URL
5555
print URLu
5656
print URLv
@@ -71,7 +71,8 @@ def hrs_since_day1CE_todate(hrs):
7171
# put times in YYYYMMDDHH format.
7272
dates=[]
7373
for t in times:
74-
fdate = hrs_since_day1CE_todate(int(t))
74+
t = t*24
75+
fdate = hrs_since_day1CE_todate(int(t))
7576
dates.append(fdate.strftime('%Y%m%d%H'))
7677
if YYYYMMDDHH1 not in dates or YYYYMMDDHH2 not in dates:
7778
raise ValueError, 'date1 or date2 not a valid date (must be in form YYYYMMDDHH, where HH is 00,06,12 or 18)'
@@ -82,13 +83,13 @@ def hrs_since_day1CE_todate(hrs):
8283
if ntime1 >= ntime2:
8384
raise ValueError,'date2 must be greater than date1'
8485
# get sea level pressure and 10-m wind data.
85-
slpdata = data['slp']
86-
udata = datau['uwnd']
87-
vdata = datav['vwnd']
86+
slpdata = data['presmsl']
87+
udata = datau['ugrdprs']
88+
vdata = datau['vgrdprs']
8889
# mult slp by 0.01 to put in units of millibars.
89-
slpin = 0.01*(slpdata.scale_factor*p.squeeze(slpdata[ntime1:ntime2+1,:,:]) + slpdata.add_offset)
90-
uin = udata.scale_factor*p.squeeze(udata[ntime1:ntime2+1,:,:]) + udata.add_offset
91-
vin = vdata.scale_factor*p.squeeze(vdata[ntime1:ntime2+1,:,:]) + vdata.add_offset
90+
slpin = 0.01*p.squeeze(slpdata[ntime1:ntime2+1,:,:])
91+
uin = p.squeeze(udata[ntime1:ntime2+1,0,:,:])
92+
vin = p.squeeze(vdata[ntime1:ntime2+1,0,:,:])
9293
datelabels = dates[ntime1:ntime2+1]
9394
# add cyclic points
9495
slp = p.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),p.Float64)
@@ -109,6 +110,12 @@ def hrs_since_day1CE_todate(hrs):
109110
# make orthographic basemap.
110111
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
111112
p.ion() # interactive mode on.
113+
uin = p.squeeze(udata[ntime1:ntime2+1,0,:,:])
114+
vin = p.squeeze(vdata[ntime1:ntime2+1,0,:,:])
115+
datelabels = dates[ntime1:ntime2+1]
116+
# make orthographic basemap.
117+
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
118+
p.ion() # interactive mode on.
112119
# create figure, add axes (leaving room for colorbar on right)
113120
fig = p.figure()
114121
ax = fig.add_axes([0.1,0.1,0.7,0.7])
@@ -135,12 +142,10 @@ def hrs_since_day1CE_todate(hrs):
135142
# plot wind vectors on projection grid (looks better).
136143
# first, shift grid so it goes from -180 to 180 (instead of 0 to 360
137144
# in longitude). Otherwise, interpolation is messed up.
138-
# also reverse latitudes (since interpolation expects monotonically
139-
# increasing x and y).
140-
ugrid,newlons = shiftgrid(180.,u[nt,::-1,:],longitudes,start=False)
141-
vgrid,newlons = shiftgrid(180.,v[nt,::-1,:],longitudes,start=False)
145+
ugrid,newlons = shiftgrid(180.,u[nt,:,:],longitudes,start=False)
146+
vgrid,newlons = shiftgrid(180.,v[nt,:,:],longitudes,start=False)
142147
# transform vectors to projection grid.
143-
urot,vrot,xx,yy = m.transform_vector(ugrid,vgrid,newlons,latitudes[::-1],51,51,returnxy=True,masked=True)
148+
urot,vrot,xx,yy = m.transform_vector(ugrid,vgrid,newlons,latitudes,51,51,returnxy=True,masked=True)
144149
# plot wind vectors over map.
145150
Q = m.quiver(xx,yy,urot,vrot,scale=500)
146151
# make quiver key.

0 commit comments

Comments
 (0)