Changeset 1673 in lmdz_wrf


Ignore:
Timestamp:
Dec 4, 2017, 12:02:14 AM (7 years ago)
Author:
lfita
Message:

Adding:

  • `compute_WRFtime': function to copmute CFtimes from WRFtime variable
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1672 r1673  
    4646# compute_tevolboxtraj: Function to compute tevolboxtraj: temporal evolution at a given point along a box following a trajectory
    4747# compute_tevolboxtraj_radialsec: Function to compute tevolboxtraj_radialsec: temporal evolution at a given point along a number of radii at a given frequency following a trajectory
     48# compute_WRFtime: unction to copmute CFtimes from WRFtime variable
    4849# curve_section: Function to provide a section of a file following a given curve
    4950# DataSetSection: Function to get a section (values along a dimension) of a given data-set
     
    2066220663    return
    2066320664
     20665def compute_WRFtime(timewrfv, refdate='19491201000000', tunitsval='minutes'):
     20666    """ Function to copmute CFtimes from WRFtime variable
     20667      refdate= [YYYYMMDDMIHHSS] format of reference date
     20668      tunitsval= CF time units
     20669      timewrfv= matrix string values of WRF 'Times' variable
     20670    """
     20671    fname = 'compute_WRFtime'
     20672
     20673    yrref=refdate[0:4]
     20674    monref=refdate[4:6]
     20675    dayref=refdate[6:8]
     20676    horref=refdate[8:10]
     20677    minref=refdate[10:12]
     20678    secref=refdate[12:14]
     20679
     20680    refdateS = yrref + '-' + monref + '-' + dayref + ' ' + horref + ':' + minref +   \
     20681      ':' + secref
     20682
     20683    dt = timewrfv.shape[0]
     20684    WRFtime = np.zeros((dt), dtype=np.float)
     20685
     20686    for it in range(dt):
     20687        wrfdates = gen.datetimeStr_conversion(timewrfv[it,:],'WRFdatetime', 'matYmdHMS')
     20688        WRFtime[it] = gen.realdatetime1_CFcompilant(wrfdates, refdate, tunitsval)
     20689
     20690    tunits = tunitsval + ' since ' + refdateS
     20691
     20692    return WRFtime, tunits
     20693
    2066420694#quit()
Note: See TracChangeset for help on using the changeset viewer.