Changeset 942 for trunk/UTIL
- Timestamp:
- Apr 25, 2013, 10:51:36 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/pp.py
r939 r942 53 53 parser.add_option('-o','--output',action='store',dest='filename',type="string",default="myplot",help="name of output files") 54 54 parser.add_option('-d','--directory',action='store',dest='folder',type="string",default="./",help="directory of output files") 55 parser.add_option('-s','--changetime',action='store',dest='changetime',type="string",default=None,help="transformation on time axis : [None] | mars_sol2ls") 55 parser.add_option('-s','--changetime',action='store',dest='changetime',type="string",default=None,\ 56 help="transformation on time axis : [None] | mars_sol2ls | mars_meso_ls | mars_meso_sol | mars_meso_utc | mars_meso_lt ") 56 57 # plot --> upper case 57 58 # -- generic -
trunk/UTIL/PYTHON/planetoplot_v2/pp_reload.py
r933 r942 14 14 parser.add_option('-P','--proj',action='store',dest='proj',type="string",default=None,help='[2D] Define a new map projection') 15 15 parser.add_option('-C','--colorb',action='store',dest='colorb',type="string",default=None,help="[2D] Define a new colormap") 16 parser.add_option('-E','--explore',action='store_true',dest='explore',default=False,help="[2D] Try many colormaps") 16 17 (opt,args) = parser.parse_args() 17 18 # ----------------------------------------------------------------------- 19 clb = ["Greys","Blues","YlOrRd",\ 20 "jet","spectral","hot",\ 21 "RdBu","RdYlBu","Paired",\ 22 "gist_ncar","gist_rainbow","gist_stern"] 23 # ----------------------------------------------------------------------- 24 18 25 for files in args: 26 19 27 yeah = pp() 20 28 yeah.defineplot(loadfile=files) 21 29 yeah.out = opt.out 30 22 31 if opt.proj is not None: 23 32 for plot in yeah.p: … … 32 41 for plot in yeah.p: 33 42 plot.title = opt.title 34 yeah.makeplot()35 43 44 if opt.explore: 45 for cm in clb: 46 for plot in yeah.p: 47 plot.colorb = cm 48 plot.title = cm 49 yeah.makeplot() 50 else: 51 yeah.makeplot() 52 -
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r936 r942 538 538 obj.file = self.file[i] 539 539 obj.var = self.var[j] 540 # get methods 541 obj.method_x = mx ; obj.method_y = my 542 obj.method_z = mz ; obj.method_t = mt 540 543 # indicate the computation method 541 544 obj.compute = self.compute … … 547 550 obj.changetime = self.changetime 548 551 obj.performtimechange() 549 ### get methods550 obj.method_x = mx ; obj.method_y = my551 obj.method_z = mz ; obj.method_t = mt552 552 ### get index 553 553 obj.getindextime(dalist=st,ind=t,stride=self.stridet) … … 1206 1206 # -------------------------- 1207 1207 def performtimechange(self): 1208 if self.changetime is not None \ 1209 and self.name_t != "t grid points": 1208 if self.changetime is not None: 1210 1209 if self.verbose: print "**** OK. Converting time axis:",self.changetime 1210 ### option added by T. Navarro 1211 1211 if self.changetime == "mars_sol2ls": 1212 1212 self.field_t = ppcompute.mars_sol2ls(self.field_t) 1213 ### options added by A. Spiga 1214 elif "mars_meso" in self.changetime: 1215 if 'Times' not in self.f.variables.keys(): 1216 if self.verbose: print "!! WARNING !! Variable Times not in file. Cannot proceed to change of time axis." 1217 else: 1218 # get the array of strings describing dates 1219 dates = self.f.variables['Times'] 1220 dates.set_auto_maskandscale(False) # necessary to solve the api Times bug! 1221 # get ls sol utc from those strings 1222 ls, sol, utc = ppcompute.mars_date(dates[:]) 1223 # populate self.field_t with the right output from mars_date 1224 if self.changetime == "mars_meso_ls": 1225 self.field_t = ls 1226 self.name_t = "Ls" 1227 elif self.changetime == "mars_meso_sol": 1228 self.field_t = sol 1229 self.name_t = "sol" 1230 elif self.changetime == "mars_meso_utc" \ 1231 and ( self.changetime == "mars_meso_lt" \ 1232 and not hasattr(self.f,'CEN_LON') ): 1233 self.field_t = ppcompute.timecorrect(utc) 1234 self.name_t = "utc" 1235 if self.method_t == "fixed": 1236 self.field_t = self.field_t % 24 # so that the user is not mistaken! 1237 elif self.changetime == "mars_meso_lt": 1238 self.field_t = ppcompute.timecorrect(utc) + getattr(self.f,'CEN_LON') / 15. 1239 self.field_t = ppcompute.timecorrect(self.field_t) 1240 self.name_t = "local time (center of domain)" 1241 if self.method_t == "fixed": 1242 self.field_t = self.field_t % 24 # so that the user is not mistaken! 1213 1243 else: 1214 1244 print "!! WARNING !! This time change is not implemented. Nothing is done." 1245 if self.verbose: print "**** OK. new t axis values [%5.1f,%5.1f]" % (self.field_t.min(),self.field_t.max()) 1215 1246 1216 1247 # get list of index to be retrieved for time axis -
trunk/UTIL/PYTHON/planetoplot_v2/ppcompute.py
r938 r942 231 231 return solout 232 232 233 # mars_date 234 # author A. Spiga 235 # ------------------------------ 236 # get Ls, sol, utc from a string with format yyyy-mm-dd_hh:00:00 237 # -- argument timechar is a vector of such strings indicating dates 238 # -- example: timechar = nc.variables['Times'][:] in mesoscale files 239 # NB: uses mars_sol2ls function above 240 # ------------------------------ 241 def mars_date(timechar): 242 # some preliminary information 243 days_in_month = [61, 66, 66, 65, 60, 54, 50, 46, 47, 47, 51, 56] 244 plus_in_month = [ 0, 61,127,193,258,318,372,422,468,515,562,613] 245 # get utc and sol from strings 246 utc = [] ; sol = [] 247 for zetime in timechar: 248 dautc = float(zetime[11]+zetime[12]) + float(zetime[14]+zetime[15])/37. 249 dasol = dautc / 24. 250 dasol = dasol + plus_in_month[ int(zetime[5]+zetime[6])-1 ] + int(zetime[8]+zetime[9]) 251 dasol = dasol - 1 ##les sols GCM commencent a 0 252 utc.append(dautc) 253 sol.append(dasol) 254 sol = np.array(sol) 255 utc = np.array(utc) 256 # get ls from sol 257 ls = mars_sol2ls(sol) 258 return ls, sol, utc 259 260 # timecorrect 261 # author A. Spiga 262 # ----------------------------- 263 # ensure time axis is monotonic 264 # correct negative values 265 # ----------------------------- 266 def timecorrect(time): 267 for ind in range(len(time)-1): 268 if time[ind] < 0.: time[ind] = time[ind] + 24. 269 if time[ind+1] < time[ind]: time[ind+1] = time[ind+1] + 24. 270 return time 271 -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r936 r942 220 220 amax = ppcompute.max(field) 221 221 if np.abs(amin) < 1.e-15: 222 zevmin = 0.223 222 cmin = 0. 224 223 else: … … 419 418 if self.lstyle is not None and self.color is not None: 420 419 mpl.plot(x,y,self.color+self.lstyle,marker=self.marker,label=self.label) 420 elif self.color is not None: 421 mpl.plot(x,y,color=self.color,marker=self.marker,label=self.label) 422 elif self.lstyle is not None: 423 mpl.plot(x,y,self.lstyle,marker=self.marker,label=self.label) 421 424 else: 422 425 mpl.plot(x,y,marker=self.marker,label=self.label) … … 672 675 ## draw colorbar. settings are different with projections. or if not mapmode. 673 676 if not self.mapmode: orientation=zeorientation ; frac = 0.075 ; pad = 0.03 ; lu = 0.5 674 elif self.proj in ['moll']: orientation="horizontal" ; frac = 0.0 75; pad = 0.03 ; lu = 1.0677 elif self.proj in ['moll']: orientation="horizontal" ; frac = 0.08 ; pad = 0.03 ; lu = 1.0 675 678 elif self.proj in ['cyl']: orientation="vertical" ; frac = 0.023 ; pad = 0.03 ; lu = 0.5 676 679 else: orientation = zeorientation ; frac = zefrac ; pad = 0.03 ; lu = 0.5 … … 690 693 ### not expecting NaN in self.addvecx and self.addvecy. masked arrays is just enough. 691 694 stride = 3 695 #stride = 1 692 696 if self.addvecx is not None and self.addvecy is not None and self.mapmode: 693 697 ### for metwinds only ??? … … 696 700 # reference vector is scaled 697 701 zescale = ppcompute.mean(np.sqrt(self.addvecx*self.addvecx+self.addvecy*self.addvecy)) 702 #zescale = 25. 698 703 # make vector field 699 704 q = m.quiver( x[::stride,::stride],y[::stride,::stride],\ … … 704 709 #keyh = 1.025 ; keyv = 1.05 # upper right corner over colorbar 705 710 keyh = 0.98 ; keyv = 1.06 711 keyh = 0.98 ; keyv = 1.07 706 712 #keyh = -0.03 ; keyv = 1.08 # upper left corner 707 713 p = mpl.quiverkey(q,keyh,keyv,\ 708 714 zescale,str(int(zescale)),\ 709 715 color='black',labelpos='S',labelsep = 0.07) 716 ############################################################################################ 717 ### TEXT. ANYWHERE. add_text.txt should be present with lines x ; y ; text ; color 718 ############################################################################################ 719 try: 720 f = open("add_text.txt", 'r') 721 for line in f: 722 if "#" in line: pass 723 else: 724 userx, usery, usert, userc = line.strip().split(';') 725 userc = userc.strip() 726 usert = usert.strip() 727 userx = float(userx.strip()) 728 usery = float(usery.strip()) 729 if self.mapmode: userx,usery = m(userx,usery) 730 mpl.text(userx,usery,usert,\ 731 color = userc,\ 732 horizontalalignment='center',\ 733 verticalalignment='center') 734 f.close() 735 except IOError: 736 pass -
trunk/UTIL/PYTHON/planetoplot_v2/set_area.txt
r930 r942 24 24 Xanadu ; -40 ; 20 ; 40 ; 120 25 25 Hyperboreae ; 80 ; 87 ; -70 ; -10 26 VM ; -1 5 ; 0 ; -90 ; -6026 VM ; -18 ; 0 ; -95 ; -40 27 27 VM_alt ; -15 ; 0 ; 270 ; 300 -
trunk/UTIL/PYTHON/planetoplot_v2/set_var.txt
r933 r942 58 58 ISR ; %.0f ; gist_heat ; Incoming Solar Radiation ; W m$^{-2}$ 59 59 SWDOWNZ ; %.0f ; gist_heat ; $\Phi^{SW}\downarrow$ ; W m$^{-2}$ 60 ZMAX_TH ; %.1f ; spectral ; PBL depth ; km
Note: See TracChangeset
for help on using the changeset viewer.