Changeset 990
- Timestamp:
- Jun 14, 2013, 9:52:31 AM (12 years ago)
- Location:
- trunk/UTIL/PYTHON/planetoplot_v2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot_v2/pp.py
r982 r990 55 55 parser.add_option('-s','--changetime',action='store',dest='changetime',type="string",default=None,\ 56 56 help="transformation on time axis : [None] | mars_sol2ls | mars_meso_ls | mars_meso_sol | mars_meso_utc | mars_meso_lt ") 57 parser.add_option('-p','--print',action='store_true',dest='savtxt',default=False,help="[1D] output field+coord in an ASCII file") 57 58 parser.add_option('--stridex',action='store',dest='stridex',type="int",default=1,help="Load data every stridex grid points over x dimension") 58 59 parser.add_option('--stridey',action='store',dest='stridey',type="int",default=1,help="Load data every stridex grid points over y dimension") … … 138 139 user.stridevecx = opt.stridevecx 139 140 user.stridevecy = opt.stridevecy 141 user.savtxt = opt.savtxt 140 142 # define field 141 143 user.define() -
trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
r984 r990 161 161 changetime=None,\ 162 162 units=None,\ 163 savtxt=False,\ 163 164 title=None): 164 165 self.request = None … … 199 200 self.includedate = includedate 200 201 self.changetime = changetime 202 self.savtxt = savtxt 201 203 ## here are user-defined plot settings 202 204 ## -- if not None, valid on all plots in the pp() objects … … 262 264 self.includedate = other.includedate 263 265 self.changetime = other.changetime 266 self.savtxt = other.savtxt 264 267 else: 265 268 print "!! ERROR !! argument must be a pp object." ; exit() … … 943 946 # finally make the plot 944 947 pl.make() 948 # possibly print results in a text file 949 if self.savtxt: 950 if self.verbose: print "**** Printing results in a text file" 951 name = pl.var + "%04d" % self.n 952 ppplot.writeascii(field=pl.field,absc=pl.absc,name=name) 945 953 # increment plot count (and propagate this in plotin) 946 954 self.n = self.n+1 … … 1299 1307 self.name_z = "z grid points" 1300 1308 else: 1301 self.field_z = self.f.variables[self.name_z][:] # specify dimension 1302 # TBD: have to check that this is not a 3D field 1309 tabalt = self.f.variables[self.name_z] 1310 # (consider the case where tabtime is not dim 1) TBD: 2D and 3D cases 1311 if tabalt.ndim == 4: 1312 try: 1313 self.field_z = tabalt[1,:,0,0] # 4D case. alt is usually third dimension. 1314 # 1 for time to avoid initial 0s 1315 except: 1316 self.field_z = tabalt[0,:,0,0] 1317 if self.verbose: print "!! WARNING !! "+self.name_z+" is 4D var. We made it 1D." 1318 else: 1319 self.field_z = self.f.variables[self.name_z][:] # specify dimension 1303 1320 if self.dim_z > 1: 1304 1321 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()) -
trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
r982 r990 247 247 what_I_plot[ what_I_plot > zevmax ] = zevmax*(1.-small_enough) 248 248 return what_I_plot 249 250 # a function to output an ascii file 251 # ---------------------------------- 252 def writeascii (field=None,absc=None,name=None): 253 if name is None: 254 name = "prof" 255 for ttt in timelib.gmtime(): 256 name = name + "_" + str(ttt) 257 if field is None or absc is None: 258 print "!! WARNING !! Not printing the file, incorrect field or absc." 259 else: 260 if field.ndim == 1: 261 myfile = open(name, 'w') 262 for ix in range(len(absc)): 263 myfile.write("%15.5e%15.5e\n" % ( absc[ix], field[ix] )) 264 myfile.close() 265 else: 266 print "!! WARNING !! Not printing the file, 2D fields not supported yet." 267 # mydata = np.transpose([absc,np.transpose(field)]) #tab 268 # for line in mydata: 269 # zeline = str(line) 270 # zeline = zeline.replace('[','') 271 # zeline = zeline.replace(']','') 272 # myfile.write(zeline + '\n') 273 return 249 274 250 275 # a generic function to show (GUI) or save a plot (PNG,EPS,PDF,...) -
trunk/UTIL/PYTHON/planetoplot_v2/set_ppclass.txt
r981 r990 10 10 # z-axis: possible names to search for. add in the line with a separating ; 11 11 # 12 altitude;Alt;vert;presnivs;bottom_top;altitude_abg;lev 12 altitude;Alt;vert;presnivs;bottom_top;altitude_abg;lev;PTOT 13 13 # t-axis: possible names to search for. add in the line with a separating ; 14 14 # -
trunk/UTIL/PYTHON/planetoplot_v2/set_var.txt
r943 r990 13 13 VM ; %.1f ; jet ; Meridional wind ; m s$^{-1}$ 14 14 W ; %.2f ; jet ; Vertical wind ; m s$^{-1}$ 15 U025 ; %.1f ; jet ; Wind speed 25cm above the surface ; m s$^{-1}$ 15 16 WIND ; %.0f ; YlOrRd ; Wind speed ; m s$^{-1}$ 16 17 UV ; %.0f ; YlOrRd ; Wind speed ; m s$^{-1}$
Note: See TracChangeset
for help on using the changeset viewer.