Changeset 2162 in lmdz_wrf


Ignore:
Timestamp:
Oct 4, 2018, 4:36:15 PM (7 years ago)
Author:
lfita
Message:

Adding change of year in `days_month'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2161 r2162  
    50525052
    50535053    date1=dt.date(year,month,1)
    5054     date2=dt.date(year,month+1,1)
     5054    if month+1 > 12:
     5055        date2=dt.date(year+1,1,1)
     5056    else:
     5057        date2=dt.date(year,month+1,1)
    50555058
    50565059    diffdate = date2-date1
     
    1408114084    dcyc = cycvar.shape[0]
    1408214085    # Indices of the beginning and end of the period
    14083     print 'cycvar:', cycvar
    14084     print 'bper:', bper, 'eper:', eper, 'val:', val
    14085 
    1408614086    bind = index_vec(cycvar,bper)
    1408714087    eind = index_vec(cycvar,eper)
     
    1408914089    # Index of the value
    1409014090    vind = index_vec(cycvar,val)
    14091 
    14092     print 'bind:', bind, 'eind:', eind, 'vind:', vind
    1409314091
    1409414092    if eind < bind:
     
    1414814146        Ncyctimes = Ncyctimes + 1
    1414914147
    14150         print 'cyctimes:', cyctimes
    14151 
    1415214148        iit = 0
    1415314149        itt = 0
     
    1415914155            ttv = mattimes[it,imat]
    1416014156            timeslice[1] = it
    14161             print it, ttv, 'ip:', ip, 'ep:', ep, '<>', (ttv >= ip and ttv < ep)
    1416214157            if not (ttv >= ip and ttv < ep):
    1416314158                slices.append(timeslice)
     
    1418614181            ttv = mattimes[it,imat]
    1418714182            timeslice[1] = it
    14188             print it, '.', itt, '|', ttv, 'ip:', ip, 'ep:', ep, '<>', cyclevar_within(cyctimes, ip, ep, ttv)
    1418914183            if not (cyclevar_within(cyctimes, ip, ep, ttv)):
    1419014184                slices.append(timeslice)
     
    1419614190    elif per == 'day':
    1419714191        imat = 2
    14198         # Getting unique values
    14199         years = list(mattimes[:,imat])
    14200         setvar = set(years)
    14201         utimes = list(setvar)
    14202         utimes.sort()
    14203         Nutimes = len(utimes)
    14204 
    14205         # introducing amounts
    14206         print '  unique ', Nutimes, 'times:', utimes, '<>', utimes[0], utimes[Nutimes-1]+amount, amount
    14207         atimes = np.arange(utimes[0], utimes[Nutimes-1]+amount, amount)
    14208         Ntimes = len(atimes)
    14209         print '  amount ', Ntimes, 'periods:', atimes
     14192
     14193        for it in range(dimt):
     14194
     14195            # cycle for days as function of the month
     14196            Ncyctimes = days_month(mattimes[it,0],mattimes[it,1])
     14197            cyctimes = np.arange(Ncyctimes)+1
    1421014198       
    14211         itt = 0
    14212         for iat in range(Ntimes-1):
     14199            print 'cyctimes:', cyctimes
     14200
     14201            # First cycle time from first time
     14202            iit = 0
     14203            itt = index_vec(cyctimes,mattimes[0,imat])
     14204            ip = cyctimes[itt]
     14205            ep = cyclevar(cyctimes, itt+amount)
     14206
    1421314207            # timeslice: [ini_slice, end_slice, freq_slice]
    14214             timeslice = [itt,itt,1]
    14215             ip = atimes[iat]
    14216             ep = atimes[iat+1]
    14217 
    14218             for it in range(itt,dimt):
    14219                 if mattimes[it,imat] >= ip and mattimes[it,imat] < ep:
    14220                     timeslice[1] = it
    14221                 else:
    14222                     timeslice[1] = it
    14223                     slices.append(timeslice)
    14224                     itt = it + 0
    14225                     break
     14208            timeslice = [iit,iit,1]
     14209            ttv = mattimes[it,imat]
     14210            timeslice[1] = it
     14211            if not (cyclevar_within(cyctimes, ip, ep, ttv)):
     14212                slices.append(timeslice)
     14213                iit = it + 0
     14214                itt = itt + amount
     14215                ip = cyclevar(cyctimes,itt)
     14216                ep = cyclevar(cyctimes,itt+amount)
    1422614217    else:
    1422714218        print errormsg
     
    1423814229tv = []
    1423914230values = []
    14240 totT = 30.
    14241 dT = 7.
     14231totT = 24.*60.
     14232dT = 7.*60.
    1424214233for it in range(0,10):
    1424314234    for itt in range(3):
     
    1424714238vals = np.array(values)
    1424814239itdim = 0
    14249 tu = 'days since 1949-12-01 00:00:00'
    14250 per = 'month'
     14240tu = 'minutes since 1949-12-01 00:00:00'
     14241per = 'day'
    1425114242calend = 'standard'
    1425214243amount = 1
Note: See TracChangeset for help on using the changeset viewer.