Changeset 391
- Timestamp:
- Nov 16, 2011, 3:11:06 PM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mymath.py
r388 r391 12 12 import numpy as np 13 13 if field is None: return None 14 else: return np.array(field).mean(axis=axis) 14 else: 15 if type(field).__name__=='MaskedArray': 16 field.set_fill_value(np.NaN) 17 zout=np.ma.array(field).mean(axis=axis) 18 # np.ma.masked_invalid(zout) 19 zout.set_fill_value(np.NaN) 20 return zout.filled() 21 else: 22 return np.array(field).mean(axis=axis) 15 23 16 24 def deg (): … … 27 35 28 36 # A.C. routine to compute saturation temperature 37 # Be Carefull, when asking for tsat-t, this routine outputs a masked array. 38 # To be correctly handled, this call to tsat must be done before the call to 39 # reduce_field, which handles correctly masked array with the new mean() function. 29 40 def get_tsat(pressure,temp=None,zlon=None,zlat=None,zalt=None,ztime=None): 30 41 import math as mt … … 55 66 output=np.zeros(np.array(temp).shape) 56 67 vardim=get_dim(zlon,zlat,zalt,ztime,temp) 57 # m=np.ma.masked_where(temp[temp == -1],temp,copy=False)58 # print temp59 # mindex=np.ma.nonzero(m.mask)60 # print mindex[0]61 68 if 'altitude' not in vardim.keys(): 62 69 print 'no altitude coordinate in temperature field for Tsat computation' … … 103 110 exit() 104 111 i=i+1 105 m=np.ma.masked_ where(temp == 0,temp,copy=False)106 zoutput=np.ma.array(output,mask=m.mask )#,fill_value=-999999)107 zout=zoutput.filled()108 return zout 112 m=np.ma.masked_invalid(temp,copy=False) 113 zoutput=np.ma.array(output,mask=m.mask,fill_value=np.NaN) 114 # zout=zoutput.filled() 115 return zoutput 109 116 110 117 # A.C. Dirty routine to determine where are the axis of a variable -
trunk/UTIL/PYTHON/myplot.py
r385 r391 128 128 from scipy import integrate 129 129 if yint: 130 output = integrate.trapz(input,x=vert,axis=ax) 130 if type(input).__name__=='MaskedArray': 131 input.set_fill_value([np.NaN]) 132 output = integrate.trapz(input.filled(),x=vert,axis=ax) 133 else: 134 output = integrate.trapz(input.filled(),x=vert,axis=ax) 131 135 else: 132 136 output = mean(input,axis=ax) -
trunk/UTIL/PYTHON/planetoplot.py
r388 r391 170 170 print "computing Tsat-T, I ASSUME Z-AXIS IS PRESSURE" 171 171 tt=getfield(nc,var) 172 tt.set_fill_value([0]) 173 all_var[k]=get_tsat(vert,tt,zlon=lon,zlat=lat,zalt=vert,ztime=time) 172 if type(tt).__name__=='MaskedArray': 173 tt.set_fill_value([np.NaN]) 174 tinput=tt.filled() 175 else: 176 tinput=tt 177 all_var[k]=get_tsat(vert,tinput,zlon=lon,zlat=lat,zalt=vert,ztime=time) 174 178 else: 175 179 if var: all_var[k] = getfield(nc,var)
Note: See TracChangeset
for help on using the changeset viewer.