Changeset 2138 in lmdz_wrf
- Timestamp:
- Sep 13, 2018, 12:32:02 AM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r2100 r2138 65 65 # var_td_Uhus: Function to compute dew-point air temperature from temperature and 66 66 # pressure values using hus 67 # var_timeoverthres: This function returns the time at which (varv(t) > thres) in time units 67 68 # var_virtualTemp: This function returns virtual temperature in K, 68 69 # var_WRFtime: Function to copmute CFtimes from WRFtime variable … … 695 696 696 697 return convini, vardims, varvdims 698 699 def 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 697 726 698 727 def Forcompute_zint(var, zinterlev, zweights, dimns, dimvns): -
trunk/tools/diagnostics.py
r2100 r2138 47 47 # rotational_z: z-component of the rotatinoal of horizontal vectorial field 48 48 # 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 49 51 50 52 from optparse import OptionParser … … 86 88 availdiags = ['ACRAINTOT', 'accum', 'clt', 'cllmh', 'convini', 'deaccum', 'fog_K84', \ 87 89 'fog_RUC', 'LMDZrh', 'mslp', 'OMEGAw', 'RAINTOT', \ 88 'rvors', 'td', 't urbulence', 'uavaFROMwswd', 'WRFcape_afwa', 'WRFclivi',\89 'WRFcl wvi', 'WRF_denszint', 'WRFgeop',\90 'rvors', 'td', 'timeoverthres', 'turbulence', 'uavaFROMwswd', 'WRFcape_afwa', \ 91 'WRFclivi', 'WRFclwvi', 'WRF_denszint', 'WRFgeop', \ 90 92 'WRFmrso', 'WRFpotevap_orPM', 'WRFp', 'WRFpsl_ecmwf', \ 91 93 'WRFpsl_ptarget', 'WRFrvors', 'WRFslw', 'ws', 'wds', 'wss', 'WRFheight', \ … … 105 107 106 108 # diagnostics not to check their dependeny 107 NONcheckdepvars = ['accum', 'deaccum', ' WRF_denszint', 'WRFzwind_log', 'WRFzwind',\108 'WRFzwind MO']109 NONcheckdepvars = ['accum', 'deaccum', 'timeoverthres', 'WRF_denszint', \ 110 'WRFzwind_log', 'WRFzwind', 'WRFzwindMO'] 109 111 110 112 NONchkvardims = ['WRFtime'] … … 797 799 ncvar.insert_variable(ncobj, 'pr', diagout/dtime, diagoutd, diagoutvd, newnc) 798 800 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 799 829 # rhs (psfc, t, q) from TimeSeries files 800 830 elif diagn == 'TSrhs': -
trunk/tools/variables_values.dat
r2126 r2138 491 491 tair, tas, air_temperature, 240., 310., air|temperature|at|2m, K, YlOrRd, $tas$, tas 492 492 Temperature 2m, tas, air_temperature, 240., 310., air|temperature|at|2m, K, YlOrRd, $tas$, tas 493 tastimeoverthres, tastimeoverthres, air_temperature, 240., 310., time|air|temperature|overpass|a|given|threshold, time, rainbow, $tastimeoverthres$, tastimeoverthres 493 494 tda, tda, air_dew_point_temperature, 240., 310., air|dew|point|temperature, K, YlGnBu, $tda$, tda 494 495 DWPT, 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.