Changeset 1694 in lmdz_wrf


Ignore:
Timestamp:
Dec 7, 2017, 8:09:46 PM (7 years ago)
Author:
lfita
Message:

Removing WRF-related actions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/get_stations.py

    r1692 r1694  
    2121
    2222# Gneric variables prepared to be computed
    23 Cvars = ['C_td']
     23Cvars = ['C_td', 'C_wd', 'C_ws']
    2424
    2525# WRF specific diagnostics
     
    2828
    2929# Variables not to check their existence inside file
    30 NONcheckingvars = Cvars + WRFvars
     30NONcheckingvars = Cvars + WRFvars + ['None']
    3131
    3232def creation_sfcstation_file(filen, lv, Lv, hv, lab, tunits, sfcvars, dimt, ifilen):
     
    362362        quit(-1)
    363363
    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
    380372        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)]
    385386
    386387    if dimn == Pressdimref: dz = len(onc.dimensions[dimn])
     388
     389# Looking for 2D 'lon', 'lat' related variables
     390Xvarvals = dimvarvalues[dimvariables['lon']]
     391Yvarvals = dimvarvalues[dimvariables['lat']]
     392if len(Xvarvals.shape) == 1:
     393    newXvarvals, newYvarvals = np.meshgrid(Xvarvals, Yvarvals)
     394    dimvarvalues[dimvariables['lon']] = newXvarvals
     395    dimvarvalues[dimvariables['lat']] = newYvarvals
    387396
    388397# Retrieving surface data
     
    427436            getdims = ogetvar.dimensions
    428437        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]]]
    431441
    432442        # Looking for the X,Y axis for location of station within file
     
    566576            getdims = ogetvar.dimensions
    567577        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]]]
    570581
    571582        # Looking for the X,Y axis for location of station within file
     
    613624       
    614625        # Writting information to file
    615         if sfcv == sfcrefvar:
     626        if sndv == sndrefvar:
    616627            ojvar = onewnc.variables['jpoint']
    617628            ojvar[:] = minji[0]
    618629            ojvar = onewnc.variables['ipoint']
    619630            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]]
    622634            onewnc.sync()
    623635
     
    655667        # Writting data and slicing
    656668        onewvar = onewnc.variables[sndv]
     669        print 'Lluis sndv:', sndv, ' shapes onewvar:', onewvar.shape, 'slice:', slicevar
    657670        onewvar[:] = ogetvar[tuple(slicevar)]   
    658671        onewnc.sync()
Note: See TracChangeset for help on using the changeset viewer.