Changeset 395 for trunk/UTIL/PYTHON/myplot.py
- Timestamp:
- Nov 17, 2011, 1:08:01 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r392 r395 49 49 def getfield (nc,var): 50 50 ## this allows to get much faster (than simply referring to nc.variables[var]) 51 import numpy as np 51 52 dimension = len(nc.variables[var].dimensions) 52 53 #print " Opening variable with", dimension, "dimensions ..." … … 54 55 elif dimension == 3: field = nc.variables[var][:,:,:] 55 56 elif dimension == 4: field = nc.variables[var][:,:,:,:] 56 return field 57 # if there are NaNs in the ncdf, they should be loaded as a masked array which will be 58 # recasted as a regular array later in reducefield 59 if (np.isnan(np.sum(field)) and (type(field).__name__ not in 'MaskedArray')): 60 print "Warning: netcdf as nan values but is not loaded as a Masked Array." 61 print "recasting array type" 62 out=np.ma.masked_invalid(field) 63 out.set_fill_value([np.NaN]) 64 else: 65 out=field 66 return out 57 67 58 68 ## Author: AS + TN + AC … … 492 502 llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1]) 493 503 elif char == "npstere": m = Basemap(rsphere=radius,projection='npstere', boundinglat=blat, lon_0=0.) 494 elif char == "spstere": m = Basemap(rsphere=radius,projection='spstere', boundinglat=blat, lon_0= 0.)504 elif char == "spstere": m = Basemap(rsphere=radius,projection='spstere', boundinglat=blat, lon_0=180.) 495 505 elif char == "nplaea": m = Basemap(rsphere=radius,projection='nplaea', boundinglat=wlat[0], lon_0=meanlon) 496 506 elif char == "laea": m = Basemap(rsphere=radius,projection='laea',lon_0=meanlon,lat_0=meanlat,lat_ts=meanlat,\
Note: See TracChangeset
for help on using the changeset viewer.