Changeset 754 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Aug 2, 2012, 12:55:45 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r753 r754 84 84 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 85 85 getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,\ 86 windamplitude,slopeamplitude,deltat0t1,enrichment_factor,getdimfromvar87 from mymath import deg,max,min,mean, get_tsat,writeascii,fig2data,fig2img86 getdimfromvar,select_case 87 from mymath import deg,max,min,mean,writeascii,fig2data,fig2img 88 88 import matplotlib as mpl 89 89 from matplotlib.pyplot import contour,contourf,hist, text,subplot, figure, rcParams, savefig, colorbar, \ … … 163 163 ### we get the names of variables to be read. in case only one available, we choose this one. 164 164 ### (we take out of the test specific names e.g. UV is not in the file but used to ask a wind speed computation) 165 varname=var[vvv] 166 logical_novarname = varname not in nc.variables 167 specificname_meso = ['UV','uv','uvmet','slopexy','SLOPEXY','deltat','DELTAT'] 168 logical_nospecificname_meso = not ((typefile in ['meso']) and (varname in specificname_meso)) 169 specificname_gcm = ['enfact'] 170 logical_nospecificname_gcm = not ((typefile in ['gcm']) and (varname in specificname_gcm)) 171 if ( logical_novarname and logical_nospecificname_meso and logical_nospecificname_gcm ): 172 if len(varinfile) == 1: varname = varinfile[0] 173 else: varname = False 165 varname = select_case(zvarname=var[vvv],znc=nc,ztypefile=typefile,mode='check') 174 166 ### we get the names of wind variables to be read (if any) 175 167 if winds: … … 314 306 all_namefile[k] = namefile 315 307 all_time[k] = time 316 if var2: 317 all_var2[k] = getfield(nc,var2) 318 ### v--- too SPECIFIC (see below) 319 if ((var2 in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (var2 not in nc.variables)): all_var2[k] = slopeamplitude(nc) 308 if var2: all_var2[k] = select_case(zvarname=var2,znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k]) 320 309 if winds: all_windu[k] = getfield(nc,uchar) ; all_windv[k] = getfield(nc,vchar) 321 310 ### we fill the arrays of fields to be plotted at the current step considered 322 ### ----------- SPECIFIC CASES. NOT HAPPY WITH THIS. note : we could probably call those via a "toolbox" in myplot. 323 ### ----------- 1. saturation temperature 324 if varname in ["temp","t","T_nadir_nit","T_nadir_day","temp_day","temp_night"] and tsat: 325 tt=getfield(nc,varname) ; print "computing Tsat-T, I ASSUME Z-AXIS IS PRESSURE" 326 if type(tt).__name__=='MaskedArray': tt.set_fill_value([np.NaN]) ; tinput=tt.filled() 327 else: tinput=tt 328 all_var[k]=get_tsat(vert,tinput,zlon=lon,zlat=lat,zalt=vert,ztime=time) 329 ### ----------- 2. wind amplitude 330 elif ((varname in ['UV','uv','uvmet']) and (typefile in ['meso']) and (varname not in nc.variables)): 331 all_var[k]=windamplitude(nc) 332 elif ((varname in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (varname not in nc.variables)): 333 all_var[k]=slopeamplitude(nc) 334 ### ------------ 3. Near surface instability 335 elif ((varname in ['DELTAT','deltat']) and (typefile in ['meso']) and (varname not in nc.variables)): 336 all_var[k]=deltat0t1(nc) 337 ### ------------ 4. Enrichment factor 338 elif ((typefile in ['gcm']) and (varname in ['enfact'])): 339 all_var[k]=enrichment_factor(nc,lon,lat,time) 340 else: 341 ### ideally only this line should be here 342 all_var[k] = getfield(nc,varname) 311 all_var[k] = select_case(zvarname=all_varname[k],znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k]) 343 312 ### we inform the user about the loop then increment the loop. this is the last line of "for namefile in namefiles" 344 313 print "**** GOT SUBDATA:",k," NAMEFILE:",namefile," VAR:",varname, var2 ; k += 1 ; firstfile = False … … 355 324 if fileref is not None: 356 325 ncref = Dataset(fileref) 357 if ((all_varname[k-1] in ['UV','uv','uvmet']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)): 358 all_var[k] = windamplitude(ncref) 359 elif ((all_varname[k-1] in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)): 360 all_var[k] = slopeamplitude(ncref) 361 elif ((all_varname[k-1] in ['DELTAT','deltat']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)): 362 all_var[k]=deltat0t1(ncref) 363 else: 364 all_var[k] = getfield(ncref,all_varname[k-1]) 326 all_var[k] = select_case(zvarname=all_varname[k-1],znc=ncref,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k],zvert=vert) 365 327 all_varname[k] = all_varname[k-1] ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] ; all_var2[k] = all_var2[k-1] 366 328 if winds: all_windu[k] = getfield(ncref,uchar) ; all_windv[k] = getfield(ncref,vchar)
Note: See TracChangeset
for help on using the changeset viewer.