Changeset 2138 in lmdz_wrf


Ignore:
Timestamp:
Sep 13, 2018, 12:32:02 AM (7 years ago)
Author:
lfita
Message:

Adding timeoverthres' and tastimeoverthres' as variable to refer

Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r2100 r2138  
    6565# var_td_Uhus: Function to compute dew-point air temperature from temperature and
    6666#   pressure values using hus
     67# var_timeoverthres: This function returns the time at which (varv(t) > thres) in time units
    6768# var_virtualTemp: This function returns virtual temperature in K,
    6869# var_WRFtime: Function to copmute CFtimes from WRFtime variable
     
    695696
    696697    return convini, vardims, varvdims
     698
     699def var_timeoverthres(varv, time, thres, dimns, dimvns):
     700    """ This function returns the time at which (varv(t) > thres) in time units
     701      varv: values of the variable to use
     702      time: time in CF coordinates
     703      thres: threshold to overpass
     704    """
     705    fname = 'var_timeoverthres'
     706
     707    dt = varv.shape[0]
     708    dy = varv.shape[1]
     709    dx = varv.shape[2]
     710
     711    vardims = dimns[:]
     712    varvdims = dimvns[:]
     713
     714    vardims.pop(0)
     715    varvdims.pop(0)
     716
     717    timeoverthres = np.ones((dy, dx), dtype=np.float)*gen.fillValueF
     718    for it in range(dt):
     719        for j in range(dy):
     720            for i in range(dx):
     721                if timeoverthres[j,i] == gen.fillValueF and varv[it,j,i] >= thres:
     722                    timeoverthres[j,i] = time[it]
     723                    break
     724
     725    return timeoverthres, vardims, varvdims
    697726
    698727def Forcompute_zint(var, zinterlev, zweights, dimns, dimvns):
  • trunk/tools/diagnostics.py

    r2100 r2138  
    4747# rotational_z: z-component of the rotatinoal of horizontal vectorial field
    4848# turbulence_var: Function to compute the Taylor's decomposition turbulence term from a a given variable
     49# timeoverthres: When a given variable [varname] overpass a given [value]. Being [CFvarn] the name of the diagnostics in
     50#   variables_values.dat
    4951
    5052from optparse import OptionParser
     
    8688availdiags = ['ACRAINTOT', 'accum', 'clt', 'cllmh', 'convini', 'deaccum', 'fog_K84', \
    8789  'fog_RUC', 'LMDZrh', 'mslp', 'OMEGAw', 'RAINTOT',                                  \
    88   'rvors', 'td', 'turbulence', 'uavaFROMwswd', 'WRFcape_afwa', 'WRFclivi',           \
    89   'WRFclwvi', 'WRF_denszint', 'WRFgeop',                                             \
     90  'rvors', 'td', 'timeoverthres', 'turbulence', 'uavaFROMwswd', 'WRFcape_afwa',      \
     91  'WRFclivi', 'WRFclwvi', 'WRF_denszint', 'WRFgeop',                                 \
    9092  'WRFmrso', 'WRFpotevap_orPM', 'WRFp', 'WRFpsl_ecmwf',                              \
    9193  'WRFpsl_ptarget', 'WRFrvors', 'WRFslw', 'ws', 'wds', 'wss', 'WRFheight',           \
     
    105107
    106108# diagnostics not to check their dependeny
    107 NONcheckdepvars = ['accum', 'deaccum', 'WRF_denszint', 'WRFzwind_log', 'WRFzwind',   \
    108   'WRFzwindMO']
     109NONcheckdepvars = ['accum', 'deaccum', 'timeoverthres', 'WRF_denszint',              \
     110  'WRFzwind_log', 'WRFzwind', 'WRFzwindMO']
    109111
    110112NONchkvardims = ['WRFtime']
     
    797799        ncvar.insert_variable(ncobj, 'pr', diagout/dtime, diagoutd, diagoutvd, newnc)
    798800
     801# timeoverthres ([varname], time, [value], [CFvarn]). When a given variable [varname]   
     802#   overpass a given [value]. Being [CFvarn] the name of the diagnostics in
     803#   variables_values.dat
     804    elif diagn == 'timeoverthres':
     805           
     806        var0 = ncobj.variables[depvars[0]][:]
     807        var1 = ncobj.variables[depvars[1]][:]
     808        var2 = np.float(depvars[2])
     809        var3 = depvars[3]
     810
     811        otime = ncobj.variables[depvars[1]]
     812
     813        dnamesvar = ncobj.variables[depvars[0]].dimensions
     814        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
     815
     816        diagout, diagoutd, diagoutvd  = diag.var_timeoverthres(var0, var1, var2,     \
     817          dnames, dvnames)
     818
     819        ncvar.insert_variable(ncobj, var3, diagout, diagoutd, diagoutvd, newnc, \
     820          fill=gen.fillValueF)
     821        # Getting the right units
     822        ovar = newnc.variables[var3]
     823        if gen.searchInlist(otime.ncattrs(), 'units'):
     824            tunits = otime.getncattr('units')
     825            ncvar.set_attribute(ovar, 'units', tunits)
     826            newnc.sync()
     827        ncvar.set_attribute(ovar, 'overpassed_threshold', var2)
     828
    799829# rhs (psfc, t, q) from TimeSeries files
    800830    elif diagn == 'TSrhs':
  • trunk/tools/variables_values.dat

    r2126 r2138  
    491491tair, tas, air_temperature, 240., 310., air|temperature|at|2m, K, YlOrRd, $tas$, tas
    492492Temperature 2m, tas, air_temperature, 240., 310., air|temperature|at|2m, K, YlOrRd, $tas$, tas
     493tastimeoverthres, tastimeoverthres, air_temperature, 240., 310., time|air|temperature|overpass|a|given|threshold, time, rainbow, $tastimeoverthres$, tastimeoverthres
    493494tda, tda, air_dew_point_temperature, 240., 310., air|dew|point|temperature, K, YlGnBu, $tda$, tda
    494495DWPT, tda, air_dew_point_temperature, 240., 310., air|dew|point|temperature, K, YlGnBu, $tda$, tda
Note: See TracChangeset for help on using the changeset viewer.