Changeset 1633 in lmdz_wrf


Ignore:
Timestamp:
Sep 10, 2017, 9:46:06 PM (7 years ago)
Author:
lfita
Message:

Adding when WRF file has already a CF-time variable in 'WRF_to_newCF'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1627 r1633  
    1867018670    timev = timeobj[:]
    1867118671
    18672     fdates = wrfnc.variables['Times'][:]
    18673     cftimes = []
    18674     for it in range(fdates.shape[0]):
    18675         wrfdates = gen.datetimeStr_conversion(fdates[it,:], 'WRFdatetime', 'matYmdHMS')
    18676         cftimes.append(gen.realdatetime1_CFcompilant(wrfdates, refDateTime, Tunits))
    18677 
    1867818672    yrref=refDateTime[0:4]
    1867918673    monref=refDateTime[4:6]
     
    1868518679    tunit = Tunits + ' since ' + yrref + '/' + monref + '/' + dayref + ' ' +         \
    1868618680      horref + ':' + minref + ':' + secref
     18681
     18682    # WRF file might already have the right time-variable
     18683    if wtimen == 'Times':
     18684        fdates = wrfnc.variables['Times'][:]
     18685        cftimes = []
     18686        for it in range(fdates.shape[0]):
     18687            wrfdates = gen.datetimeStr_conversion(fdates[it,:], 'WRFdatetime', 'matYmdHMS')
     18688            cftimes.append(gen.realdatetime1_CFcompilant(wrfdates, refDateTime, Tunits))
     18689    else:
     18690        itimeunits = timeobj.getncattr('units')
     18691        if itimeunits != tunit:
     18692            cftimes = gen.coincident_CFtimes(timev, tunit, itimeuints)
     18693        else:
     18694            cftimes = list(timev)
    1868718695
    1868818696    newvar = onewnc.createVariable('time','f8',('time'))
     
    1871518723                    newvard.append(str(dimn))
    1871618724                    if not gen.searchInlist(newdims, dimn): add_dims(wrfnc,onewnc,[str(dimn)])
    18717 
    1871818725
    1871918726            cfn = varattrs[0]
Note: See TracChangeset for help on using the changeset viewer.