Changeset 647 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- May 3, 2012, 6:46:55 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r642 r647 66 66 lbls=None,\ 67 67 lstyle=None,\ 68 cross=None): 68 cross=None,\ 69 streamflag=False): 69 70 70 71 #################################################################################################################### … … 91 92 #from singlet import singlet 92 93 from itertools import cycle 94 import os 93 95 94 96 ######################### … … 414 416 if mult != 2718.: what_I_plot = what_I_plot*mult 415 417 else: what_I_plot = np.log10(what_I_plot) ; print "log plot" 418 416 419 if var2: ### what is contoured. 417 420 what_I_plot_contour, error = reducefield( all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, \ … … 523 526 if indexvert is not None: lbl = lbl + " iz" + str(indexvert[0]) 524 527 if indextime is not None: lbl = lbl + " it" + str(indextime[0]) 525 if lbl == "": lbl = namefiles[index_f]528 if lbl == "": lbl = all_namefile[index_f] 526 529 527 530 if mrate is not None: x = y ## because swapaxes... … … 539 542 540 543 elif which == "regular": 544 545 # plot stream lines if there is a stream file and a vert/lat slice. Might not work with movies ?? 546 if streamflag and sslat is None and svert is None: 547 streamfile = all_namefile[index_f].replace('.nc','_stream.nc') 548 teststream = os.path.exists(streamfile) 549 if teststream: 550 print 'INFO: Using stream file',streamfile, 'for stream lines' 551 ncstream = Dataset(streamfile) 552 psi = getfield(ncstream,'psi') 553 psi = psi[0,:,:,0] # time and longitude are dummy dimensions 554 if psi.shape[1] != len(x) or psi.shape[0] != len(y): 555 errormess('stream file does not fit! Dimensions: '+str(psi.shape)+' '+str(x.shape)+' '+str(y.shape)) 556 zelevels = np.arange(-1.e10,1.e10,1.e9) 557 zemin = np.min(abs(zelevels)) 558 zemax = np.max(abs(zelevels)) 559 zewidth = (abs(zelevels)-zemin)*(5.- 0.5)/(zemax - zemin) + 0.5 # linewidth ranges from 5 to 0.5 560 cs = contour( x,y,psi, zelevels, colors='k', linewidths = zewidth) 561 clabel(cs, inline=True, fontsize = 4.*rcParams['font.size']/5., fmt="%1.1e") 562 else: 563 print 'WARNING: STREAM FILE',streamfile, 'DOES NOT EXIST !' 564 541 565 if hole: what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax) 542 566 else: what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax) … … 554 578 if mapmode == 1: m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans) 555 579 elif mapmode == 0: pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans) 580 556 581 557 582 if colorb not in ['nobar','onebar']: … … 591 616 zebins = np.linspace(zevmin,zevmax,num=30) 592 617 hist(toplot,bins=zebins,histtype='step',linewidth=2,color='k',normed=True) 593 zestd = np.std(toplot) 594 zemean = np.mean(toplot) 618 zestd = np.std(toplot);zemean = np.mean(toplot) 595 619 zebins = np.linspace(zevmin,zevmax,num=300) 596 620 zegauss = (1./(zestd * np.sqrt(2 * np.pi)) * np.exp( - (zebins - zemean)**2 / (2 * zestd**2) ) ) … … 675 699 if index_f is numplot-1: plottitle = basename+' '+"fig(1) "+ope+" fig(2)" 676 700 elif index_f is numplot-2: plottitle = basename+' '+fileref 677 else: plottitle = basename+' '+ namefiles[0]#index_f]678 else: plottitle = basename+' '+ namefiles[0]#index_f]701 else: plottitle = basename+' '+all_namefile[index_f] 702 else: plottitle = basename+' '+all_namefile[index_f] 679 703 if mult != 1: plottitle = '{:.0e}'.format(mult) + "*" + plottitle 680 704 if zetitle[0] != "fill":
Note: See TracChangeset
for help on using the changeset viewer.