Changeset 422
- Timestamp:
- Nov 24, 2011, 6:49:00 PM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/myplot.py
r418 r422 73 73 import numpy as np 74 74 from mymath import max,mean 75 csmooth = 12 ## a fair amount of grid points 75 csmooth = 12 ## a fair amount of grid points (too high results in high computation time) 76 76 dimension = np.array(input).ndim 77 77 shape = np.array(input).shape -
trunk/UTIL/PYTHON/myscript.py
r418 r422 56 56 57 57 ### OPERATIONS BETWEEN FILES 58 parser.add_option('--operation', action='store',dest='operat', type="string", default=None, help='operation to perform on input files given through -f. "+" or "-" acts on each input file by adding or substracting the ref file specified through --fref. "cat" acts on all input files in-a-row. ')58 parser.add_option('--operation', action='store',dest='operat', type="string", default=None, help='operation to perform on input files given through -f. "+" or "-" acts on each input file by adding or substracting the ref file specified through --fref. "cat" acts on all input files in-a-row. "add_var" "sub_var" "mul_var" "div_var" acts on two variables.') 59 59 parser.add_option('--fref', action='store',dest='fref', type="string", default=None, help='reference namefile for the --operation option.') 60 60 parser.add_option('--mope', action='store',dest='vminope', type="float", default=0., help='bounding minimum value for inter-file operation') -
trunk/UTIL/PYTHON/planetoplot.py
r419 r422 81 81 if not isinstance(namefiles, np.ndarray): namefiles = [namefiles] 82 82 if not isinstance(var, np.ndarray): var = [var] 83 if ope is not None and len(var) > 1: errormess("you are using an operation... please set only one var !")84 83 85 84 ################################ … … 97 96 print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", len(namefiles), nslices, len(var), numplot 98 97 print "********** MAPMODE: ", mapmode 99 if fileref is not None: all_var = [[]]*(zelen+2) ; all_varname = [[]]*(zelen+2) ; all_namefile = [[]]*(zelen+2) ; all_time = [[]]*(zelen+2) 100 else: all_var = [[]]*zelen ; all_var2 = [[]]*zelen ; all_title = [[]]*zelen ; all_varname = [[]]*zelen ; all_namefile = [[]]*zelen ; all_time = [[]]*zelen 98 if fileref is not None: zelen = zelen + 2 99 elif "var" in ope: zelen = zelen + 1 100 all_var = [[]]*zelen ; all_var2 = [[]]*zelen ; all_title = [[]]*zelen ; all_varname = [[]]*zelen ; all_namefile = [[]]*zelen ; all_time = [[]]*zelen 101 101 102 102 ################################################################################################# … … 194 194 ################################## 195 195 ### Operation on files 196 ### ... for the moment only OK when 1 var only197 196 if ope is not None: 198 print ope 197 print ope 198 if "var" not in ope: 199 if len(var) > 1: errormess("for this operation... please set only one var !") 199 200 if ope in ["-","+"]: 200 if fileref is not None: all_var[k] = getfield(Dataset(fileref),all_varname[k-1]) ; all_varname[k] = all_varname[k-1] 201 if fileref is not None: all_var[k] = getfield(Dataset(fileref),all_varname[k-1]) ; all_varname[k] = all_varname[k-1] ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] 201 202 else: errormess("fileref is missing!") 202 203 if ope == "-": all_var[k+1]= all_var[k-1] - all_var[k] 203 204 elif ope == "+": all_var[k+1]= all_var[k-1] + all_var[k] 204 all_varname[k+1] = all_varname[k] ; numplot = numplot+2205 all_varname[k+1] = all_varname[k] ; all_time[k+1] = all_time[k] ; all_namefile[k+1] = all_namefile[k] ; numplot = numplot+2 205 206 elif ope in ["cat"]: 206 207 tab = all_var[0];k = 1 207 208 while k != len(namefiles)-1: 208 209 tab = np.append(tab,all_var[k],axis=0) ; k += 1 209 time= np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better210 all_time[0] = np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better 210 211 all_var[0] = np.array(tab) ; numplot = 1 211 elif ope is not None: 212 errormess(ope+" : non-implemented operation. Available op. are + and -.") 212 else: errormess(ope+" : non-implemented operation. Check pp.py --help") 213 else: 214 if len(namefiles) > 1: errormess("for this operation... please set only one file !") 215 if len(var) > 2: errormess("not sure this works for more than 2 vars... please check.") 216 if ope in ["div_var"]: all_var[k] = all_var[k-2] / all_var[k-1] ; insert = '_div_' 217 elif ope in ["mul_var"]: all_var[k] = all_var[k-2] * all_var[k-1] ; insert = '_mul_' 218 elif ope in ["add_var"]: all_var[k] = all_var[k-2] + all_var[k-1] ; insert = '_add_' 219 elif ope in ["sub_var"]: all_var[k] = all_var[k-2] - all_var[k-1] ; insert = '_sub_' 220 else: errormess(ope+" : non-implemented operation. Check pp.py --help") 221 numplot = numplot + 1 ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] 222 all_varname[k] = all_varname[k-2] + insert + all_varname[k-1] 213 223 214 224 ################################## … … 225 235 while error is False: 226 236 print "********** nplot", nplot, "itime",itime,"error",error 227 228 # time = all_time[index_f] 229 237 230 238 ### Which local time ? 231 239 ltst = localtime ( interv[0]+itime*interv[1], 0.5*(wlon[0]+wlon[1]) ) … … 258 266 indexvert = getsindex(svert,((nplot-1)//(nlon*nlat))%nvert,vert) 259 267 260 if fileref is not None: index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(namefiles)+2) ## OK only 1 var, see test in the beginning 268 if fileref is not None: index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(namefiles)+2) ## OK only 1 var, see test in the beginning 269 elif "var" in ope: index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(var)+1) ## OK only 1 file, see test in the beginning 261 270 else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah 262 271 time = all_time[index_f] … … 268 277 indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 269 278 if typefile in ['mesoapi','meso'] and indextime is not None: ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 270 271 279 #################################################################### 272 280
Note: See TracChangeset
for help on using the changeset viewer.