Changeset 2229 in lmdz_wrf for trunk/tools/generic_tools.py


Ignore:
Timestamp:
Nov 14, 2018, 9:30:59 PM (6 years ago)
Author:
lfita
Message:

Finally fixing `cycle_within'?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2228 r2229  
    1402514025    >>> cyclevar_within(np.arange(12)+1, 12, 2, 2)
    1402614026    True
     14027    >>> cyclevar_within(np.arange(12)+1, 12, 2, 12)
     14028    True
    1402714029    """
    1402814030    fname = 'cyclevar_within'
     
    1403814040    if eind < bind:
    1403914041        eind = eind + dcyc
    14040         vind = vind + dcyc
     14042        if vind != bind: vind = vind + dcyc
    1404114043
    1404214044    if vind < bind:
     
    1465514657    """ Function to return temporal slices of a series of times for a given amount
    1465614658        of periods
    14657       tv: time vallues (CF format)
     14659      tv: time values (CF format)
    1465814660      tu: CF time-units
    1465914661      cal: calendar
     
    1470314705        print '    available ones:', type(np.arange(1)), type(range(2))
    1470414706        quit(-1)
    14705     #print 'mat times _______'   
     14707    #print 'mat times _______'
    1470614708    #for it in range(dimt):
    1470714709    #    print '  ',it, mattimes[it,:]
     
    1476914771            if cyclevar_within(months12, bseas, eseas, estats[1]):
    1477014772                estats[1] = bseas
    14771                 bereak
     14773                break
    1477214774        # Checking if the end of season is on the following year...
    1477314775        if bseas < mone: estats[0] = estats[0] + 1
     
    1498014982for it in range(0,10):
    1498114983   for itt in range(3):
    14982         tv.append(iTT+it*totT+dT*itt)
     14984        days = iTT+it*totT+dT*itt
     14985        tv.append(days)
    1498314986        #values.append((it*3+itt)*1.)
    14984         values.append(it*1.)
    14985 
    14986 print 'tv:', tv
    14987 print 'values:', values
     14987        Nyear = int((days-31)/365)
     14988        dyear = (days-31) - Nyear*365
     14989        if dyear < 59:
     14990            values.append(0.)
     14991        elif dyear >= 59 and dyear < 151:
     14992            values.append(1.)
     14993        elif dyear >= 151 and dyear < 243:
     14994            values.append(2.)
     14995        elif dyear >= 243 and dyear < 334:
     14996            values.append(3.)
     14997
     14998for it in range(len(values)):
     14999    print it, tv[it], values[it]
    1498815000
    1498915001vals = np.array(values)
    1499015002itdim = 0
    1499115003tu = 'days since 1949-12-01 00:00:00'
    14992 per = 'aggseason'
     15004per = 'season'
    1499315005calend = 'standard'
    1499415006amount = 1
     
    1501615028            origshape[itdim] = aggslc[iislc]
    1501715029            iishape[itdim] = iislc
    15018             print iislc, ':', iishape, '<>', origshape
     15030            print iislc, ':', iishape, '<>', origshape, vals[tuple(origshape)]
    1501915031            tvals[tuple(iishape)] = vals[tuple(origshape)]
    1502015032
Note: See TracChangeset for help on using the changeset viewer.