Changeset 1694 in lmdz_wrf
- Timestamp:
- Dec 7, 2017, 8:09:46 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/get_stations.py
r1692 r1694 21 21 22 22 # Gneric variables prepared to be computed 23 Cvars = ['C_td' ]23 Cvars = ['C_td', 'C_wd', 'C_ws'] 24 24 25 25 # WRF specific diagnostics … … 28 28 29 29 # Variables not to check their existence inside file 30 NONcheckingvars = Cvars + WRFvars 30 NONcheckingvars = Cvars + WRFvars + ['None'] 31 31 32 32 def creation_sfcstation_file(filen, lv, Lv, hv, lab, tunits, sfcvars, dimt, ifilen): … … 362 362 quit(-1) 363 363 364 # Except for temporal variables, we don't want dimensions with time-axis 365 # (assuming fixed) 366 if varn == 'WRFtime': 367 varvalues, CFtu= ncvar.compute_WRFtime(onc.variables['Times'], ReferenceDate,\ 368 UnitsTime) 369 dt = varvalues.shape[0] 370 dimvarvalues[varn] = varvalues 371 else: 372 ovar = onc.variables[varn] 373 slicevar = {} 374 if not gen.searchInlist(axesvars['T'], varn): 375 for dn in ovar.dimensions: 376 if not gen.searchInlist(axesdims['T'], dn): 377 slicevar[dn] = -1 378 else: 379 slicevar[dn] = 0 364 if not gen.searchInlist(NONcheckingvars, varn): 365 # Except for temporal variables, we don't want dimensions with time-axis 366 # (assuming fixed) 367 if varn == 'WRFtime': 368 varvalues, CFtu = ncvar.compute_WRFtime(onc.variables['Times'], \ 369 ReferenceDate, UnitsTime) 370 dt = varvalues.shape[0] 371 dimvarvalues[varn] = varvalues 380 372 else: 381 slicevar[dn] = -1 382 dt = len(onc.dimensions[dn]) 383 slicevar, vardims = ncvar.SliceVarDict(ovar, slicevar) 384 dimvarvalues[varn] = ovar[tuple(slicevar)] 373 ovar = onc.variables[varn] 374 slicevar = {} 375 if not gen.searchInlist(axesvars['T'], varn): 376 for dn in ovar.dimensions: 377 if not gen.searchInlist(axesdims['T'], dn): 378 slicevar[dn] = -1 379 else: 380 slicevar[dn] = 0 381 else: 382 slicevar[dn] = -1 383 dt = len(onc.dimensions[dn]) 384 slicevar, vardims = ncvar.SliceVarDict(ovar, slicevar) 385 dimvarvalues[varn] = ovar[tuple(slicevar)] 385 386 386 387 if dimn == Pressdimref: dz = len(onc.dimensions[dimn]) 388 389 # Looking for 2D 'lon', 'lat' related variables 390 Xvarvals = dimvarvalues[dimvariables['lon']] 391 Yvarvals = dimvarvalues[dimvariables['lat']] 392 if len(Xvarvals.shape) == 1: 393 newXvarvals, newYvarvals = np.meshgrid(Xvarvals, Yvarvals) 394 dimvarvalues[dimvariables['lon']] = newXvarvals 395 dimvarvalues[dimvariables['lat']] = newYvarvals 387 396 388 397 # Retrieving surface data … … 427 436 getdims = ogetvar.dimensions 428 437 else: 429 getdims = ['Time', 'south_north', 'west_east'] 430 getvdims = ['WRFtime', 'XLAT', 'XLONG'] 438 getdims = list(onc.variables[sfcrefvar].dimensions) 439 getvdims = [dimvariables[getdims[0]], dimvariables[getdims[1]], \ 440 dimvariables[getdims[2]]] 431 441 432 442 # Looking for the X,Y axis for location of station within file … … 566 576 getdims = ogetvar.dimensions 567 577 else: 568 getdims = ['Time', 'bottom_top', 'south_north', 'west_east'] 569 getvdims = ['WRFtime', 'WRFp', 'XLAT', 'XLONG'] 578 getdims = list(onc.variables[sndrefvar].dimensions) 579 getvdims = [dimvariables[getdims[0]], dimvariables[getdims[1]], \ 580 dimvariables[getdims[2]], dimvariables[getdims[3]]] 570 581 571 582 # Looking for the X,Y axis for location of station within file … … 613 624 614 625 # Writting information to file 615 if s fcv == sfcrefvar:626 if sndv == sndrefvar: 616 627 ojvar = onewnc.variables['jpoint'] 617 628 ojvar[:] = minji[0] 618 629 ojvar = onewnc.variables['ipoint'] 619 630 ojvar[:] = minji[1] 620 ohvar = onewnc.variables['fheight'] 621 ohvar[:] = dimvarvalues[dimvariables['H']][minji[0],minji[1]] 631 if dimvariables['H'] != 'None': 632 ohvar = onewnc.variables['fheight'] 633 ohvar[:] = dimvarvalues[dimvariables['H']][minji[0],minji[1]] 622 634 onewnc.sync() 623 635 … … 655 667 # Writting data and slicing 656 668 onewvar = onewnc.variables[sndv] 669 print 'Lluis sndv:', sndv, ' shapes onewvar:', onewvar.shape, 'slice:', slicevar 657 670 onewvar[:] = ogetvar[tuple(slicevar)] 658 671 onewnc.sync()
Note: See TracChangeset
for help on using the changeset viewer.