Changeset 424 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Nov 25, 2011, 1:42:00 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r423 r424 15 15 target=None, 16 16 stride=3,\ 17 numplot=None,\18 17 var=None,\ 19 18 colorb="def",\ … … 26 25 zoom=None,\ 27 26 display=True,\ 28 itstep=None,\29 27 hole=False,\ 30 28 save="gui",\ … … 32 30 var2=None,\ 33 31 ndiv=10,\ 34 first=1,\35 32 mult=1.,\ 36 33 zetitle="fill",\ … … 93 90 if svert is None: svert = readslices(str(level)) ; nvert=1 94 91 zelen = len(namefiles)*len(var) 95 if numplot is None:numplot = zelen*nslices92 numplot = zelen*nslices 96 93 print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", len(namefiles), nslices, len(var), numplot 97 94 print "********** MAPMODE: ", mapmode … … 230 227 ################################# 231 228 ### Time loop for plotting device 232 found_lct = False;nplot = 1;itime = first;error = False 233 if itstep is None and numplot > 0: itstep = int(24./numplot) 234 elif numplot <= 0: itstep = 1 229 nplot = 1;error = False 235 230 print "********************************************" 236 231 while error is False: 237 print "********** nplot", nplot, " itime",itime,"error",error232 print "********** nplot", nplot, "error",error 238 233 239 ### Which local time ?240 ltst = localtime ( interv[0]+itime*interv[1], 0.5*(wlon[0]+wlon[1]) )241 242 234 ### General plot settings 243 #print itime, int(ltst), numplot, nplot 244 if numplot >= 1: 245 if nplot > numplot: break 246 if numplot > 1: 247 if typefile not in ['geo']: subplot(subv,subh,nplot) 248 found_lct = True 249 ### If only one local time is requested (numplot < 0) 250 elif numplot <= 0: 251 if int(ltst) + numplot != 0: 252 itime += 1 253 if found_lct is True: break ## because it means LT was found at previous iteration 254 else: continue ## continue to iterate to find the correct LT 255 else: 256 found_lct = True 235 if nplot > numplot: break 236 if numplot > 1: subplot(subv,subh,nplot) 257 237 258 238 ### Map projection … … 260 240 m = define_proj(proj,wlon,wlat,back=back,blat=blat) 261 241 x, y = m(lon2d, lat2d) 262 #################################################################### 242 243 #################################################################### 263 244 ## get all indexes to be taken into account for this subplot and then reduce field 264 245 ## 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 … … 272 253 else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah 273 254 time = all_time[index_f] 274 275 if mapmode == 1 and stime is None: 276 indextime = itime 277 if len(var) != 1 or len(namefiles) != 1: indextime = first 278 else: 279 indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 280 if typefile in ['mesoapi','meso'] and indextime is not None: ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 281 #################################################################### 255 if stime is not None: 256 if stime[0][0] < 0: 257 if typefile in ['mesoapi','meso']: 258 for i in range(len(time)): time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) ) 259 stime = -stime ; print "OK... WORKING WITH LOCAL TIMES" 260 else: errormess("local times not supported for GCM files. not too hard to modify the code though.") 261 if mapmode == 1 and stime is None: indextime = 1 262 else: indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 263 if typefile in ['mesoapi','meso'] and indextime is not None: ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 264 #################################################################### 282 265 283 266 ticks = ndiv + 1 … … 418 401 # if indextime is not None: plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime])) 419 402 title( plottitle ) 420 itime += itstep421 403 if nplot >= numplot: error = True 422 404 nplot += 1 … … 446 428 zeplot=outputname 447 429 448 if found_lct: 449 pad_inches_value = 0.35 450 print "********** SAVE ", save 451 if save == 'png': 452 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 453 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 454 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 455 elif save == 'gui': show() 456 elif save == 'txt': print "Saved results in txt file." 457 else: 458 print "INFO: save mode not supported. using gui instead." 459 show() 460 else: print "!!! Local time not found" 430 pad_inches_value = 0.35 431 print "********** SAVE ", save 432 if save == 'png': 433 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 434 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 435 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 436 elif save == 'gui': show() 437 elif save == 'txt': print "Saved results in txt file." 438 else: 439 print "INFO: save mode not supported. using gui instead." 440 show() 461 441 462 442 ###############
Note: See TracChangeset
for help on using the changeset viewer.