Changeset 587 in lmdz_wrf
- Timestamp:
- Jul 8, 2015, 7:06:26 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/create_OBSnetcdf.py
r553 r587 122 122 varTYPE='|' list of variable types ('D', 'F', 'I', 'I64', 'S') 123 123 varOPER='|' list of operations to do to the variables to meet their units ([oper],[val]) 124 [oper]=-,sumc,subc,mulc,divc (nothing, add, rest, multiply and divide) 125 124 [oper]: 125 -, nothing 126 sumc, add [val] 127 subc, rest [val] 128 mulc, multiply by [val] 129 divc, divide by [val] 130 rmchar,[val],[pos], remove [val] characters from [pos]='B', beginning, 'E', end 126 131 NAMElon=name of the variable with the longitude (x position) 127 132 NAMElat=name of the variable with the latitude (y position) … … 202 207 fname = 'value_fmt' 203 208 204 aopers = ['sumc','subc','mulc','divc' ]209 aopers = ['sumc','subc','mulc','divc', 'rmchar'] 205 210 206 211 fmts = ['D', 'F', 'I', 'I64', 'S'] … … 211 216 newval = None 212 217 else: 213 print 'op: ',op218 print 'op: **' + op + '**' 214 219 if op != '-': 215 220 opern = op.split(',')[0] 216 operv = np.float(op.split(',')[1])221 operv = op.split(',')[1] 217 222 218 223 if not searchInlist(aopers,opern): … … 223 228 else: 224 229 opern = 'sumc' 225 operv = 0.230 operv = '0.' 226 231 227 232 if not searchInlist(fmts, fmt): … … 236 241 elif opern == 'mulc': newval = np.float32(val) * opv 237 242 elif opern == 'divc': newval = np.float32(val) / opv 243 elif opern == 'rmchar': 244 opv = int(operv) 245 Lval = len(val) 246 if op.split(',')[2] == 'B': 247 newval = np.float32(val[opv:Lval+1]) 248 elif op.split(',')[2] == 'E': 249 newval = np.float32(val[Lval-opv:Lval]) 250 else: 251 print errormsg 252 print ' ' + fname + ": operation '" + opern + "' not " +\ 253 " work with '" + op.split(',')[2] + "' !!" 254 quit(-1) 238 255 elif fmt == 'F': 239 256 opv = np.float(operv) … … 242 259 elif opern == 'mulc': newval = np.float(val) * opv 243 260 elif opern == 'divc': newval = np.float(val) / opv 261 elif opern == 'rmchar': 262 opv = int(operv) 263 Lval = len(val) 264 if op.split(',')[2] == 'B': 265 newval = np.float(val[opv:Lval+1]) 266 elif op.split(',')[2] == 'E': 267 newval = np.float(val[0:Lval-opv]) 268 else: 269 print errormsg 270 print ' ' + fname + ": operation '" + opern + "' not " +\ 271 " work with '" + op.split(',')[2] + "' !!" 272 quit(-1) 273 244 274 elif fmt == 'I': 245 275 opv = int(operv) … … 248 278 elif opern == 'mulc': newval = int(val) * opv 249 279 elif opern == 'divc': newval = int(val) / opv 280 elif opern == 'rmchar': 281 opv = int(operv) 282 Lval = len(val) 283 if op.split(',')[2] == 'B': 284 newval = int(val[opv:Lval+1]) 285 elif op.split(',')[2] == 'E': 286 newval = int(val[0:Lval-opv]) 287 else: 288 print errormsg 289 print ' ' + fname + ": operation '" + opern + "' not " +\ 290 " work with '" + op.split(',')[2] + "' !!" 291 quit(-1) 250 292 elif fmt == 'I64': 251 293 opv = np.int64(operv) … … 254 296 elif opern == 'mulc': newval = np.int64(val) * opv 255 297 elif opern == 'divc': newval = np.int64(val) / opv 298 elif opern == 'rmchar': 299 opv = int(operv) 300 Lval = len(val) 301 if op.split(',')[2] == 'B': 302 newval = np.int64(val[opv:Lval+1]) 303 elif op.split(',')[2] == 'E': 304 newval = np.int64(val[0:Lval-opv]) 305 else: 306 print errormsg 307 print ' ' + fname + ": operation '" + opern + "' not " +\ 308 " work with '" + op.split(',')[2] + "' !!" 309 quit(-1) 256 310 elif fmt == 'S': 257 newval = val 311 if opern == 'rmchar': 312 opv = int(operv) 313 Lval = len(val) 314 if op.split(',')[2] == 'B': 315 newval = val[opv:Lval+1] 316 elif op.split(',')[2] == 'E': 317 newval = val[0:Lval-opv] 318 else: 319 print errormsg 320 print ' ' + fname + ": operation '" + opern + "' not " +\ 321 " work with '" + op.split(',')[2] + "' !!" 322 quit(-1) 323 else: 324 newval = val 325 258 326 else: 259 327 newval = None … … 886 954 print ' excess of formats for:', formats[Nshow:len(formats)+1] 887 955 888 quit(-1)956 # quit(-1) 889 957 890 958 # Reading values
Note: See TracChangeset
for help on using the changeset viewer.