Changeset 418
- Timestamp:
- Nov 23, 2011, 4:39:01 PM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcs.py
r417 r418 60 60 fields = varznames, \ 61 61 predifined = 'mcs')[0] 62 62 else:filename=opt.file 63 63 # Files 64 64 … … 122 122 for zn in varznames: 123 123 load=getfield(nc,zn) 124 if opt.zrecast: 125 load=np.ma.masked_where(load < -1.e-30,load) 126 load.set_fill_value([np.NaN]) 127 load=load.filled() 124 load=np.ma.masked_where(load < -1.e-20,load) 125 load.set_fill_value([np.NaN]) 126 load=load.filled() 127 load=np.ma.masked_invalid(load) 128 load.set_fill_value([np.NaN]) 129 load=load.filled() 128 130 varz.append(load) 131 load=0. 129 132 print "Found: "+zn+" with dimensions: " 130 133 print np.array(varz[n]).shape … … 193 196 varchk[vv,:,:,:,:]=variable[istart:istop+1,:,:,:] 194 197 vv=vv+1 198 varchk=np.ma.masked_invalid(varchk) 199 varchk.set_fill_value([np.NaN]) 195 200 varchktime=time[istart:istop+1] 196 201 ndays=np.floor(varchktime[len(varchktime)-1])-np.floor(varchktime[0]) … … 199 204 ntmichk=ntimemin[i,:,:] 200 205 ntmachk=ntimemax[i,:,:] 201 dtmichk.set_fill_value( np.NaN)202 dtmachk.set_fill_value( np.NaN)203 ntmichk.set_fill_value( np.NaN)204 ntmachk.set_fill_value( np.NaN)206 dtmichk.set_fill_value([np.NaN]) 207 dtmachk.set_fill_value([np.NaN]) 208 ntmichk.set_fill_value([np.NaN]) 209 ntmachk.set_fill_value([np.NaN]) 205 210 dtmichk=dtmichk.filled() 206 211 dtmachk=dtmachk.filled() … … 215 220 vartmpnight=np.zeros([nzvar,ndays,nz,ny,nx]) 216 221 vartmpday=np.zeros([nzvar,ndays,nz,ny,nx]) 222 vartmpnight=np.ma.masked_invalid(vartmpnight) 223 vartmpday=np.ma.masked_invalid(vartmpday) 224 vartmpnight.set_fill_value([np.NaN]) 225 vartmpday.set_fill_value([np.NaN]) 226 217 227 nd=0 218 228 print " .time indices MCS grid -> diagfi grid." … … 239 249 vartmpday[vv,nd,:,iy,ix]=np.NaN 240 250 elif nitdtmichk > nitdtmachk: 241 vartmpday[vv,nd,:,iy,ix]=(np.m ean(varchk[vv,daystart+nitdtmichk:daystop+1,:,iy,ix],axis=0)+np.mean(varchk[vv,daystart:daystart+nitdtmachk+1,:,iy,ix],axis=0))/2.251 vartmpday[vv,nd,:,iy,ix]=(np.ma.mean(varchk[vv,daystart+nitdtmichk:daystop+1,:,iy,ix],axis=0)+np.ma.mean(varchk[vv,daystart:daystart+nitdtmachk+1,:,iy,ix],axis=0))/2. 242 252 else: 243 vartmpday[vv,nd,:,iy,ix]=np.m ean(varchk[vv,daystart+nitdtmichk:daystart+nitdtmachk+1,:,iy,ix],axis=0)253 vartmpday[vv,nd,:,iy,ix]=np.ma.mean(varchk[vv,daystart+nitdtmichk:daystart+nitdtmachk+1,:,iy,ix],axis=0) 244 254 if ((nitntmichk is np.NaN) or (nitntmachk is np.NaN)): 245 255 vartmpnight[vv,nd,:,iy,ix]=np.NaN 246 256 elif nitntmichk > nitntmachk: 247 vartmpnight[vv,nd,:,iy,ix]=(np.m ean(varchk[vv,daystart+nitntmichk:daystop+1,:,iy,ix],axis=0)+np.mean(varchk[vv,daystart:daystart+nitntmachk+1,:,iy,ix],axis=0))/2.257 vartmpnight[vv,nd,:,iy,ix]=(np.ma.mean(varchk[vv,daystart+nitntmichk:daystop+1,:,iy,ix],axis=0)+np.ma.mean(varchk[vv,daystart:daystart+nitntmachk+1,:,iy,ix],axis=0))/2. 248 258 else: 249 vartmpnight[vv,nd,:,iy,ix]=np.m ean(varchk[vv,daystart+nitntmichk:daystart+nitntmachk+1,:,iy,ix],axis=0)259 vartmpnight[vv,nd,:,iy,ix]=np.ma.mean(varchk[vv,daystart+nitntmichk:daystart+nitntmachk+1,:,iy,ix],axis=0) 250 260 iy=iy+1 251 261 ix=ix+1 … … 256 266 vartmpdaymasked=np.ma.masked_invalid(vartmpday) 257 267 vartmpnightmasked=np.ma.masked_invalid(vartmpnight) 268 vartmpdaymasked.set_fill_value([np.NaN]) 269 vartmpnightmasked.set_fill_value([np.NaN]) 258 270 for vv in np.arange(nzvar): 259 271 vardayout[vv,i,:,:,:]=np.ma.mean(vartmpdaymasked[vv,:,:,:,:],axis=0) -
trunk/UTIL/PYTHON/myplot.py
r409 r418 651 651 return what_I_plot 652 652 653 654 ## Author : AC 655 def hole_bounds(what_I_plot,zevmin,zevmax): 656 import numpy as np 657 zi=0 658 for i in what_I_plot: 659 zj=0 660 for j in i: 661 if ((j < zevmin) or (j > zevmax)):what_I_plot[zi,zj]=np.NaN 662 zj=zj+1 663 zi=zi+1 664 665 return what_I_plot 666 653 667 ## Author: AS 654 668 def zoomset (wlon,wlat,zoom): -
trunk/UTIL/PYTHON/myscript.py
r409 r418 16 16 parser.add_option('-M', '--max', action='append',dest='vmax', type="float", default=None, help='bounding maximum value (append)') 17 17 parser.add_option('-H', '--hole', action='store_true',dest='hole', default=False, help='holes above max and below min') 18 parser.add_option('--nolow', action='store_true',dest='nolow', default=False, help='plot only minima and maxima [false]') 18 19 19 20 ### VERTICAL INTERPOLATION -
trunk/UTIL/PYTHON/planetoplot.py
r407 r418 52 52 yintegral=False,\ 53 53 blat=None,\ 54 tsat=False): 54 tsat=False,\ 55 nolow=False): 55 56 56 57 … … 64 65 fmtvar,definecolorvec,defcolorb,getprefix,putpoints,calculate_bounds,errormess,definesubplot,\ 65 66 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 66 getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar 67 getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds 67 68 from mymath import deg,max,min,mean,get_tsat,writeascii 68 69 import matplotlib as mpl … … 323 324 ##### 2D field 324 325 if len(what_I_plot.shape) is 2: 326 if hole: what_I_plot = hole_bounds(what_I_plot,zevmin,zevmax) 327 else: what_I_plot = bounds(what_I_plot,zevmin,zevmax) 328 if nolow: what_I_plot = nolow(what_I_plot) 325 329 if not tile: 326 if not hole: what_I_plot = bounds(what_I_plot,zevmin,zevmax)327 330 #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20) 328 331 zelevels = np.linspace(zevmin,zevmax,num=ticks) … … 330 333 elif mapmode == 0: contourf( x, y, what_I_plot, zelevels, cmap = palette) 331 334 else: 332 if hole: what_I_plot = nolow(what_I_plot)333 335 if mapmode == 1: m.pcolor( x, y, what_I_plot, cmap = palette, vmin=zevmin, vmax=zevmax ) 334 336 elif mapmode == 0: pcolor( x, y, what_I_plot, cmap = palette, vmin=zevmin, vmax=zevmax ) -
trunk/UTIL/PYTHON/pp.py
r409 r418 135 135 ope=opt.operat,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\ 136 136 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy,yintegral=opt.column,\ 137 blat=opt.blat,tsat=opt.tsat )137 blat=opt.blat,tsat=opt.tsat,nolow=opt.nolow) 138 138 print 'DONE: '+name 139 139 system("rm -f to_be_erased")
Note: See TracChangeset
for help on using the changeset viewer.