Changeset 569 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Mar 7, 2012, 4:56:38 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r562 r569 62 62 seevar=False,\ 63 63 xlab=None,\ 64 ylab=None): 64 ylab=None,\ 65 lbls=None): 65 66 66 67 #################################################################################################################### … … 73 74 fmtvar,definecolorvec,defcolorb,getprefix,putpoints,calculate_bounds,errormess,definesubplot,\ 74 75 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 75 getname,localtime, polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds76 getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds 76 77 from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img 77 78 import matplotlib as mpl … … 139 140 ### ... VAR 140 141 varname=var[vvv] 141 if varname not in nc.variables:142 if ((varname not in nc.variables) and not ((typefile in ['meso']) and (varname in ['UV','uv','uvmet']))): 142 143 if len(varinfile) == 1: varname = varinfile[0] 143 144 else: varname = False … … 196 197 ###### principle: calculate correct indices then repopulate slon and slat 197 198 if slon is not None or slat is not None: 199 if slon is not None: sslon = np.zeros([1,2]) 200 if slat is not None: sslat = np.zeros([1,2]) 201 198 202 if firstfile and save == 'png' and typefile == 'meso' and "HGT" in varinfile: iwantawhereplot = nc #show a topo map with a cross on the chosen point 199 203 else: iwantawhereplot = None #do not show anything, just select indices … … 208 212 indices[iii,jjj,:] = bidimfind(lon2d,lat2d,vlon,vlat,file=iwantawhereplot) 209 213 lonp,latp = ( lon2d[indices[iii,jjj,0],indices[iii,jjj,1]] , lat2d[indices[iii,jjj,0],indices[iii,jjj,1]] ) 210 #print vlon, lonp, vlat, latp211 214 for iii in range(numlon): 212 215 for jjj in range(numlat): 213 if slon is not None: s lon[iii][0] = indices[iii,0,1] ;slon[iii][1] = indices[iii,0,1] #...this is idx214 if slat is not None: s lat[jjj][0] = indices[0,jjj,0] ;slat[jjj][1] = indices[0,jjj,0] #...this is idy216 if slon is not None: sslon[iii][0] = indices[iii,0,1] ; sslon[iii][1] = indices[iii,0,1] #...this is idx 217 if slat is not None: sslat[jjj][0] = indices[0,jjj,0] ; sslat[jjj][1] = indices[0,jjj,0] #...this is idy 215 218 lonp,latp = ( lon2d[indices[0,0,0],indices[0,0,1]] , lat2d[indices[0,0,0],indices[0,0,1]] ) 216 219 ###### … … 235 238 elif "Time" in nc.variables: time = count + np.arange(0,len(nc.variables["Time"]),1) 236 239 else: time = count + np.arange(0,1,1) 237 if nnn > 0: count = time[-1] + 1 ## so that a cat is possible with simple subscripts 238 else: count = 0 240 if ope in ["cat"]: 241 if nnn > 0: count = time[-1] + 1 ## so that a cat is possible with simple subscripts 242 else: count = 0 243 else: count = 0 239 244 if axtime in ["lt"]: 240 for i in range(len(time)): time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) ) 245 ftime = np.zeros(len(time)) 246 for i in range(len(time)): 247 ftime[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) ) 248 time=ftime 249 time=check_localtime(time) 241 250 print "LOCAL TIMES.... ", time 251 242 252 ### 243 253 if typefile in ['geo']: vert = [0.] ; stime = readslices(str(0)) … … 271 281 else: 272 282 ##### GENERAL STUFF HERE 273 all_var[k] = getfield(nc,varname) 274 283 if ((varname in ['UV','uv','uvmet']) and (typefile in ['meso']) and (varname not in nc.variables)): 284 if "U" in varinfile: zu=getfield(nc,'U') 285 elif "Um" in varinfile: zu=getfield(nc,'Um') 286 if "V" in varinfile: zv=getfield(nc,'V') 287 elif "Vm" in varinfile: zv=getfield(nc,'Vm') 288 znt,znz,zny,znx = np.array(zu).shape 289 if "U" in varinfile:znx=znx-1 290 zuint = np.zeros([znt,znz,zny,znx]) 291 zvint = np.zeros([znt,znz,zny,znx]) 292 if "U" in varinfile: 293 for xx in np.arange(znx): 294 zuint[:,:,:,xx] = (zu[:,:,:,xx] + zu[:,:,:,xx+1])/2. 295 for yy in np.arange(zny): 296 zvint[:,:,yy,:] = (zv[:,:,yy,:] + zv[:,:,yy+1,:])/2. 297 else: 298 zuint=zu 299 zvint=zv 300 all_var[k] = np.sqrt(zuint**2 + zvint**2) 301 else: 302 all_var[k] = getfield(nc,varname) 303 275 304 print "**** GOT SUBDATA:",k," NAMEFILE:",namefile," VAR:",varname, var2 ; k += 1 ; firstfile = False 276 305 #### End of for namefile in namefiles … … 283 312 if len(var) > 1: errormess("for this operation... please set only one var !") 284 313 if ope in ["-","+","-%"]: 285 if fileref is not None: all_var[k] = getfield(Dataset(fileref),all_varname[k-1]) ; all_varname[k] = all_varname[k-1] ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] 286 else: errormess("fileref is missing!") 314 if fileref is not None: 315 316 if ((all_varname[k-1] in ['UV','uv','uvmet']) and (typefile in ['meso']) and (all_varname[k-1] not in Dataset(fileref).variables)): 317 if "U" in varinfile: zu=getfield(Dataset(fileref),'U') 318 elif "Um" in varinfile: zu=getfield(Dataset(fileref),'Um') 319 if "V" in varinfile: zv=getfield(Dataset(fileref),'V') 320 elif "Vm" in varinfile: zv=getfield(Dataset(fileref),'Vm') 321 znt,znz,zny,znx = np.array(zu).shape 322 if "U" in varinfile:znx=znx-1 323 zuint = np.zeros([znt,znz,zny,znx]) 324 zvint = np.zeros([znt,znz,zny,znx]) 325 if "U" in varinfile: 326 for xx in np.arange(znx): 327 zuint[:,:,:,xx] = (zu[:,:,:,xx] + zu[:,:,:,xx+1])/2. 328 for yy in np.arange(zny): 329 zvint[:,:,yy,:] = (zv[:,:,yy,:] + zv[:,:,yy+1,:])/2. 330 else: 331 zuint=zu 332 zvint=zv 333 all_var[k] = np.sqrt(zuint**2 + zvint**2) 334 else: 335 all_var[k] = getfield(Dataset(fileref),all_varname[k-1]) 336 337 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] 338 339 else: errormess("fileref is missing!") 287 340 if ope == "-": all_var[k+1]= all_var[k-1] - all_var[k] 288 341 elif ope == "+": all_var[k+1]= all_var[k-1] + all_var[k] … … 291 344 masked.set_fill_value([np.NaN]) 292 345 all_var[k+1]= 100.*(all_var[k-1] - masked)/masked 293 all_varname[k+1] = all_varname[k] ; all_time[k+1] = all_time[k] ; all_namefile[k+1] = all_namefile[k] ; numplot = numplot+2346 all_varname[k+1] = all_varname[k] ; all_time[k+1] = all_time[k] ; all_namefile[k+1] = all_namefile[k] ; all_var2[k+1] = all_var2[k] ; numplot = numplot+2 294 347 elif ope in ["cat"]: 295 348 tabtime = all_time[0];tab = all_var[0];k = 1 … … 329 382 ## get all indexes to be taken into account for this subplot and then reduce field 330 383 ## We plot 1) all lon slices 2) all lat slices 3) all vert slices 4) all time slices and then go to the next slice 331 indexlon = getsindex(s lon,(nplot-1)%nlon,lon)332 indexlat = getsindex(s lat,((nplot-1)//nlon)%nlat,lat)384 indexlon = getsindex(sslon,(nplot-1)%nlon,lon) 385 indexlat = getsindex(sslat,((nplot-1)//nlon)%nlat,lat) 333 386 indexvert = getsindex(svert,((nplot-1)//(nlon*nlat))%nvert,vert) 334 387 if ope is not None: … … 456 509 457 510 if which == "unidim": 511 #lbls = ["<TH+RiSL+MY4> tau=0.5","<Convadj> tau=0.5","<TH+RiSL+MY4> tau=1","<Convadj> tau=1"] 458 512 lbl = "" 459 513 if indexlat is not None: lbl = lbl + " ix" + str(indexlat[0]) … … 462 516 if indextime is not None: lbl = lbl + " it" + str(indextime[0]) 463 517 if lbl == "": lbl = namefiles[index_f] 518 519 if lbls is not None: lbl=lbls[index_f] 520 464 521 if mrate is not None: x = y ## because swapaxes... 465 522 #what_I_plot_frame = np.diff(what_I_plot_frame, n=1) ; x = x[1:] … … 473 530 if save == 'txt': writeascii(np.transpose(what_I_plot),'profile'+str(nplot*1000+imov)+'.txt') 474 531 475 elif which == "regular": 532 elif which == "regular": 476 533 if hole: what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax) 477 534 else: what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax) … … 570 627 if mrate is not None: basename = "movie_" + basename 571 628 if typefile in ['meso']: 572 if s lon is not None: basename = basename + "_lon_" + str(int(round(lonp)))573 if s lat is not None: basename = basename + "_lat_" + str(int(round(latp)))629 if sslon is not None: basename = basename + "_lon_" + str(int(round(lonp))) 630 if sslat is not None: basename = basename + "_lat_" + str(int(round(latp))) 574 631 plottitle = basename 575 632 ### dans le nouveau systeme time=ls,sol,lt cette ligne pourrait ne servir a rien (ou deplacer au dessus)
Note: See TracChangeset
for help on using the changeset viewer.