Changeset 2140 in lmdz_wrf for trunk


Ignore:
Timestamp:
Sep 14, 2018, 5:57:13 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `timemax': When a given variable [varname] got its maximum
Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r2138 r2140  
    6565# var_td_Uhus: Function to compute dew-point air temperature from temperature and
    6666#   pressure values using hus
     67# var_timemax: This function returns the time at which variable reaches its maximum in time
     68#   units
    6769# var_timeoverthres: This function returns the time at which (varv(t) > thres) in time units
    6870# var_virtualTemp: This function returns virtual temperature in K,
     
    696698
    697699    return convini, vardims, varvdims
     700
     701def var_timemax(varv, time, dimns, dimvns):
     702    """ This function returns the time at which variable reaches its maximum in time
     703        units
     704      varv: values of the variable to use
     705      time: time in CF coordinates
     706    """
     707    fname = 'var_timemax'
     708
     709    dt = varv.shape[0]
     710    dy = varv.shape[1]
     711    dx = varv.shape[2]
     712
     713    vardims = dimns[:]
     714    varvdims = dimvns[:]
     715
     716    vardims.pop(0)
     717    varvdims.pop(0)
     718
     719    timemax = np.ones((dy, dx), dtype=np.float)*gen.fillValueF
     720    varmax = np.max(varv, axis=0)
     721    for j in range(dy):
     722        for i in range(dx):
     723            it = gen.index_vec(varv[:,j,i], varmax[j,i])
     724            timemax[j,i] = time[it]
     725
     726    return timemax, vardims, varvdims
    698727
    699728def var_timeoverthres(varv, time, thres, dimns, dimvns):
  • trunk/tools/diagnostics.py

    r2138 r2140  
    799799        ncvar.insert_variable(ncobj, 'pr', diagout/dtime, diagoutd, diagoutvd, newnc)
    800800
     801# timemax ([varname], time). When a given variable [varname] got its maximum
     802    elif diagn == 'timemax':
     803           
     804        var0 = ncobj.variables[depvars[0]][:]
     805        var1 = ncobj.variables[depvars[1]][:]
     806
     807        otime = ncobj.variables[depvars[1]]
     808
     809        dnamesvar = ncobj.variables[depvars[0]].dimensions
     810        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
     811
     812        diagout, diagoutd, diagoutvd  = diag.var_timemax(var0, var1, dnames,         \
     813          dvnames)
     814
     815        ncvar.insert_variable(ncobj, 'timemax', diagout, diagoutd, diagoutvd, newnc, \
     816          fill=gen.fillValueF)
     817        # Getting the right units
     818        ovar = newnc.variables['timemax']
     819        if gen.searchInlist(otime.ncattrs(), 'units'):
     820            tunits = otime.getncattr('units')
     821            ncvar.set_attribute(ovar, 'units', tunits)
     822            newnc.sync()
     823        ncvar.set_attribute(ovar, 'variable', depvars[0])
     824
    801825# timeoverthres ([varname], time, [value], [CFvarn]). When a given variable [varname]   
    802826#   overpass a given [value]. Being [CFvarn] the name of the diagnostics in
  • trunk/tools/variables_values.dat

    r2138 r2140  
    501501th105, th105, thickness_1000_500, 0., 2500., atmosphere|thickness|1000|hPa|to|500|hPa, m, Reds, $m$, m
    5025021000 hPa to 500 hPa thickness, th105, thickness_1000_500, 0., 2500., atmosphere|thickness|1000|hPa|to|500|hPa, m, Reds, $m$, m
     503timemax, timemax, time_maximum, 0., 310000000., time|of|maximum, time, rainbow, $timemax$, timemax
    503504tke, tke, turbulent_kinetic_energy, 0., 0.003, turbulent|kinetic|energy, m2/s2, Reds, $tke$, tke
    504505TKE, tke, turbulent_kinetic_energy, 0., 0.003, turbulent|kinetic|energy, m2/s2, Reds, $tke$, tke
Note: See TracChangeset for help on using the changeset viewer.