Changeset 1100 in lmdz_wrf


Ignore:
Timestamp:
Sep 12, 2016, 11:18:53 AM (8 years ago)
Author:
lfita
Message:

Adding `week' in 'period_information'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1098 r1100  
    325325    check_arguments(fname,str(idate)+','+str(edate)+','+str(totunits),expectargs,',')
    326326
     327    readyT = ['year','month','week','day','hour','minute','second']
     328
    327329# Checking length
    328330    Lidate = len(idate)
     
    416418# Looking for number of months tacking exact beginning of the units [iYYYY][iMM]01000000, [eYYYY][eMM+1]01000000
    417419##
    418     if totunits == 'month':
     420    elif totunits == 'month':
    419421        itime = int(iyrS)*100 + int(imoS)
    420422        if edate[6:15] != '01000000':
     
    451453        oinf = oinf + ',' + str(Nmonths) + ',' + ExactMonths
    452454
     455# Looking for number of days tacking exact beginning of the units [iYYYY][iMM][iDD]000000, [eYYYY][eMM][eDD+7]000000
     456##
     457    elif totunits == 'week':
     458        itime = dt.datetime(int(iyrS),int(imoS),int(idaS),0,0,0)
     459        if edate[8:15] != '000000':
     460            etime = dt.datetime(int(eyrS), int(emoS), int(edaS)+7,0,0,0)
     461        else:
     462            etime = edateT
     463
     464        Ndays = 1
     465        ExactDays = itime.strftime("%Y%m%d%H%M%S")
     466        it = itime
     467        while it + dt.timedelta(days=7) <= etime:
     468            it = it + dt.timedelta(days=7)
     469            Ndays = Ndays + 7
     470            ExactDays = ExactDays + '@' + it.strftime("%Y%m%d%H%M%S")
     471
     472        oinf = oinf + ',' + str(Ndays) + ',' + ExactDays
     473
    453474# Looking for number of days tacking exact beginning of the units [iYYYY][iMM][iDD]000000, [eYYYY][eMM][eDD+1]000000
    454475##
    455     if totunits == 'day':
     476    elif totunits == 'day':
    456477        itime = dt.datetime(int(iyrS),int(imoS),int(idaS),0,0,0)
    457478        if edate[8:15] != '000000':
     
    472493# Looking for number of hours tacking exact beginning of the units [iYYYY][iMM][iDD][iHH]0000, [eYYYY][eMM][eDD][iHH+1]0000
    473494##
    474     if totunits == 'hour':
     495    elif totunits == 'hour':
    475496        itime = dt.datetime(int(iyrS),int(imoS),int(idaS),int(ihoS),0,0)
    476497        if edate[10:15] != '0000':
     
    491512# Looking for number of minutes tacking exact beginning of the units [iYYYY][iMM][iDD][iHH][iMI]00, [eYYYY][eMM][eDD][iHH][iMI+1]00
    492513##
    493     if totunits == 'minute':
     514    elif totunits == 'minute':
    494515        itime = dt.datetime(int(iyrS),int(imoS),int(idaS),int(ihoS),int(imiS),0)
    495516        if edate[12:15] != '00':
     
    511532#   [eYYYY][eMM][eDD][iHH][iMI][iSE+1]
    512533##
    513     if totunits == 'second':
     534    elif totunits == 'second':
    514535        itime = dt.datetime(int(iyrS),int(imoS),int(idaS),int(ihoS),int(imiS),int(iseS))
    515536        if edate[12:15] != '00':
     
    527548   
    528549        oinf = oinf + ',' + str(Nseconds) + ',' + ExactSeconds
     550
     551    else:
     552        print errormsg
     553        print '  '+ fname + ": totalunits '" + totunits + "' not ready !!"
     554        print '    total time units ready:', readyT
     555        quit(-1)
    529556
    530557    return oinf
     
    86878714        [12 13]]
    86888715    """
    8689     fname = 'dimoper_matrix'
     8716    fname = 'oper_submatrix'
    86908717
    86918718    operations = ['sumc', 'subc', 'mulc', 'divc', 'lowthres', 'upthres']
    86928719    matype = mat.dtype
     8720
     8721    print fname + '; Lluis: matype:', matype,'shape:',mat.shape,'opdims:',opdims
    86938722
    86948723    if oper.find(',') != -1:
     
    87218750    Ndop = len(opdims)
    87228751    Ntotdims = np.prod(ldimop)
     8752    print fname + '; Lluis ldimop:', ldimop, 'Ntotdims:', Ntotdims
    87238753
    87248754    # Checking for coincidence in shapes
Note: See TracChangeset for help on using the changeset viewer.