Changeset 380
- Timestamp:
- Nov 14, 2011, 1:20:02 PM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/meso.py
r377 r380 44 44 vmaxtab = adjust_length (opt.vmax, zelen) 45 45 46 47 ################################ 48 ### General check 49 50 if opt.fref is not None: 51 if opt.operat is None: 52 print "you must specify an operation when using a reference file" 53 exit() 54 if opt.operat in ["+","-"]: 55 if opt.fref is None: 56 print "you must specifiy a reference file when using inter-file operations" 57 exit() 58 59 interpref=False 60 if opt.fref is not None: 61 if opt.operat is not None: 62 if opt.itp is not None: 63 interpref=True 64 65 ################################ 66 67 46 68 print "file, length", opt.file, len(opt.file) 47 69 … … 57 79 for i in range(len(opt.file)): 58 80 59 zefile = opt.file[i] 60 print zefile 81 zefiles = separatenames(opt.file[i]) 82 print "zefiles", zefiles 83 84 #zefile = opt.file[i] 85 #print zefile 86 zefile = zefiles[0] 87 61 88 #zelevel = opt.lvl 62 89 stralt = None … … 99 126 else: zerange = range(zelen) 100 127 128 129 130 131 132 133 134 135 if interpref: 136 interpolated_ref="" 137 interpolated_ref=call_zrecast(interp_mode=opt.itp,\ 138 input_name=[opt.fref],\ 139 fields=zevars) 140 141 reffile=interpolated_ref[0] 142 else: 143 reffile=opt.fref 144 # Divers #################################################### 145 101 146 zexaxis=[opt.xmin,opt.xmax] 102 147 zeyaxis=[opt.ymin,opt.ymax] … … 116 161 ############# 117 162 ### Main call 118 name = planetoplot (zefile ,level=int(zelevel),vertmode=opt.itp,\163 name = planetoplot (zefiles,level=int(zelevel),vertmode=opt.itp,\ 119 164 proj=opt.proj,back=opt.back,target=opt.tgt,stride=opt.ste,var=argvar,\ 120 165 numplot=opt.num,colorb=opt.clb,winds=opt.winds,\ … … 126 171 slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\ 127 172 outputname=opt.out,resolution=opt.res,\ 173 ope=opt.operat,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\ 128 174 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy) 129 175 print 'Done: '+name -
trunk/UTIL/PYTHON/myscript.py
r377 r380 2 2 3 3 ### I/O 4 parser.add_option('-f', '--file', action='append',dest='file', type="string", default=None, help='[NEEDED] filename (append). Comma-separated: same fig')4 parser.add_option('-f', '--file', action='append',dest='file', type="string", default=None, help='[NEEDED] filename. Append: different figures. Comma-separated: same figure (+ possible --operation). Regex tip: -f `echo foo* | sed s+" "+","+g`') 5 5 parser.add_option('-t', '--target', action='store',dest='tgt', type="string", default=None, help='destination folder') 6 6 parser.add_option('-S', '--save', action='store',dest='save', type="string", default="gui", help='save mode (png,eps,svg,pdf or gui) [gui]') … … 52 52 53 53 ### OPERATIONS BETWEEN FILES 54 parser.add_option('--operation', action='store',dest='operat', type="string", default=None, help='operation to perform between input file (ifile) and reference file (rfile) specified through --fref. Available: "+","-". Done as: ifile +or- rfile.')54 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.') 55 55 parser.add_option('--fref', action='store',dest='fref', type="string", default=None, help='reference namefile for the --operation option.') 56 56 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
r372 r380 161 161 basename = getname(var=var,winds=winds,anomaly=anomaly) 162 162 basename = basename + getstralt(nc,level) ## can be moved elsewhere for a more generic routine 163 163 164 164 print "var, var2: ", var, var2 165 165 if var: all_var[k] = getfield(nc,var) … … 173 173 174 174 ################################## 175 ### Load reference file if there is one 176 if fileref is not None: 177 ncref = Dataset(fileref) 178 ### ... VAR 175 ### Operation on files 176 if ope is not None: 179 177 if var not in nc.variables: var = False 180 178 if var: 181 all_var[k] = getfield(ncref,var) 182 if ope is "-": 183 all_var[k+1]= all_var[k-1] - all_var[k] 184 elif ope is "+": 185 all_var[k+1]= all_var[k-1] + all_var[k] 179 print ope 180 if ope in ["-","+"]: 181 if fileref is not None: all_var[k] = getfield(Dataset(fileref),var) 182 else: errormess("fileref is missing!") 183 if ope == "-": all_var[k+1]= all_var[k-1] - all_var[k] 184 elif ope == "+": all_var[k+1]= all_var[k-1] + all_var[k] 185 numplot = numplot+2 186 elif ope in ["cat"]: 187 tab = all_var[0];k = 0 188 while k != len(namefiles)-1: 189 tab = np.append(tab,all_var[k],axis=0) 190 k += 1 191 time = np.arange(0,len(tab),1) ### AS: time reference is simple, should be better 192 all_var[0] = np.array(tab);numplot = 1 186 193 elif ope is not None: 187 print "non-implemented operation. Available op. are + and -." 188 numplot = numplot+2 194 errormess(ope+" : non-implemented operation. Available op. are + and -.") 189 195 190 196 ################################## … … 195 201 ################################# 196 202 ### Time loop for plotting device 197 found_lct = False 198 nplot = 1 199 itime = first 200 error = False 203 found_lct = False;nplot = 1;itime = first;error = False 201 204 if itstep is None and numplot > 0: itstep = int(24./numplot) 202 205 elif numplot <= 0: itstep = 1
Note: See TracChangeset
for help on using the changeset viewer.