Changeset 442 in lmdz_wrf


Ignore:
Timestamp:
May 28, 2015, 1:20:19 PM (10 years ago)
Author:
lfita
Message:

Adding WRFtime' on RAINTOT' calculation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diagnostics.py

    r413 r442  
    1212import re
    1313import nc_var_tools as ncvar
     14import datetime as dt
    1415
    1516main = 'diagnostics.py'
     
    979980
    980981# Transforming to a flux
    981         dtimeunits = var2.getncattr('units')
    982         tunits = dtimeunits.split(' ')[0]
    983 
    984         dtime = (var2[1] - var2[0])*timeunits_seconds(tunits)
     982        if depvarsp[2] != 'WRFtime':
     983            dtimeunits = var2.getncattr('units')
     984            tunits = dtimeunits.split(' ')[0]
     985
     986            dtime = (var2[1] - var2[0])*timeunits_seconds(tunits)
     987        else:
     988            time1 = var2[0,:]
     989            time2 = var2[1,:]
     990            dtdate1 = dt.datetime.strptime(time1,"%Y-%m-%d_%H:%M:%S")
     991            dtdate2 = dt.datetime.strptime(time2,"%Y-%m-%d_%H:%M:%S")
     992            diffdate12 = ddate2 - ddate1
     993            dtime = diffdate12.total_seconds()
     994
    985995        ncvar.insert_variable(ncobj, 'pr', diagout/dtime, diagoutd, diagoutvd, newnc)
    986996
Note: See TracChangeset for help on using the changeset viewer.