Changeset 1907 in lmdz_wrf for trunk


Ignore:
Timestamp:
Apr 16, 2018, 12:56:07 AM (7 years ago)
Author:
lfita
Message:

Agregatting new possible time-units on `compute_time_bnds'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r1906 r1907  
    2290522905
    2290622906    # Quantity of time_bnds
    22907     availtunits = ['c', 'y', 'm', 'd', 'h', 'i', 's']
    22908     if tunit == 'c':
     22907    availtunits = ['c', 'ce', 'y', 'yr', 'm', 'mo', 'w', 'we', 'd', 'da', 'h', 'hr', \
     22908      'i', 'mi', 's', 'se']
     22909    if tunit == 'c' or tunit == 'ce':
    2290922910        dtbnds = quantity * 100 * 365 * 24 * 3600.
    2291022911        begTBmat = [int(begTmat[0]/100)*100, 1, 1, 0, 0, 0]
     
    2291222913          [100,0,0,0,0,0])
    2291322914        dTBmat = [quantity*100, 0, 0, 0, 0, 0]
    22914     elif tunit == 'y':
     22915    elif tunit == 'y' or tunit == 'yr':
    2291522916        dtbnds = quantity * 365 * 24 * 3600.
    2291622917        begTBmat = [begTmat[0], 1, 1, 0, 0, 0]
    2291722918        endTBmat = [endTmat[0]+1, 1, 1, 0, 0, 0]
    2291822919        dTBmat = [quantity, 0, 0, 0, 0, 0]
    22919     elif tunit == 'm':
     22920    elif tunit == 'm' or tunit == 'mo':
    2292022921        iyr = begTmat[0]
    2292122922        imo = begTmat[1]
     
    2292622927        endTBmat = [endTmat[0], endTmat[1]+1, 1, 0, 0, 0]
    2292722928        dTBmat = [0, quantity, 0, 0, 0, 0]
    22928     elif tunit == 'w':
     22929    elif tunit == 'w' or tunit == 'we':
    2292922930        dtbnds = quantity * 7 * 24 * 3600.
    2293022931        begTBmat = [begTmat[0], begTmat[1], begTmat[2], 0, 0, 0]
     
    2293222933          [0,0,7,0,0,0])
    2293322934        dTBmat = [0, 0, quantity*7, 0, 0, 0]
    22934     elif tunit == 'd':
     22935    elif tunit == 'd' or tunit == 'da':
    2293522936        dtbnds = quantity * 24 * 3600.
    2293622937        begTBmat = [begTmat[0], begTmat[1], begTmat[2], 0, 0, 0]
     
    2293822939          [0,0,1,0,0,0])
    2293922940        dTBmat = [0, 0, quantity, 0, 0, 0]
    22940     elif tunit == 'h':
     22941    elif tunit == 'h' or tunit == 'hr':
    2294122942        dtbnds = quantity * 3600.
    2294222943        begTBmat = [begTmat[0], begTmat[1], begTmat[2], begTmat[3], 0, 0]
     
    2294422945          0], [0,0,0,1,0,0])
    2294522946        dTBmat = [0, 0, 0, quantity, 0, 0]
    22946     elif tunit == 'i':
     22947    elif tunit == 'i' or tunit == 'mi':
    2294722948        dtbnds = quantity * 60.
    2294822949        begTBmat = [begTmat[0], begTmat[1], begTmat[2], begTmat[3], begTmat[4], 0]
     
    2295022951          endTmat[4],0], [0,0,0,0,1,0])
    2295122952        dTBmat = [0, 0, 0, 0, quantity, 0]
    22952     elif tunit == 's':
     22953    elif tunit == 's' or tunit == 'se':
    2295322954        dtbnds = quantity * 1.
    2295422955        begTBmat = [begTmat[0], begTmat[1], begTmat[2], begTmat[3], begTmat[4],      \
     
    2437324374
    2437424375    if np.mod(secfreq, 100 * 365 * 24 * 3600.) == 0.:
    24375         Sfreq = str(int(secfreq/(100 * 365 * 24 * 3600.))) + ',C'
     24376        Sfreq = str(int(secfreq/(100 * 365 * 24 * 3600.))) + ',ce'
    2437624377    elif np.mod(secfreq, 365 * 24 * 3600.) == 0.:
    24377         Sfreq = str(int(secfreq/(365 * 24 * 3600.))) + ',Y'
     24378        Sfreq = str(int(secfreq/(365 * 24 * 3600.))) + ',yr'
    2437824379    elif np.mod(secfreq, 7 * 24 * 3600.) == 0.:
    24379         Sfreq = str(int(secfreq/(7 * 24 * 3600.))) + ',W'
     24380        Sfreq = str(int(secfreq/(7 * 24 * 3600.))) + ',we'
    2438024381    elif np.mod(secfreq, 24 * 3600.) == 0.:
    24381         Sfreq = str(int(secfreq/(24.*3600.))) + ',D'
     24382        Sfreq = str(int(secfreq/(24.*3600.))) + ',da'
    2438224383    elif np.mod(secfreq,3600.) == 0.:
    24383         Sfreq = str(int(secfreq/3600.)) + ',H'
     24384        Sfreq = str(int(secfreq/3600.)) + ',hr'
    2438424385    elif np.mod(secfreq,60.) == 0.:
    24385         Sfreq = str(int(secfreq/60.)) + ',M'
     24386        Sfreq = str(int(secfreq/60.)) + ',mi'
    2438624387    else:
    2438724388        print '  ' + fname + ": data from file does not conform "+\
     
    2439524396        print '      minute:', secfreq/(60.)
    2439624397        print '      second:', secfreq
     24398        quit(-1)
    2439724399    print 'diff_conform:', Sfreq
    2439824400
Note: See TracChangeset for help on using the changeset viewer.