Changeset 701
- Timestamp:
- Jun 11, 2012, 4:17:57 PM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r687 r701 125 125 zvint=zv 126 126 return np.sqrt(zuint**2 + zvint**2) 127 128 ## Author: AC 129 # Compute the enrichment factor of non condensible gases 130 # The corresponding variable to call is enfact 131 def enrichment_factor(nc): 132 import numpy as np 133 varinfile = nc.variables.keys() 134 if "co2" in varinfile: co2=getfield(nc,'co2') 135 else: print "error, you need co2 var in your file" 136 if "ap" in varinfile: ap=getfield(nc,'ap') 137 else: print "error, you need ap var in your file" 138 if "bp" in varinfile: bp=getfield(nc,'bp') 139 else: print "error, you need bp var in your file" 140 if "ps" in varinfile: ps=getfield(nc,'ps') 141 else: print "error, you need ps var in your file" 142 dimension = len(nc.variables['co2'].dimensions) 143 if dimension == 3: 144 znz,zny,znx = np.array(co2).shape 145 znt=1 146 elif dimension == 4: znt,znz,zny,znx = np.array(co2).shape 147 co2col = np.zeros([znt,zny,znx]) 148 arcol = np.zeros([znt,zny,znx]) 149 mmrarcol = np.zeros([znt,zny,znx]) 150 meanar = np.zeros([znt]) 151 pplev = np.zeros([znt,znz+1,zny,znx]) 152 enfact = np.zeros([znt,zny,znx]) 153 grav=3.72 154 for zz in np.arange(znz): 155 pplev[:,zz,:,:] = ap[zz]+bp[zz]*ps[:,:,:] 156 pplev[:,znz,:,:]=0. 157 158 for zz in np.arange(znz): 159 co2col[:,:,:] = co2col[:,:,:] + co2[:,zz,:,:]*(pplev[:,zz,:,:]-pplev[:,zz+1,:,:])/grav 160 arcol[:,:,:] = arcol[:,:,:] + (1.-co2[:,zz,:,:])*(pplev[:,zz,:,:]-pplev[:,zz+1,:,:])/grav 161 162 mmrarcol = arcol/(arcol + co2col) 163 for xx in np.arange(znx): 164 for yy in np.arange(zny): 165 meanar[:] = meanar[:] + mmrarcol[:,yy,xx] 166 meanar = meanar/(znx*zny) 167 168 enfact =-(meanar - mmrarcol)/meanar 169 return enfact 127 170 128 171 ## Author: AC … … 947 990 "TAU": "%.1f",\ 948 991 "CO2": "%.2f",\ 992 "ENFACT": "%.1f",\ 949 993 #### T.N. 950 994 "TEMP": "%.0f",\ -
trunk/UTIL/PYTHON/planetoplot.py
r687 r701 79 79 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 80 80 getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,\ 81 windamplitude,slopeamplitude,deltat0t1 81 windamplitude,slopeamplitude,deltat0t1,enrichment_factor 82 82 from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img 83 83 import matplotlib as mpl … … 155 155 ### we get the names of variables to be read. in case only one available, we choose this one. 156 156 varname=var[vvv] 157 if ((varname not in nc.variables) and not ((typefile in ['meso']) and (varname in ['UV','uv','uvmet','slopexy','SLOPEXY','deltat','DELTAT'])) ):157 if ((varname not in nc.variables) and not ((typefile in ['meso']) and (varname in ['UV','uv','uvmet','slopexy','SLOPEXY','deltat','DELTAT'])) and not ((typefile in ['gcm']) and (varname in ['enfact']))): 158 158 if len(varinfile) == 1: varname = varinfile[0] 159 159 else: varname = False … … 299 299 ##################### 300 300 ##### SPECIFIC CASES 301 ##### note : we could probably call those via a "toolbox" in myplot. 301 302 ##### 1. saturation temperature 302 303 if varname in ["temp","t","T_nadir_nit","T_nadir_day","temp_day","temp_night"] and tsat: … … 310 311 elif ((varname in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (varname not in nc.variables)): 311 312 all_var[k]=slopeamplitude(nc) 313 #### 3. Near surface instability 312 314 elif ((varname in ['DELTAT','deltat']) and (typefile in ['meso']) and (varname not in nc.variables)): 313 315 all_var[k]=deltat0t1(nc) 316 #### 4. Enrichment factor 317 elif ((typefile in ['gcm']) and (varname in ['enfact'])): 318 all_var[k]=enrichment_factor(nc) 314 319 else: 315 320 ##### GENERAL STUFF HERE
Note: See TracChangeset
for help on using the changeset viewer.