Changeset 977 for trunk/UTIL
- Timestamp:
- Jun 4, 2013, 4:41:53 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/examples/les_psfc.py
r933 r977 2 2 from ppclass import pp 3 3 4 les = pp(file="/home/aymeric/Big_Data/ psfc_f18.nc",var="PSFC",y=["50,250"],x=["50","100"])4 les = pp(file="/home/aymeric/Big_Data/LES_dd/psfc_f18.nc",var="PSFC",y=["50,250"],x=["50","100"]) 5 5 les.verbose = True 6 6 les.getplot() -
trunk/UTIL/PYTHON/planetoplot_v2/examples/meso_profile.py
r960 r977 11 11 m.y = -5. # setting a fixed y value 12 12 m.z = None # leaving z as a free dimension 13 m.t = [6., 12.,18.,24.] # setting 4 fixed t values13 m.t = [6.,9.,12.,15.,18.,21.,24.] # setting 4 fixed t values 14 14 15 15 # define settings … … 17 17 #m.verbose = True # making the programe verbose 18 18 #m.out = "pdf" # output format 19 m.colorb = "spectral" # color cycle according to a color map 19 20 20 21 # get data and make plot with default settings … … 48 49 S.p[0].xlabel="Potential temperature (K)" 49 50 S.filename = "meso_profile" 51 S.colorb = None # come back to default color cycle 50 52 51 53 # make the plot -
trunk/UTIL/PYTHON/planetoplot_v2/pp.py
r972 r977 74 74 parser.add_option('--xcoeff',action='append',dest='xcoeff',type="float",default=None,help="[1D] multiply x axis") 75 75 parser.add_option('--ycoeff',action='append',dest='ycoeff',type="float",default=None,help="[1D] multiply y axis") 76 parser.add_option('--xmin',action='append',dest='xmin',type="float",default=None,help="[1D] min bound x axis") 77 parser.add_option('--ymin',action='append',dest='ymin',type="float",default=None,help="[1D] min bound y axis") 78 parser.add_option('--xmax',action='append',dest='xmax',type="float",default=None,help="[1D] max bound x axis") 79 parser.add_option('--ymax',action='append',dest='ymax',type="float",default=None,help="[1D] max bound y axis") 76 80 # -- 2D plot 77 81 parser.add_option('-C','--colorb',action='append',dest='colorb',type="string",default=None,help="[2D] colormap: http://micropore.files.wordpress.com/2010/06/colormaps.png") -
trunk/UTIL/PYTHON/planetoplot_v2/pp_reload.py
r960 r977 7 7 from optparse import OptionParser ### TBR by argparse 8 8 from ppclass import pp 9 from ppplot import rainbow 9 10 # ----------------------------------------------------------------------- 10 11 parser = OptionParser() … … 34 35 plot.proj = opt.proj 35 36 if opt.colorb is not None: 37 yeah.colorb = opt.colorb 36 38 for plot in yeah.p: 37 39 plot.colorb = opt.colorb -
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r972 r977 784 784 if self.title is not None: plobj.title = self.title 785 785 if self.units is not None: plobj.units = self.units 786 if self.colorb is not None: plobj.colorb = self.colorb 786 787 # -- 1D specific 787 788 if dp == 1: … … 795 796 if self.vmin is not None: plobj.vmin = self.vmin 796 797 if self.vmax is not None: plobj.vmax = self.vmax 797 if self.colorb is not None: plobj.colorb = self.colorb798 798 # finally append plot object 799 799 self.p.append(plobj) … … 909 909 self.fig.add_subplot(1,1,1,axisbg=pl.axisbg) # define one subplot (still needed for user-defined font sizes) 910 910 sav = pl.xlabel,pl.ylabel,pl.xcoeff,pl.ycoeff,pl.title,pl.swaplab # save titles and labels 911 # possibility to color lines according to a color map 912 # ... made so that all plots span the whole color map automatically. 913 if self.colorb is not None: 914 if self.verbose: print "**** OK. We make a rainbow spaghetti plot with color map ",self.colorb 915 ppplot.rainbow(cb=self.colorb,num=self.howmanyplots) 911 916 else: 912 917 pl.invert = False ; pl.lstyle = None # don't invert again axis … … 932 937 # once completed show the plot (cannot show intermediate plotin) 933 938 # ... added a fix (customplot=True) for the label problem in basemap 934 print "**** PPCLASS. Done step: makeplot"939 if not self.quiet: print "**** PPCLASS. Done step: makeplot" 935 940 if (self.n == self.howmanyplots): 936 941 ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=self.customplot,includedate=self.includedate,res=self.res) … … 1133 1138 except: 1134 1139 try: self.p[iii].wscale = opt.wscale[0] 1140 except: pass 1141 ### 1142 try: self.p[iii].xmin = opt.xmin[iii] 1143 except: 1144 try: self.p[iii].xmin = opt.xmin[0] 1145 except: pass 1146 ### 1147 try: self.p[iii].ymin = opt.ymin[iii] 1148 except: 1149 try: self.p[iii].ymin = opt.ymin[0] 1150 except: pass 1151 ### 1152 try: self.p[iii].xmax = opt.xmax[iii] 1153 except: 1154 try: self.p[iii].xmax = opt.xmax[0] 1155 except: pass 1156 ### 1157 try: self.p[iii].ymax = opt.ymax[iii] 1158 except: 1159 try: self.p[iii].ymax = opt.ymax[0] 1135 1160 except: pass 1136 1161 -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r972 r977 180 180 # useful functions # 181 181 #################### 182 183 # a function to change color lines according to a color map (idea by A. Pottier) 184 # ... two optional arguments: color maps + a number telling how much intervals are needed 185 def rainbow(cb="jet",num=8): 186 ax = mpl.gca() 187 pal = mpl.cm.get_cmap(name=cb) 188 ax._get_lines.set_color_cycle([pal(i) for i in np.linspace(0,0.9,num)]) 182 189 183 190 # a function to define subplot … … 299 306 ycoeff=1.,\ 300 307 fmt=None,\ 308 colorb="jet",\ 301 309 units="",\ 302 310 title=""): … … 318 326 self.fmt = fmt 319 327 self.units = units 328 self.colorb = colorb 320 329 ## other useful arguments 321 330 ## ... not used here in ppplot but need to be attached to plot object … … 382 391 self.marker = marker 383 392 self.label = label 393 self.xmin = None 394 self.ymin = None 395 self.xmax = None 396 self.ymax = None 384 397 385 398 # define_from_var … … 405 418 mpl.grid(color='grey') 406 419 if self.lstyle == "": self.lstyle = " " # to allow for no line at all with "" 420 # set dummy x axis if not defined 421 if self.absc is None: 422 self.absc = np.array(range(self.field.shape[0])) 423 print "!! WARNING !! dummy coordinates on x axis" 407 424 # swapping if requested 408 425 if self.swap: x = self.field ; y = self.absc … … 427 444 # ... this must be after plot so that axis bounds are well-defined 428 445 # ... also inverting must be after making the thing logarithmic 429 if self.logx: mpl. semilogx()430 if self.logy: mpl. semilogy()446 if self.logx: mpl.xscale("log") # not mpl.semilogx() because excludes log on y 447 if self.logy: mpl.yscale("log") # not mpl.semilogy() because excludes log on x 431 448 if self.invert: ax = mpl.gca() ; ax.set_ylim(ax.get_ylim()[::-1]) 432 449 # add a label for line(s) … … 446 463 if xmin < x1: x1 = xmin 447 464 if xmax > x2: x2 = xmax 465 if self.xmin is not None: x1 = self.xmin 466 if self.xmax is not None: x2 = self.xmax 448 467 ax.set_xbound(lower=x1,upper=x2) 449 468 # y-axis … … 453 472 if ymin < y1: y1 = ymin 454 473 if ymax > y2: y2 = ymax 474 if self.ymin is not None: y1 = self.ymin 475 if self.ymax is not None: y2 = self.ymax 455 476 ax.set_ybound(lower=y1,upper=y2) 456 477 ## set with .div the number of ticks. (is it better than automatic?) … … 478 499 proj="cyl",\ 479 500 back=None,\ 480 colorb="jet",\481 501 trans=1.0,\ 482 502 addvecx=None,\ … … 498 518 self.proj = proj 499 519 self.back = back 500 self.colorb = colorb501 520 self.trans = trans 502 521 self.addvecx = addvecx … … 527 546 # get what is done in the parent class... 528 547 plot.make(self) 529 if self.fmt is None: self.fmt = "%. 2e"548 if self.fmt is None: self.fmt = "%.1e" 530 549 # ... then add specific stuff 531 550 ############################################################################################ 532 551 ### PRE-SETTINGS 533 552 ############################################################################################ 534 # transposing if necessary535 shape = self.field.shape536 if shape[0] != shape[1]:537 if len(self.absc) == shape[0] and len(self.ordi) == shape[1]:538 print "!! WARNING !! Transposing axes"539 self.field = np.transpose(self.field)540 553 # set dummy xy axis if not defined 541 554 if self.absc is None: … … 547 560 self.mapmode = False 548 561 print "!! WARNING !! dummy coordinates on y axis" 562 # transposing if necessary 563 shape = self.field.shape 564 if shape[0] != shape[1]: 565 if len(self.absc) == shape[0] and len(self.ordi) == shape[1]: 566 print "!! WARNING !! Transposing axes" 567 self.field = np.transpose(self.field) 549 568 # bound field 550 569 zevmin, zevmax = calculate_bounds(self.field,vmin=self.vmin,vmax=self.vmax) -
trunk/UTIL/PYTHON/planetoplot_v2/set_ppclass.txt
r936 r977 13 13 # t-axis: possible names to search for. add in the line with a separating ; 14 14 # 15 Times;time;Time; time_counter;Ls15 Times;time;Time;Ls 16 16 # area: possible names to search for. add in the line with a separating ; 17 17 #
Note: See TracChangeset
for help on using the changeset viewer.