Changeset 395


Ignore:
Timestamp:
Nov 17, 2011, 1:08:01 PM (14 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.

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

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

    r379 r395  
    8989       zvarcarac[zznames[i]]=zzvardim
    9090       i=i+1
     91
     92   print "creating "+zfilename
     93
    9194   print zvarcarac 
    9295 
     
    139142   file.close()
    140143
     144   print "closing "+zfilename
     145
     146   return
     147
    141148def find_key(dic, val):
    142149    """return the key of dictionary dic given the value"""
  • trunk/UTIL/PYTHON/mymath.py

    r391 r395  
    112112    m=np.ma.masked_invalid(temp,copy=False)
    113113    zoutput=np.ma.array(output,mask=m.mask,fill_value=np.NaN)
    114 #    zout=zoutput.filled()
    115114    return zoutput
    116115
  • 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,\
  • trunk/UTIL/PYTHON/planetoplot.py

    r393 r395  
    183183          else:                                 tinput=tt
    184184          all_var[k]=get_tsat(vert,tinput,zlon=lon,zlat=lat,zalt=vert,ztime=time)
     185          all_varname[k] = varname
    185186      else:
    186187      ##### GENERAL STUFF HERE
Note: See TracChangeset for help on using the changeset viewer.