Changeset 382 for trunk/UTIL/PYTHON
- Timestamp:
- Nov 14, 2011, 4:14:44 PM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/gcm.py
r381 r382 175 175 outputname=opt.out,resolution=opt.res,\ 176 176 ope=opt.operat,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\ 177 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy )177 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy,yintegral=opt.yint) 178 178 print 'Done: '+name 179 179 system("rm -f to_be_erased") -
trunk/UTIL/PYTHON/meso.py
r380 r382 172 172 outputname=opt.out,resolution=opt.res,\ 173 173 ope=opt.operat,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\ 174 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy )174 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy,yintegral=opt.yint) 175 175 print 'Done: '+name 176 176 system("rm -f to_be_erased") -
trunk/UTIL/PYTHON/myplot.py
r376 r382 56 56 return field 57 57 58 ## Author: AS + TN 59 def reducefield (input,d4=None,d3=None,d2=None,d1=None ):58 ## Author: AS + TN + AC 59 def reducefield (input,d4=None,d3=None,d2=None,d1=None,yint=False,alt=None): 60 60 ### we do it the reverse way to be compliant with netcdf "t z y x" or "t y x" or "y x" 61 61 ### it would be actually better to name d4 d3 d2 d1 as t z y x … … 97 97 elif max(d2) >= shape[2]: error = True 98 98 elif max(d1) >= shape[3]: error = True 99 elif d4 is not None and d3 is not None and d2 is not None and d1 is not None: 100 output = mean(input[d4,:,:,:],axis=0); output = mean(output[d3,:,:],axis=0); output = mean(output[d2,:],axis=0); output = mean(output[d1],axis=0)99 elif d4 is not None and d3 is not None and d2 is not None and d1 is not None: 100 output = mean(input[d4,:,:,:],axis=0); output = reduce_zaxis(output[d3,:,:],ax=0,yint=yint,vert=alt[d3]); output = mean(output[d2,:],axis=0); output = mean(output[d1],axis=0) 101 101 elif d4 is not None and d3 is not None and d2 is not None: 102 output = mean(input[d4,:,:,:],axis=0); output = mean(output[d3,:,:],axis=0); output = mean(output[d2,:],axis=0)102 output = mean(input[d4,:,:,:],axis=0); output = reduce_zaxis(output[d3,:,:],ax=0,yint=yint,vert=alt[d3]); output = mean(output[d2,:],axis=0) 103 103 elif d4 is not None and d3 is not None and d1 is not None: 104 output = mean(input[d4,:,:,:],axis=0); output = mean(output[d3,:,:],axis=0); output = mean(output[:,d1],axis=1)104 output = mean(input[d4,:,:,:],axis=0); output = reduce_zaxis(output[d3,:,:],ax=0,yint=yint,vert=alt[d3]); output = mean(output[:,d1],axis=1) 105 105 elif d4 is not None and d2 is not None and d1 is not None: 106 106 output = mean(input[d4,:,:,:],axis=0); output = mean(output[:,d2,:],axis=1); output = mean(output[:,d1],axis=1) 107 107 elif d3 is not None and d2 is not None and d1 is not None: 108 output = mean(input[:,d3,:,:],axis=1); output = mean(output[:,d2,:],axis=1); output = mean(output[:,d1],axis=1)109 elif d4 is not None and d3 is not None: output = mean(input[d4,:,:,:],axis=0); output = mean(output[d3,:,:],axis=0)108 output = reduce_zaxis(input[:,d3,:,:],ax=1,yint=yint,vert=alt[d3]); output = mean(output[:,d2,:],axis=1); output = mean(output[:,d1],axis=1) 109 elif d4 is not None and d3 is not None: output = mean(input[d4,:,:,:],axis=0); output = reduce_zaxis(output[d3,:,:],ax=0,yint=yint,vert=alt[d3]) 110 110 elif d4 is not None and d2 is not None: output = mean(input[d4,:,:,:],axis=0); output = mean(output[:,d2,:],axis=1) 111 111 elif d4 is not None and d1 is not None: output = mean(input[d4,:,:,:],axis=0); output = mean(output[:,:,d1],axis=2) 112 elif d3 is not None and d2 is not None: output = mean(input[:,d3,:,:],axis=1); output = mean(output[:,d2,:],axis=1)113 elif d3 is not None and d1 is not None: output = mean(input[:,d3,:,:],axis=1); output = mean(output[:,:,d1],axis=0)112 elif d3 is not None and d2 is not None: output = reduce_zaxis(input[:,d3,:,:],ax=1,yint=yint,vert=alt[d3]); output = mean(output[:,d2,:],axis=1) 113 elif d3 is not None and d1 is not None: output = reduce_zaxis(input[:,d3,:,:],ax=1,yint=yint,vert=alt[d3]); output = mean(output[:,:,d1],axis=0) 114 114 elif d2 is not None and d1 is not None: output = mean(input[:,:,d2,:],axis=2); output = mean(output[:,:,d1],axis=2) 115 115 elif d1 is not None: output = mean(input[:,:,:,d1],axis=3) 116 116 elif d2 is not None: output = mean(input[:,:,d2,:],axis=2) 117 elif d3 is not None: output = mean(input[:,d3,:,:],axis=1)117 elif d3 is not None: output = reduce_zaxis(input[:,d3,:,:],ax=0,yint=yint,vert=alt[d3]) 118 118 elif d4 is not None: output = mean(input[d4,:,:,:],axis=0) 119 119 dimension = np.array(output).ndim … … 121 121 print 'dim,shape: ',dimension,shape 122 122 return output, error 123 124 ## Author: AC 125 126 def reduce_zaxis (input,ax=None,yint=False,vert=None): 127 from mymath import max,mean 128 from scipy import integrate 129 if yint: 130 output = integrate.trapz(input,x=vert,axis=ax) 131 else: 132 output = mean(input,axis=ax) 133 return output 123 134 124 135 ## Author: AS + TN … … 578 589 "ALBBARE": "%.2f",\ 579 590 "TAU": "%.1f",\ 591 "CO2": "%.2f",\ 580 592 #### T.N. 581 593 "TEMP": "%.0f",\ … … 617 629 "ALBBARE": "spectral",\ 618 630 "TAU": "YlOrBr_r",\ 631 "CO2": "YlOrBr_r",\ 619 632 #### T.N. 620 633 "MTOT": "Jet",\ -
trunk/UTIL/PYTHON/myscript.py
r380 r382 43 43 parser.add_option('--lon', action='append',dest='slon', type="string", default=None, help='slices along lon. 2 comma-separated values: averaging') 44 44 parser.add_option('--vert', action='append',dest='svert', type="string", default=None, help='slices along vert. 2 comma-separated values: averaging') 45 parser.add_option('--yint', action='store_true',dest='yint', default=False,help='change the function of --vert z1,z2 from MEAN to INTEGRATE along z') 45 46 parser.add_option('--time', action='append',dest='stime', type="string", default=None, help='slices along time. 2 comma-separated values: averaging') 46 47 parser.add_option('--xmax', action='store',dest='xmax', type="float", default=None, help='max value for x-axis in contour-plots [max(xaxis)]') -
trunk/UTIL/PYTHON/planetoplot.py
r380 r382 48 48 xaxis=[None,None],\ 49 49 yaxis=[None,None],\ 50 ylog=False): 50 ylog=False,\ 51 yintegral=False): 51 52 52 53 … … 265 266 #### Contour plot 266 267 if var2: 267 what_I_plot, error = reducefield(all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert 268 what_I_plot, error = reducefield(all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, yint=yintegral, alt=vert) 268 269 #what_I_plot = what_I_plot*mult 269 270 if not error: … … 288 289 #### Shaded plot 289 290 if var: 290 what_I_plot, error = reducefield(all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert )291 what_I_plot, error = reducefield(all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert , yint=yintegral, alt=vert) 291 292 what_I_plot = what_I_plot*mult 292 293 if not error: … … 315 316 if not hole: what_I_plot = bounds(what_I_plot,zevmin,zevmax) 316 317 #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20) 317 zelevels = np.linspace(zevmin,zevmax )#,num=ndiv+1)318 zelevels = np.linspace(zevmin,zevmax,num=2.*ndiv+1) 318 319 #contourf(what_I_plot, zelevels, cmap = palette ) 319 320 … … 365 366 ### Vector plot --- a adapter 366 367 if winds: 367 vecx, error = reducefield( getfield(nc,uchar), d4=indextime, d3=indexvert )368 vecy, error = reducefield( getfield(nc,vchar), d4=indextime, d3=indexvert )368 vecx, error = reducefield( getfield(nc,uchar), d4=indextime, d3=indexvert , yint=yintegral , alt=vert) 369 vecy, error = reducefield( getfield(nc,vchar), d4=indextime, d3=indexvert , yint=yintegral , alt=vert) 369 370 #what_I_plot, error = reducefield(all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert ) 370 371 if not error:
Note: See TracChangeset
for help on using the changeset viewer.