Changeset 923 for trunk/UTIL
- Timestamp:
- Mar 31, 2013, 10:18:37 PM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 3 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/README.TXT
r920 r923 30 30 data 31 31 ---- 32 - demo_data/* --> plot objects for a demonstration tour and customizing tests 32 plot objects for a demonstration tour and customizing tests 33 https://dl.dropbox.com/u/11078310/demo_data.tar.gz 33 34 34 35 Requirements -
trunk/UTIL/PYTHON/planetoplot_v2/examples/aire.py
r921 r923 11 11 tpond.compute = "meanarea" 12 12 tpond.superpose = True 13 tpond.label = "mean with ponderation by mesh area" 13 14 tpond.getplot(extraplot=1) 14 15 … … 17 18 tnormal.compute = "mean" 18 19 tnormal.plotin = tpond 20 tnormal.label = "simple mean (kind of wrong)" 21 tnormal.filename = "aire" 19 22 tnormal.getplot() 20 23 -
trunk/UTIL/PYTHON/planetoplot_v2/examples/anomaly.py
r910 r923 17 17 ## COMPUTE AND PLOT RELATIVE ANOMALY in % 18 18 anomaly = ((simple-mean)/mean)*100. 19 anomaly.filename = "anomaly" 19 20 anomaly.defineplot() 20 21 anomaly.p[0].title = "surface temperature anomaly in %" -
trunk/UTIL/PYTHON/planetoplot_v2/examples/chain_pp.sh
r910 r923 1 1 #! /bin/bash 2 2 3 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc4 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -v v -t 0.5 -z 10.5 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -y 26 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -y 2 -m 1000 -L --7 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -C spectral8 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P ortho9 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P moll10 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P npstere11 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P spstere12 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P cyl -A Tharsis13 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P lcc -A Tharsis14 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P laea -A Tharsis15 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -A Tropics -P merc16 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -c phisinit -t 0.5 -z 10. -T Yeah -P laea -A Tharsis17 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P merc -A Whole_No_High18 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P robin3 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc 4 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -v v -t 0.5 -z 10. 5 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -y 2 6 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -y 2 -m 1000 -L -- 7 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -C spectral 8 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P ortho 9 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P moll 10 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P npstere 11 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P spstere 12 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P cyl -A Tharsis 13 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P lcc -A Tharsis 14 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -z 10. -T Yeah -P laea -A Tharsis 15 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -A Tropics -P merc 16 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -c phisinit -t 0.5 -z 10. -T Yeah -P laea -A Tharsis 17 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P merc -A Whole_No_High 18 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P robin 19 19 20 ./pp.py -f/home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:0021 ./pp.py -f/home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 -v HGT -B vishires22 ./pp.py -f/home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 -v HGT -t 1. -B vishires -H 0.523 ./pp.py -f/home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 -v HGT -t 1. -P ortho -B vishires20 ./pp.py /home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 21 ./pp.py /home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 -v HGT -B vishires 22 ./pp.py /home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 -v HGT -t 1. -B vishires -H 0.5 23 ./pp.py /home/aymeric/Big_Data/GALE/wrfout_d03_2024-06-09_00\:00\:00 -v HGT -t 1. -P ortho -B vishires 24 24 25 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P robin26 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -x 10 -C jet -P robin27 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P robin -H 0.5 -B vishires25 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P robin 26 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v u -t 0.5 -x 10 -C jet -P robin 27 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v ps -t 0.5 -z 10. -C jet -P robin -H 0.5 -B vishires 28 28 29 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -P robin30 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v phisinit -P ortho -I -120.31 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v phisinit -P ortho -I -120. -v phisinit -I 12032 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v phisinit -P ortho -I -120. -v phisinit33 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P robin -I -120. -v icetot -I 120.29 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -P robin 30 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v phisinit -P ortho -I -120. 31 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v phisinit -P ortho -I -120. -v phisinit -I 120 32 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v phisinit -P ortho -I -120. -v phisinit 33 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P robin -I -120. -v icetot -I 120. 34 34 35 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll36 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll -i u -j v37 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll -i u -j v -z 10.38 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll -i u -j v -z 10000.39 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P cyl -i u -j v -z 10000. --verbose40 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P cyl -i u -j v -z 10000. -c phisinit41 ./pp.py -f/home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P cyl -z 10000. -c temp35 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll 36 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll -i u -j v 37 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll -i u -j v -z 10. 38 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P moll -i u -j v -z 10000. 39 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P cyl -i u -j v -z 10000. --verbose 40 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P cyl -i u -j v -z 10000. -c phisinit 41 ./pp.py /home/aymeric/Big_Data/DATAPLOT/diagfired.nc -v icetot -t 1. -P cyl -z 10000. -c temp 42 42 43 ./pp.py -fwrfout_d03_2024-06-09_00\:00\:00_z -v tk -c HGT -t 1 -z 0 -P lcc -i Um -j Vm --verbose43 ./pp.py wrfout_d03_2024-06-09_00\:00\:00_z -v tk -c HGT -t 1 -z 0 -P lcc -i Um -j Vm --verbose -
trunk/UTIL/PYTHON/planetoplot_v2/examples/hodograph.py
r910 r923 17 17 # u as a function of v 18 18 hodo = u.f(v) 19 hodo.filename = "hodograph" 19 20 hodo.makeplot() 20 21 -
trunk/UTIL/PYTHON/planetoplot_v2/examples/les_psfc.py
r910 r923 14 14 les.y = None 15 15 les.t = ["10"] 16 #les.stridex = 3 17 #les.stridey = 3 16 les.stridex = 3 17 les.stridey = 3 18 les.filename = "les_psfc" 18 19 les.getplot() -
trunk/UTIL/PYTHON/planetoplot_v2/examples/meso_profile.py
r910 r923 47 47 S.p[0].ylabel="Geopotential height (km)" 48 48 S.p[0].xlabel="Potential temperature (K)" 49 S.filename = "meso_profile" 49 50 50 51 # make the plot -
trunk/UTIL/PYTHON/planetoplot_v2/examples/scatter.py
r910 r923 50 50 S3.p[0].color="k" 51 51 S3.p[0].ylabel="wind speed $\sqrt{u^{2}+v^{2}}$ (m s$^{-1}$)" 52 S3.filename="scatter" 52 53 S3.makeplot() 53 54 -
trunk/UTIL/PYTHON/planetoplot_v2/examples/simple.py
r910 r923 21 21 u.p[0].title = "This is what we name $u$ (m s$^{-1}$)" 22 22 u.p[0].proj = "robin" 23 u.filename = "simple" 23 24 24 25 # we plot … … 28 29 # ... no need to reload data 29 30 u.p[0].colorb = "RdBu" 31 u.filename = "myplot" 30 32 u.makeplot() 31 33 -
trunk/UTIL/PYTHON/planetoplot_v2/examples/vector.py
r910 r923 8 8 u.t = "0.5,0.8" 9 9 u.z = "50000" 10 u.filename = "vector" 10 11 u.get() 11 12 u.defineplot() … … 16 17 17 18 u.z = "50" 19 u.filename = "myplot" 18 20 u.getplot() 19 21 -
trunk/UTIL/PYTHON/planetoplot_v2/examples/vertpress.py
r910 r923 9 9 prof.x = 30 10 10 prof.y = 30 11 prof.filename = "vertpress" 11 12 12 13 prof.get() -
trunk/UTIL/PYTHON/planetoplot_v2/examples/windspeed.py
r910 r923 25 25 wind = wind**0.5 26 26 wind.plotin = v 27 wind.filename = "windspeed" 27 28 wind.defineplot() 28 29 wind.p[2].title = "$\sqrt{u^2+v^2}$ (m s$^{-1}$)" -
trunk/UTIL/PYTHON/planetoplot_v2/examples/zonalcontour.py
r910 r923 8 8 u.x = "0" 9 9 u.t = "0.5" 10 u.filename = "zonalcontour" 10 11 u.get() 11 12 u.defineplot() -
trunk/UTIL/PYTHON/planetoplot_v2/examples/zonalmean.py
r910 r923 21 21 u.y = None 22 22 u.t = "0.5" 23 u.filename = "zonalmean" 23 24 u.get() 24 25 u.defineplot() … … 30 31 ## ZONAL MINIMUM 31 32 u.compute = "min" 33 u.filename = "zonalmin" 32 34 u.get() 33 35 u.defineplot() … … 39 41 ## ZONAL MAXIMUM 40 42 u.compute = "max" 43 u.filename = "myplot" 41 44 u.get() 42 45 u.defineplot() -
trunk/UTIL/PYTHON/planetoplot_v2/pp.py
r921 r923 16 16 # ... see sample scripts 17 17 18 ##################################### 19 # get arguments from the command line20 ##################################### 18 ###################################### 19 # define parser with version and usage 20 ###################################### 21 21 parser = OptionParser() 22 parser.version = \ 23 '''************************************************************************ 24 PLANETOPLOT (for help: pp.py -h) 25 --> command line tool to make nice & quick plots from netCDF files 26 --> based on python + numpy + scipy + matplotlib + basemap + netCDF4 27 --> Author: A. Spiga (LMD/UPMC) aymeric.spiga@upmc.fr 28 ************************************************************************''' 29 parser.usage = \ 30 '''pp.py [options] netCDF file(s) 31 (NB: no options --> simple inspection of variables and dimensions in netCDF files''' 32 parser.print_version() 33 34 ######################################## 35 # set options for the pp.py command line 36 ######################################## 22 37 parser.add_option('--verbose',action='store_true',dest='verbose',default=False,help='make the program verbose') 23 38 # field --> lower case 24 parser.add_option('-f','--file',action='append',dest='file',type="string",default=None,help="[NEEDED] 'file' or ['file1','file2',etc]")25 39 parser.add_option('-v','--var',action='append',dest='var',type="string",default=None,help="'variable' or ['var1','var2',etc]") 26 parser.add_option('-x','--lon',action='append',dest='x',type="string",default=None,help="x axis value. eitherone value; or val1,val2 (computations)")27 parser.add_option('-y','--lat',action='append',dest='y',type="string",default=None,help="y axis value. eitherone value; or val1,val2 (computations)")28 parser.add_option('-z','--vert',action='append',dest='z',type="string",default=None,help="z axis value. eitherone value; or val1,val2 (computations)")29 parser.add_option('-t','--time',action='append',dest='t',type="string",default=None,help="t axis value. eitherone value; or val1,val2 (computations)")30 parser.add_option('-u','--compute',action='store',dest='compute',type="string",default="mean",help="computation: mean, min, max ")40 parser.add_option('-x','--lon',action='append',dest='x',type="string",default=None,help="x axis value. one value; or val1,val2 (computations)") 41 parser.add_option('-y','--lat',action='append',dest='y',type="string",default=None,help="y axis value. one value; or val1,val2 (computations)") 42 parser.add_option('-z','--vert',action='append',dest='z',type="string",default=None,help="z axis value. one value; or val1,val2 (computations)") 43 parser.add_option('-t','--time',action='append',dest='t',type="string",default=None,help="t axis value. one value; or val1,val2 (computations)") 44 parser.add_option('-u','--compute',action='store',dest='compute',type="string",default="mean",help="computation: mean, min, max, meanarea") 31 45 parser.add_option('-c','--contour',action='store',dest='contour',type="string",default=None,help="one 'variable' for contour") 32 46 parser.add_option('-i','--vecx',action='store',dest='vecx',type="string",default=None,help="one 'variable' for wind vector x component") … … 36 50 parser.add_option('-o','--output',action='store',dest='filename',type="string",default="myplot",help="name of output files") 37 51 parser.add_option('-d','--directory',action='store',dest='folder',type="string",default="./",help="directory of output files") 38 parser.add_option('-u','--compute',action='store',dest='compute',type="string",default="mean",help='')39 52 # plot --> upper case 40 53 # -- generic … … 51 64 parser.add_option('-K','--marker',action='append',dest='marker',type="string",default=None,help="[1D] marker: '' 'x' 'o' etc") 52 65 parser.add_option('-S','--superpose',action='store_true',dest='superpose',default=False,help="[1D] use same axis for all plots") 66 parser.add_option('-E','--label',action='append',dest='label',type="string",default=None,help="[1D] label for line") 53 67 # -- 2D plot 54 68 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") … … 62 76 (opt,args) = parser.parse_args() 63 77 64 ########################################## 65 # a possibility to simply inspect the file 66 ########################################## 67 if opt.file is None: 68 print "Stop here. I need at least a file: -f FILE" ; exit() 78 ###################################### 79 # get arguments (one or several files) 80 ###################################### 81 if args is None: 82 print "Stop here! I need file(s) as argument(s)!" ; exit() 83 else: 84 files = args 85 86 ############################################# 87 # a possibility to simply inspect the file(s) 88 ############################################# 69 89 if opt.var is None: 70 for filename in opt.file: inspect(filename)90 for filename in files: inspect(filename) 71 91 exit() 72 92 … … 83 103 # set pp object 84 104 user = pp() 85 user.file = opt.file 86 user.var = var 87 user.vargoal = vargoal 88 user.x = opt.x 89 user.y = opt.y 90 user.z = opt.z 91 user.t = opt.t 105 user.file = files 106 user.var = var ; user.vargoal = vargoal 107 user.x = opt.x ; user.y = opt.y 108 user.z = opt.z ; user.t = opt.t 92 109 user.verbose = opt.verbose 93 110 user.compute = opt.compute … … 118 135 try: 119 136 f = open(opt.folder+'/'+opt.filename+'.sh', 'w') 120 f.write(command) 137 f.write(command) 121 138 except IOError: 122 139 print "!! WARNING !! pp.py command not saved. Probably do not have permission to write here." -
trunk/UTIL/PYTHON/planetoplot_v2/pp_reload.py
r917 r923 10 10 parser = OptionParser() 11 11 parser.add_option('-O','--out',action='store',dest='out',type="string",default="gui",help='Specify a new output format') 12 parser.add_option('-P','--proj',action='store',dest='proj',type="string",default=None,help='Define a new map projection') 12 parser.add_option('-K','--marker',action='store',dest='marker',type="string",default=None,help="[1D] Define a new marker") 13 parser.add_option('-P','--proj',action='store',dest='proj',type="string",default=None,help='[2D] Define a new map projection') 14 parser.add_option('-C','--colorb',action='store',dest='colorb',type="string",default=None,help="[2D] Define a new colormap") 13 15 (opt,args) = parser.parse_args() 14 16 # ----------------------------------------------------------------------- … … 20 22 for plot in yeah.p: 21 23 plot.proj = opt.proj 24 if opt.colorb is not None: 25 for plot in yeah.p: 26 plot.colorb = opt.colorb 27 if opt.marker is not None: 28 for plot in yeah.p: 29 plot.marker = opt.marker 22 30 yeah.makeplot() 23 31 -
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r921 r923 24 24 #### ... executed when imported ## 25 25 ################################### 26 print "************************************"27 print "**** WELCOME TO PLANETOPLOT 2.0 ****"28 print "************************************"29 26 # where settings files are located... 30 27 whereset = None … … 143 140 out="gui",\ 144 141 filename="myplot",\ 145 folder="./"): 142 folder="./",\ 143 xlabel=None,ylabel=None,\ 144 xcoeff=None,ycoeff=None,\ 145 proj=None,\ 146 vmin=None,vmax=None,\ 147 div=None,\ 148 colorb=None,\ 149 lstyle=None,\ 150 marker=None,\ 151 color=None,\ 152 label=None,\ 153 title=None): 146 154 self.request = None 147 155 self.nfin = 0 ; self.nvin = 0 … … 172 180 self.filename = filename 173 181 self.folder = folder 182 ## here are user-defined plot settings 183 ## -- if not None, valid on all plots in the pp() objects 184 self.xlabel = xlabel ; self.xcoeff = xcoeff 185 self.ylabel = ylabel ; self.ycoeff = ycoeff 186 self.proj = proj 187 self.vmin = vmin ; self.vmax = vmax 188 self.div = div 189 self.colorb = colorb 190 self.lstyle = lstyle 191 self.marker = marker 192 self.color = color 193 self.label = label 194 self.title = title 174 195 175 196 # print status … … 178 199 pass 179 200 else: 180 print "**** Done step: " + self.status201 print "**** PPCLASS. Done step: " + self.status 181 202 182 203 ##################################################### 183 204 # EMULATE OPERATORS + - * / ** << FOR PP() OBJECTS # 184 205 ##################################################### 206 207 # define the operation << 208 # ... e.g. obj2 << obj1 209 # ... means: get init for pp object obj2 from another pp object obj1 210 # ... (this should solve the affectation trap obj2 = obj1) 211 def __lshift__(self,other): 212 if other.__class__.__name__ == "pp": 213 self.file = other.file 214 self.var = other.var 215 self.filegoal = other.filegoal 216 self.vargoal = other.vargoal 217 self.x = other.x ; self.y = other.y ## if None, free dimension 218 self.z = other.z ; self.t = other.t ## if None, free dimension 219 self.stridex = other.stridex ; self.stridey = other.stridey 220 self.stridez = other.stridez ; self.stridet = other.stridet 221 self.verbose = other.verbose 222 self.noproj = other.noproj 223 self.plotin = other.plotin 224 self.superpose = other.superpose 225 self.forcedimplot = other.forcedimplot 226 self.out = other.out 227 self.filename = other.filename 228 self.folder = other.folder 229 self.xlabel = other.xlabel ; self.xcoeff = other.xcoeff 230 self.ylabel = other.ylabel ; self.ycoeff = other.ycoeff 231 self.proj = other.proj 232 self.vmin = other.vmin ; self.vmax = other.vmax 233 self.div = other.div 234 self.colorb = other.colorb 235 self.lstyle = other.lstyle 236 self.marker = other.marker 237 self.color = other.color 238 self.label = other.label 239 self.title = other.title 240 else: 241 print "!! ERROR !! argument must be a pp object." ; exit() 185 242 186 243 # check the compatibility of two objects for operations … … 236 293 setattr(obj,k,v) 237 294 the_clone.status = "retrieved" 295 the_clone.filename = self.filename 238 296 return the_clone 239 297 … … 258 316 else: 259 317 ope = other 260 if "vector" in self.vargoal[j] + self.filegoal[i]: 261 print "!! ERROR !! we do not operate on vectors yet." 262 exit() 318 goal = self.vargoal[j] + self.filegoal[i] 319 if ("vector" in goal) or ("contour" in goal): 320 if self.verbose: print "!! WARNING !! No operation was made on contours and vectors. This can be debatted actually." 321 obj.field = obj_ref.field 263 322 else: 264 323 obj.field = obj_ref.field + ope … … 285 344 else: 286 345 ope = other 287 if "vector" in self.vargoal[j] + self.filegoal[i]: 288 print "!! ERROR !! we do not operate on vectors yet." 289 exit() 346 goal = self.vargoal[j] + self.filegoal[i] 347 if ("vector" in goal) or ("contour" in goal): 348 if self.verbose: print "!! WARNING !! No operation was made on contours and vectors. This can be debatted actually." 349 obj.field = obj_ref.field 290 350 else: 291 351 obj.field = obj_ref.field - ope … … 312 372 else: 313 373 ope = other 314 if "vector" in self.vargoal[j] + self.filegoal[i]: 315 print "!! ERROR !! we do not operate on vectors yet." 316 exit() 374 goal = self.vargoal[j] + self.filegoal[i] 375 if ("vector" in goal) or ("contour" in goal): 376 if self.verbose: print "!! WARNING !! No operation was made on contours and vectors. This can be debatted actually." 377 obj.field = obj_ref.field 317 378 else: 318 379 obj.field = obj_ref.field * ope … … 339 400 else: 340 401 ope = other 341 if "vector" in self.vargoal[j] + self.filegoal[i]: 342 print "!! ERROR !! we do not operate on vectors yet." 343 exit() 402 goal = self.vargoal[j] + self.filegoal[i] 403 if ("vector" in goal) or ("contour" in goal): 404 if self.verbose: print "!! WARNING !! No operation was made on contours and vectors. This can be debatted actually." 405 obj.field = obj_ref.field 344 406 else: 345 407 obj.field = obj_ref.field / ope … … 383 445 obj = the_clone.request[i][j][t][z][y][x] 384 446 obj_ref = self.request[i][j][t][z][y][x] 385 if "vector" in self.vargoal[j] + self.filegoal[i]: 386 print "!! ERROR !! we do not operate on vectors yet." 387 exit() 447 goal = self.vargoal[j] + self.filegoal[i] 448 if ("vector" in goal) or ("contour" in goal): 449 if self.verbose: print "!! WARNING !! No operation was made on contours and vectors. This can be debatted actually." 450 obj.field = obj_ref.field 388 451 else: 389 452 obj.field = obj_ref.field ** num … … 392 455 return the_clone 393 456 394 # define the operation << 395 # ... e.g. obj2 << obj1 396 # ... means: get init for pp object obj2 from another pp object obj1 397 # ... (this should solve the affectation trap obj2 = obj1) 398 def __lshift__(self,other): 399 if other.__class__.__name__ == "pp": 400 self.file = other.file 401 self.var = other.var 402 self.filegoal = other.filegoal 403 self.vargoal = other.vargoal 404 self.x = other.x ; self.y = other.y ## if None, free dimension 405 self.z = other.z ; self.t = other.t ## if None, free dimension 406 self.stridex = other.stridex ; self.stridey = other.stridey 407 self.stridez = other.stridez ; self.stridet = other.stridet 408 self.verbose = other.verbose 409 self.noproj = other.noproj 410 self.plotin = other.plotin 411 self.superpose = other.superpose 412 self.forcedimplot = other.forcedimplot 413 self.out = other.out 414 self.filename = other.filename 415 self.folder = other.folder 416 else: 417 print "!! ERROR !! argument must be a pp object." ; exit() 457 ### TBD: reverse power? for exponentials? 418 458 419 459 ############################################################################################## … … 505 545 # change status 506 546 self.status = "defined" 547 return self 507 548 508 549 ############################################################################################## … … 533 574 # change status 534 575 self.status = "retrieved" 576 return self 535 577 536 578 ########################################################## … … 540 582 self.define() 541 583 self.retrieve() 584 return self 542 585 543 586 ######################################## … … 643 686 plobj.ordi = obj.ordi # ordinate (or latitude) 644 687 # -- useless in 1D but not used anyway 688 # specific 1D plot stuff 689 if dp == 1: 690 # -- a default label 691 plobj.label = "" 692 if self.nfin > 1: plobj.label = plobj.label + " file #"+str(i+1) 693 if self.nvin > 1: plobj.label = plobj.label + " var #"+str(j+1) 694 if self.nplott > 1: plobj.label = plobj.label + " t #"+str(t+1) 695 if self.nplotz > 1: plobj.label = plobj.label + " z #"+str(z+1) 696 if self.nploty > 1: plobj.label = plobj.label + " y #"+str(y+1) 697 if self.nplotx > 1: plobj.label = plobj.label + " x #"+str(x+1) 698 # specific 2d plot stuff 645 699 if dp == 2: 646 # specific 2d plot stuff647 700 # -- light grey background for missing values 648 701 if type(plobj.field).__name__ in 'MaskedArray': plobj.axisbg = '0.75' … … 651 704 and "grid points" not in obj.name_x \ 652 705 and not self.noproj ) 653 # finally append 706 # possible user-defined plot settings shared by all plots 707 if self.div is not None: plobj.div = self.div 708 if self.xlabel is not None: plobj.xlabel = self.xlabel 709 if self.xcoeff is not None: plobj.xcoeff = self.xcoeff 710 if self.ylabel is not None: plobj.ylabel = self.ylabel 711 if self.ycoeff is not None: plobj.ycoeff = self.ycoeff 712 if self.title is not None: plobj.title = self.title 713 # -- 1D specific 714 if dp == 1: 715 if self.lstyle is not None: plobj.lstyle = self.lstyle 716 if self.marker is not None: plobj.marker = self.marker 717 if self.color is not None: plobj.color = self.color 718 if self.label is not None: plobj.label = self.label 719 # -- 2D specific 720 elif dp == 2: 721 if self.proj is not None and not self.noproj: plobj.proj = self.proj 722 if self.vmin is not None: plobj.vmin = self.vmin 723 if self.vmax is not None: plobj.vmax = self.vmax 724 if self.colorb is not None: plobj.colorb = self.colorb 725 # finally append plot object 654 726 self.p.append(plobj) 655 727 count = count + 1 … … 711 783 # final status 712 784 self.status = "definedplot" 785 return self 713 786 714 787 ############################################################################################## … … 780 853 # finally make the plot 781 854 pl.make() 782 self.n = self.n+1 855 # increment plot count (and propagate this in plotin) 856 self.n = self.n+1 857 if self.plotin is not None: self.plotin.n = self.n 783 858 # once completed show the plot (cannot show intermediate plotin) 784 859 # ... added a fix (customplot=True) for the label problem in basemap 785 print "**** Done step: makeplot"786 if (self.n == self.howmanyplots): 860 print "**** PPCLASS. Done step: makeplot" 861 if (self.n == self.howmanyplots): 787 862 ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=self.customplot) 788 863 mpl.close() … … 795 870 except IOError: 796 871 print "!! WARNING !! Saved object file not written. Probably do not have permission to write here." 872 return self 797 873 798 874 ########################################################### … … 802 878 self.defineplot(extraplot=extraplot) 803 879 self.makeplot() 880 return self 804 881 805 882 ####################################################### … … 809 886 self.get() 810 887 self.plot(extraplot=extraplot) 888 return self 811 889 812 890 ################################################################### … … 816 894 self.get() 817 895 self.defineplot(extraplot=extraplot) 896 return self 818 897 819 898 ############################################################## … … 907 986 except: 908 987 try: self.p[iii].marker = opt.marker[0] 988 except: pass 989 ### 990 try: self.p[iii].label = opt.label[iii] 991 except: 992 try: self.p[iii].label = opt.label[0] 909 993 except: pass 910 994 ### … … 1045 1129 if "grid points" not in self.name_x: 1046 1130 if self.field_x.all() == self.field_x[0,0]: 1047 print "!! WARNING !! xy axis look undefined. creating anon-dummy ones."1131 print "!! WARNING !! xy axis look undefined. creating non-dummy ones." 1048 1132 self.field_x = np.array(range(self.dim_x)) ; self.name_x = "x grid points" 1049 1133 self.field_y = np.array(range(self.dim_y)) ; self.name_y = "y grid points" … … 1330 1414 # ... this is done in the .area() method. 1331 1415 # after that self.field contains field*area/totarea 1332 if "area" in self.compute: self.area() 1416 if "area" in self.compute: 1417 if "comp" in self.method_x+self.method_y: 1418 self.area() 1419 else: 1420 if self.verbose: print "!! WARNING !! No area accounted for (computing on t and/or z axis)." 1333 1421 # now ready to compute [TBD: we would like to have e.g. mean over x,y and min over t ??] 1334 1422 if self.method_t == "comp": … … 1371 1459 print "**** OK. Final shape for "+self.var+" after averaging and squeezing",self.field.shape 1372 1460 1373 # get areas for computations and ponderate field by those areas1374 # ------------------------------------------------------------- 1461 # get areas for computations and ponderate self.field by area/totarea 1462 # ------------------------------------------------------------------- 1375 1463 def area(self): 1376 1464 if self.verbose: print "**** OK. Get area array for computations." … … 1398 1486 # read the 2D area array in netCDF file 1399 1487 aire.getfield() 1400 # normalize by total area1401 1488 aire.field = np.squeeze(aire.field) 1402 totarea = ppcompute.sum(ppcompute.sum(aire.field,axis=1),axis=0)1403 if self.verbose: print "**** OK. Total area is: ",totarea1404 aire.field = aire.field / totarea1405 1489 # reduce with self horizontal indexes 1406 1490 if "fixed" in self.method_x+self.method_y: 1407 1491 aire.field = aire.field[self.index_y,self.index_x] 1492 # calculate total area 1493 # ... 2D comp is easy. 1D comp is a bit less easy but simple array manipulation. 1494 if "free" in self.method_x+self.method_y: 1495 if self.method_x == "free": 1496 totarea = ppcompute.sum(aire.field,axis=0) 1497 totarea = np.reshape(totarea,(1,totarea.size)) 1498 totarea = np.tile(totarea,(1,self.index_x)) 1499 elif self.method_y == "free": 1500 totarea = ppcompute.sum(aire.field,axis=1) 1501 totarea = np.reshape(totarea,(totarea.size,1)) 1502 totarea = np.tile(totarea,(1,self.index_x.size)) 1503 elif self.method_x == "comp" and self.method_y == "comp": 1504 totarea = ppcompute.sum(ppcompute.sum(aire.field,axis=1),axis=0) 1505 else: 1506 if self.verbose: print "!! WARNING !! Not account for areas. Only averaging over z and/or t axis." 1507 # normalize by total area 1508 print "**** OK. I can now normalize field by areas." 1509 aire.field = aire.field / totarea 1408 1510 # tile area array over self t and z axis so that area field could be multiplied with self.field 1409 1511 aire.field = np.tile(aire.field,(self.index_t.size,self.index_z.size,1,1)) -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r920 r923 349 349 lstyle='-',\ 350 350 color='b',\ 351 marker='x'): 351 marker='x',\ 352 label=None): 352 353 ## get initialization from parent class 353 354 plot.__init__(self) … … 356 357 self.color = color 357 358 self.marker = marker 359 self.label = label 358 360 359 361 # define_from_var … … 389 391 # either request linestyle or let matplotlib decide 390 392 if self.lstyle is not None and self.color is not None: 391 mpl.plot(x,y,self.color+self.lstyle,marker=self.marker )393 mpl.plot(x,y,self.color+self.lstyle,marker=self.marker,label=self.label) 392 394 else: 393 mpl.plot(x,y,marker=self.marker )395 mpl.plot(x,y,marker=self.marker,label=self.label) 394 396 # make log axes and/or invert ordinate 395 397 # ... this must be after plot so that axis bounds are well-defined … … 398 400 if self.logy: mpl.semilogy() 399 401 if self.invert: ax = mpl.gca() ; ax.set_ylim(ax.get_ylim()[::-1]) 402 # add a label for line(s) 403 if self.label is not None: 404 if self.label != "": 405 mpl.legend(loc="best",fancybox=True) 400 406 ## TBD: set with .div the number of ticks 401 407 ## TBD: be able to control plot limits … … 556 562 wlat[0] = None ; wlat[1] = None ; wlon[0] = None ; wlon[1] = None 557 563 steplon = 30. ; steplat = 30. 558 if self.proj == "robin": steplon = 60.564 if self.proj in ["robin","moll"]: steplon = 60. 559 565 mertab = np.r_[-360.:360.:steplon] 560 566 partab = np.r_[-90.:90.:steplat] … … 642 648 scale=zescale*reducevec,width=widthvec ) 643 649 # make vector key. default is on upper left corner. 644 p = mpl.quiverkey(q,-0.03,1.08,\ 650 keyh = 1.025 ; keyv = 1.05 651 #keyh = -0.03 ; keyv = 1.08 652 p = mpl.quiverkey(q,keyh,keyv,\ 645 653 zescale,str(int(zescale)),\ 646 654 color='black',labelpos='S',labelsep = 0.07) 647 #### streamplot!!! avec basemap -
trunk/UTIL/PYTHON/planetoplot_v2/set_multiplot.txt
r917 r923 4 4 ############################################ 5 5 1 ; 1 ; 1 ; 0.0 ; 0.0 ; 22 6 2 ; 1 ; 2 ; 0. 35 ; 0.0 ; 206 2 ; 1 ; 2 ; 0.5 ; 0.0 ; 20 7 7 #3 ; 3 ; 1 ; 0.0 ; 1.0 ; 18 8 8 3 ; 1 ; 3 ; 0.35 ; 0.0 ; 18 9 4 ; 2 ; 2 ; 0. 8; 0.6 ; 189 4 ; 2 ; 2 ; 0.35 ; 0.6 ; 18 10 10 6 ; 3 ; 2 ; 0.6 ; 1.0 ; 18 11 11 8 ; 2 ; 4 ; 0.6 ; 0.6 ; 18
Note: See TracChangeset
for help on using the changeset viewer.