Changeset 1029 for trunk/UTIL/PYTHON
- Timestamp:
- Sep 5, 2013, 2:28:49 PM (11 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 26 added
- 16 deleted
- 5 edited
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/examples/additional/just_color_and_title.py
r1027 r1029 3 3 4 4 anewversion = pp() 5 anewversion.defineplot(loadfile="../ demo_data/gw.ppobj")5 anewversion.defineplot(loadfile="../../demo_data/gw.ppobj") 6 6 for plot in anewversion.p: 7 7 plot.colorb = "Paired" 8 plot.title = " This is a psychedelic plot"8 plot.title = "Psychedelic plot!" 9 9 anewversion.makeplot() -
trunk/UTIL/PYTHON/planetoplot_v2/examples/additional/vertpress.py
r1027 r1029 4 4 prof = pp() 5 5 prof.verbose = True 6 prof.file = "/home/aymeric/Big_Data/case_night.nc" 6 #prof.file = "/home/aymeric/Big_Data/case_night.nc" 7 prof.file = "/home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00:00:00_z" 7 8 prof.var = "tk" 8 9 prof.t = [10.,20.] 9 prof.x = 3010 prof.y = 3010 prof.x = -5. #30 11 prof.y = 138. #30 11 12 prof.filename = "vertpress" 12 13 -
trunk/UTIL/PYTHON/planetoplot_v2/pp.py
r1015 r1029 54 54 parser.add_option('-d','--directory',action='store',dest='folder',type="string",default="./",help="directory of output files") 55 55 parser.add_option('-s','--changetime',action='store',dest='changetime',type="string",default=None,\ 56 help="transformation on time axis : [None] | mars_sol2ls | mars_dayini | mars_meso_ls | mars_meso_sol | mars_meso_utc | mars_meso_lt ")56 help="transformation on time axis : [None] | correctls | mars_sol2ls | mars_dayini | mars_meso_ls | mars_meso_sol | mars_meso_utc | mars_meso_lt ") 57 57 parser.add_option('-p','--print',action='store_true',dest='savtxt',default=False,help="[1D] output field+coord in an ASCII file") 58 58 parser.add_option('--stridex',action='store',dest='stridex',type="int",default=1,help="Load data every stridex grid points over x dimension") -
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r1015 r1029 151 151 xlabel=None,ylabel=None,\ 152 152 xcoeff=None,ycoeff=None,\ 153 nxticks=10,nyticks=10,\ 153 154 proj=None,\ 154 155 vmin=None,vmax=None,\ … … 163 164 savtxt=False,\ 164 165 modx=None,\ 166 xp=16,yp=8,\ 167 missing=1.e25,\ 165 168 title=None): 166 169 self.request = None … … 203 206 self.savtxt = savtxt 204 207 self.modx = modx 208 self.missing = missing 205 209 ## here are user-defined plot settings 206 210 ## -- if not None, valid on all plots in the pp() objects … … 217 221 self.units = units 218 222 self.title = title 223 self.xp = xp ; self.yp = yp 224 self.nxticks = nxticks ; self.nyticks = nyticks 219 225 220 226 # print status … … 225 231 else: 226 232 print "**** PPCLASS. Done step: " + self.status 233 234 # print attributes 235 def printme(self): 236 for k, v in vars(self).items(): 237 print k,v 227 238 228 239 ##################################################### … … 268 279 self.savtxt = other.savtxt 269 280 self.modx = other.modx 281 self.xp = other.xp ; self.yp = other.yp 282 self.missing = other.missing 283 self.nxticks = other.nxticks ; self.nyticks = other.nyticks 270 284 else: 271 285 print "!! ERROR !! argument must be a pp object." ; exit() … … 589 603 obj.getindexvert(dalist=sz,ind=z) 590 604 obj.getindexhori(dalistx=sx,dalisty=sy,indx=x,indy=y) 605 # missing value 606 obj.missing = self.missing 591 607 # change status 592 608 self.status = "defined" … … 715 731 self.status = "definedplot" ; self.plotin = None 716 732 self.nplot = len(self.p) ; self.howmanyplots = self.nplot 717 return 733 ## [BUG FIX: apparently info about missing values is not saved correctly] 734 for count in range(self.nplot): 735 pl = self.p[count] 736 masked = np.ma.masked_where(np.abs(pl.field) > self.missing,pl.field) 737 pl.field = masked ; pl.field[pl.field.mask] = np.NaN 738 return #self? 718 739 # ----------------------------------------------------- 719 740 # REGULAR MODE … … 802 823 if self.colorb is not None: plobj.colorb = self.colorb 803 824 if self.modx is not None: plobj.modx = self.modx 825 if self.nxticks is not None: plobj.nxticks = self.nxticks 826 if self.nyticks is not None: plobj.nyticks = self.nyticks 804 827 # -- 1D specific 805 828 if dp == 1: … … 896 919 if self.plotin is None: 897 920 # start from scratch 898 self.fig = mpl.figure(figsize=(16,8))921 self.fig = ppplot.figuref(x=self.xp,y=self.yp) 899 922 self.subv,self.subh = ppplot.definesubplot(self.howmanyplots,self.fig) 900 923 self.n = 0 … … 1220 1243 self.changetime = None 1221 1244 self.stridex = 1 ; self.stridey = 1 ; self.stridez = 1 ; self.stridet = 1 1245 self.missing = '!! missing value: I am not set, damned !!' 1222 1246 1223 1247 # open a file. for now it is netcdf. TBD for other formats. … … 1309 1333 if self.verbose: print "**** OK. y axis %4.0f values [%5.1f,%5.1f]" % (self.dim_y,self.field_y.min(),self.field_y.max()) 1310 1334 # ALTITUDE. Try preset fields. If not present set grid points axis. 1311 # WARNING: how do we do if several are available? 1335 # WARNING: how do we do if several are available? the last one is chosen. 1312 1336 self.name_z = "nothing" 1313 1337 for c in glob_listz: … … 1329 1353 else: 1330 1354 self.field_z = self.f.variables[self.name_z][:] # specify dimension 1355 # TBD: problems when self.dim_z != self.field_z.size 1356 if self.field_z.size != self.dim_z: 1357 if self.verbose: print "!! WARNING !! Cannot use this z coordinate. Not enough points. Use simple z axis." 1358 self.field_z = np.array(range(self.dim_z)) 1359 self.name_z = "z grid points" 1331 1360 if self.dim_z > 1: 1332 1361 if self.verbose: print "**** OK. z axis %4.0f values [%5.1f,%5.1f]" % (self.dim_z,self.field_z.min(),self.field_z.max()) 1362 1333 1363 # TIME. Try preset fields. 1334 1364 self.name_t = "nothing" … … 1351 1381 else: 1352 1382 daint = tabtime[1] - dafirst 1353 dalast = dafirst + (self.dim_t-1)*daint 1354 if dalast != tabtime[self.dim_t-1] and self.verbose: 1355 print "!! WARNING !! Time axis has been recast to be monotonic",dalast,tabtime[self.dim_t-1] 1383 dalast = dafirst + (self.dim_t-1)*daint 1356 1384 self.field_t = np.linspace(dafirst,dalast,num=self.dim_t) 1385 if self.verbose: 1386 print "!! WARNING !! WARNING !! Time axis is supposed to be equally spaced !! 1387 if dalast != tabtime[self.dim_t-1]: 1388 print "!! WARNING !! Time axis has been recast to be monotonic",dalast,tabtime[self.dim_t-1] 1357 1389 except: 1358 1390 # ... or if a problem encountered, define a simple time axis … … 1369 1401 if self.changetime is not None: 1370 1402 if self.verbose: print "**** OK. Converting time axis:",self.changetime 1371 ### option added by T. Navarro1403 ### options added by T. Navarro 1372 1404 if self.changetime == "mars_sol2ls": 1373 1405 if "controle" in self.f.variables: … … 1381 1413 + self.f.variables['controle'][26] 1382 1414 ### options added by A. Spiga 1415 elif self.changetime == "correctls": 1416 # not regularly spaced + handle modulo 360. in files 1417 dafirst = tabtime[0] + 0. 1418 daint = tabtime[1] - dafirst 1419 dalast = dafirst + (self.dim_t-1)*daint 1420 year = 0. 1421 add = np.linspace(dafirst,dalast,num=self.dim_t) ; add[0] = 0. 1422 for iii in range(1,self.dim_t): 1423 if tabtime[iii] - tabtime[iii-1] < 0: year = year+1. 1424 add[iii] = year*360. 1425 self.field_t = add + tabtime 1383 1426 elif "mars_meso" in self.changetime: 1384 1427 if 'Times' not in self.f.variables.keys(): … … 1671 1714 # make a mask in case there are non-NaN missing values. (what about NaN missing values?) 1672 1715 # ... this is important for computations below (see ppcompute) 1673 masked = np.ma.masked_where(np.abs(self.field) > 1e25,self.field)1716 masked = np.ma.masked_where(np.abs(self.field) > self.missing,self.field) 1674 1717 if masked.mask.any() == True: 1675 if self.verbose: print "!! WARNING !! Values over +-1e25 are considered missing values."1718 if self.verbose: print "!! WARNING !! Values over %5.3e are considered missing values." % self.missing 1676 1719 self.field = masked 1677 1720 self.field.set_fill_value([np.NaN]) -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r1027 r1029 187 187 # a function for predefined figure sizes 188 188 def figuref(x=16,y=9): 189 mpl.figure(figsize=(x,y)) 189 fig = mpl.figure(figsize=(x,y)) 190 return fig 190 191 191 192 # a function to change color lines according to a color map (idea by A. Pottier) … … 208 209 subv, subh = subv_t[numplot],subh_t[numplot] 209 210 except: 210 print "!! WARNING !! no preset found from set_multiplot.txt, or this setting file was not found."211 print "!! WARNING !! (ignore if superpose mode) no preset found from set_multiplot.txt, or this setting file was not found." 211 212 subv = 1 ; subh = numplot 212 213 return subv,subh … … 355 356 xmax=None,\ 356 357 ymax=None,\ 358 nxticks=10,\ 359 nyticks=10,\ 357 360 title=""): 358 361 ## what could be defined by the user … … 379 382 self.xmax = xmax 380 383 self.ymax = ymax 384 self.nxticks = nxticks 385 self.nyticks = nyticks 381 386 ## other useful arguments 382 387 ## ... not used here in ppplot but need to be attached to plot object … … 532 537 ## set with .div the number of ticks. (is it better than automatic?) 533 538 if not self.logx: 534 ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) 539 ax.xaxis.set_major_locator(MaxNLocator(self.div/2)) #TBD: with nxticks? 535 540 else: 536 541 print "!! WARNING. in logx mode, ticks are set automatically." … … 684 689 if self.ymin is not None: ax.set_ybound(lower=self.ymin) 685 690 if self.ymax is not None: ax.set_ybound(upper=self.ymax) 686 # set the number of ticks (hardcoded) 687 ax.xaxis.set_major_locator(MaxNLocator(10)) 691 # set the number of ticks 692 if not self.logx: 693 ax.xaxis.set_major_locator(MaxNLocator(self.nxticks)) 694 else: 695 print "!! WARNING. in logx mode, ticks are set automatically." 688 696 ## specific modulo labels 689 697 if self.modx is not None: … … 773 781 if self.back in back.keys(): 774 782 print "**** info: loading a background, please wait.",self.back 775 if self.back not in ["coast","sea"]: m.warpimage(back[self.back],scale=0.75) 776 elif self.back == "coast": m.drawcoastlines() 777 elif self.back == "sea": m.drawlsmask(land_color='white',ocean_color='aqua') 783 if self.back not in ["coast","sea"]: 784 try: m.warpimage(back[self.back],scale=0.75) 785 except: print "!! ERROR !! no background image could be loaded. probably not connected to the internet?" 786 elif self.back == "coast": 787 m.drawcoastlines() 788 elif self.back == "sea": 789 m.drawlsmask(land_color='white',ocean_color='aqua') 778 790 else: 779 791 print "!! ERROR !! requested background not defined. change name or fill in set_back.txt" ; exit() -
trunk/UTIL/PYTHON/planetoplot_v2/set_back.txt
r933 r1029 7 7 tesalbedo ; http://www.lmd.jussieu.fr/~aslmd/maps/tesalbedo.jpg 8 8 vis ; http://www.lmd.jussieu.fr/~aslmd/maps/mar0kuu2.jpg 9 vishires ; http://www.lmd.jussieu.fr/~aslmd/maps/MarsMap_2500x1250.jpg9 vishires ; /home/aymeric/Dropbox/Public/MarsMap_2500x1250.jpg 10 10 geolocal ; http://www.lmd.jussieu.fr/~aslmd/maps/geolocal.jpg 11 11 mola ; http://www.lmd.jussieu.fr/~aslmd/maps/mars-mola-2k.jpg 12 molabw ; http://www.lmd.jussieu.fr/~aslmd/maps/MarsElevation_2500x1250.jpg12 molabw ; /home/aymeric/Dropbox/Public/MarsElevation_2500x1250.jpg 13 13 bw ; http://www.lmd.jussieu.fr/~aslmd/maps/EarthElevation_2500x1250.jpg 14 14 contrast ; http://www.lmd.jussieu.fr/~aslmd/maps/EarthMapAtmos_2500x1250.jpg … … 24 24 titan ; http://laps.noaa.gov/albers/sos/saturn/titan/titan_rgb_cyl_www.jpg 25 25 titanuni ; http://maps.jpl.nasa.gov/pix/sat6fss1.jpg 26 titanreg ; http://laps.noaa.gov/albers/sos/features/combined_titan_lon_zero_center.png 26 27 venus ; http://laps.noaa.gov/albers/sos/venus/venus4/venus4_rgb_cyl_www.jpg 27 28 cosmic ; http://laps.noaa.gov/albers/sos/universe/wmap/wmap_rgb_cyl_www.jpg -
trunk/UTIL/PYTHON/planetoplot_v2/set_var.txt
r990 r1029 4 4 ################################## 5 5 T ; %.0f ; gist_heat ; Temperature ; K 6 TEMP ; % 0.f ; gist_heat ; Temperature ; K6 TEMP ; %.1f ; gist_heat ; Temperature ; K 7 7 TPOT ; %.0f ; Paired ; Potential temperature ; K 8 8 TSURF ; %.0f ; RdBu_r ; Surface temperature ; K
Note: See TracChangeset
for help on using the changeset viewer.