Ignore:
Timestamp:
Nov 17, 2011, 1:08:01 PM (13 years ago)
Author:
acolaitis
Message:

PYTHON

M 393 mymath.py
----------------- Cosmetic change

M 393 make_netcdf.py
----------------- Cosmetic change

M 393 planetoplot.py
----------------- corrected bug with varname and --tsat

M 393 myplot.py
----------------- added possibility for the script to read ncdf files with NaN value and treat them correctly without messing with the mathematical operations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/myplot.py

    r392 r395  
    4949def getfield (nc,var):
    5050    ## this allows to get much faster (than simply referring to nc.variables[var])
     51    import numpy as np
    5152    dimension = len(nc.variables[var].dimensions)
    5253    #print "   Opening variable with", dimension, "dimensions ..."
     
    5455    elif dimension == 3:  field = nc.variables[var][:,:,:]
    5556    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
    5767
    5868## Author: AS + TN + AC
     
    492502                              llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1])
    493503    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.)
    495505    elif char == "nplaea":  m = Basemap(rsphere=radius,projection='nplaea', boundinglat=wlat[0], lon_0=meanlon)
    496506    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.