Changeset 382 for trunk/UTIL/PYTHON/myplot.py
- Timestamp:
- Nov 14, 2011, 4:14:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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",\
Note: See TracChangeset
for help on using the changeset viewer.