Index: /trunk/tools/diag_tools.py
===================================================================
--- /trunk/tools/diag_tools.py	(revision 2137)
+++ /trunk/tools/diag_tools.py	(revision 2138)
@@ -65,4 +65,5 @@
 # var_td_Uhus: Function to compute dew-point air temperature from temperature and 
 #   pressure values using hus
+# var_timeoverthres: This function returns the time at which (varv(t) > thres) in time units
 # var_virtualTemp: This function returns virtual temperature in K, 
 # var_WRFtime: Function to copmute CFtimes from WRFtime variable
@@ -695,4 +696,32 @@
 
     return convini, vardims, varvdims
+
+def var_timeoverthres(varv, time, thres, dimns, dimvns):
+    """ This function returns the time at which (varv(t) > thres) in time units
+      varv: values of the variable to use
+      time: time in CF coordinates
+      thres: threshold to overpass
+    """
+    fname = 'var_timeoverthres'
+
+    dt = varv.shape[0]
+    dy = varv.shape[1]
+    dx = varv.shape[2]
+
+    vardims = dimns[:]
+    varvdims = dimvns[:]
+
+    vardims.pop(0)
+    varvdims.pop(0)
+
+    timeoverthres = np.ones((dy, dx), dtype=np.float)*gen.fillValueF
+    for it in range(dt):
+        for j in range(dy):
+            for i in range(dx):
+                if timeoverthres[j,i] == gen.fillValueF and varv[it,j,i] >= thres:
+                    timeoverthres[j,i] = time[it]
+                    break
+
+    return timeoverthres, vardims, varvdims
 
 def Forcompute_zint(var, zinterlev, zweights, dimns, dimvns):
Index: /trunk/tools/diagnostics.py
===================================================================
--- /trunk/tools/diagnostics.py	(revision 2137)
+++ /trunk/tools/diagnostics.py	(revision 2138)
@@ -47,4 +47,6 @@
 # rotational_z: z-component of the rotatinoal of horizontal vectorial field
 # turbulence_var: Function to compute the Taylor's decomposition turbulence term from a a given variable
+# timeoverthres: When a given variable [varname] overpass a given [value]. Being [CFvarn] the name of the diagnostics in 
+#   variables_values.dat
 
 from optparse import OptionParser
@@ -86,6 +88,6 @@
 availdiags = ['ACRAINTOT', 'accum', 'clt', 'cllmh', 'convini', 'deaccum', 'fog_K84', \
   'fog_RUC', 'LMDZrh', 'mslp', 'OMEGAw', 'RAINTOT',                                  \
-  'rvors', 'td', 'turbulence', 'uavaFROMwswd', 'WRFcape_afwa', 'WRFclivi',           \
-  'WRFclwvi', 'WRF_denszint', 'WRFgeop',                                             \
+  'rvors', 'td', 'timeoverthres', 'turbulence', 'uavaFROMwswd', 'WRFcape_afwa',      \
+  'WRFclivi', 'WRFclwvi', 'WRF_denszint', 'WRFgeop',                                 \
   'WRFmrso', 'WRFpotevap_orPM', 'WRFp', 'WRFpsl_ecmwf',                              \
   'WRFpsl_ptarget', 'WRFrvors', 'WRFslw', 'ws', 'wds', 'wss', 'WRFheight',           \
@@ -105,6 +107,6 @@
 
 # diagnostics not to check their dependeny
-NONcheckdepvars = ['accum', 'deaccum', 'WRF_denszint', 'WRFzwind_log', 'WRFzwind',   \
-  'WRFzwindMO']
+NONcheckdepvars = ['accum', 'deaccum', 'timeoverthres', 'WRF_denszint',              \
+  'WRFzwind_log', 'WRFzwind', 'WRFzwindMO']
 
 NONchkvardims = ['WRFtime']
@@ -797,4 +799,32 @@
         ncvar.insert_variable(ncobj, 'pr', diagout/dtime, diagoutd, diagoutvd, newnc)
 
+# timeoverthres ([varname], time, [value], [CFvarn]). When a given variable [varname]    
+#   overpass a given [value]. Being [CFvarn] the name of the diagnostics in 
+#   variables_values.dat
+    elif diagn == 'timeoverthres':
+            
+        var0 = ncobj.variables[depvars[0]][:]
+        var1 = ncobj.variables[depvars[1]][:]
+        var2 = np.float(depvars[2])
+        var3 = depvars[3]
+
+        otime = ncobj.variables[depvars[1]]
+
+        dnamesvar = ncobj.variables[depvars[0]].dimensions
+        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
+
+        diagout, diagoutd, diagoutvd  = diag.var_timeoverthres(var0, var1, var2,     \
+          dnames, dvnames)
+
+        ncvar.insert_variable(ncobj, var3, diagout, diagoutd, diagoutvd, newnc, \
+          fill=gen.fillValueF)
+        # Getting the right units
+        ovar = newnc.variables[var3]
+        if gen.searchInlist(otime.ncattrs(), 'units'): 
+            tunits = otime.getncattr('units')
+            ncvar.set_attribute(ovar, 'units', tunits)
+            newnc.sync()
+        ncvar.set_attribute(ovar, 'overpassed_threshold', var2)
+
 # rhs (psfc, t, q) from TimeSeries files
     elif diagn == 'TSrhs':
Index: /trunk/tools/variables_values.dat
===================================================================
--- /trunk/tools/variables_values.dat	(revision 2137)
+++ /trunk/tools/variables_values.dat	(revision 2138)
@@ -491,4 +491,5 @@
 tair, tas, air_temperature, 240., 310., air|temperature|at|2m, K, YlOrRd, $tas$, tas
 Temperature 2m, tas, air_temperature, 240., 310., air|temperature|at|2m, K, YlOrRd, $tas$, tas
+tastimeoverthres, tastimeoverthres, air_temperature, 240., 310., time|air|temperature|overpass|a|given|threshold, time, rainbow, $tastimeoverthres$, tastimeoverthres
 tda, tda, air_dew_point_temperature, 240., 310., air|dew|point|temperature, K, YlGnBu, $tda$, tda
 DWPT, tda, air_dew_point_temperature, 240., 310., air|dew|point|temperature, K, YlGnBu, $tda$, tda
