Changeset 1105 in lmdz_wrf for trunk


Ignore:
Timestamp:
Sep 13, 2016, 10:52:42 AM (9 years ago)
Author:
lfita
Message:

Adding `julday_360d': Function to provide the julian day of a date in a 360 days/yr (or 12 30-days months) calendar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1102 r1105  
    5555# index_mat: Function to provide the coordinates of a given value inside a matrix
    5656# index_vec: Function to provide the coordinates of a given value inside a vector
     57# julday_360d: Function to provide the julian day of a date in a 360 days/yr (or 12 30-days months) calendar
    5758# list_combos: Function to construct a new list with all possible N-combinations of the list-values
    5859# list_coincidences: Function to provide the coincidences between two lists
     
    280281    Nlvs = len(listv)
    281282    for ic in range(Ncombos):
    282         print fname + ' Lluis: ic:', ic, 'Nlvs:', Nlvs
    283283        prevlist = list(newlist)
    284284        for lv in prevlist:
     
    850850    return newdate
    851851
     852def julday_360d(date):
     853    """ Function to provide the julian day of a date in a 360 days/yr (or 12 30-days months) calendar
     854      date=  date [Y, m, d, h, mi, s]
     855      >>> julday_360d([1976,2,17,8,30,2])
     856      47
     857    """
     858    fname = 'julday_360d'
     859
     860    julday = (date[1]-1)*30 + date[2]
     861
     862    return julday
     863print julday_360d([1976,2,17,8,30,2])
     864
     865quit()
    852866class dtsec360dyr(object):
    853867    """ Class to operate a number of seconds to a date in a 360 days/yr (or 12 30-days months) calendar
     
    91989212    matype = mat.dtype
    91999213
    9200     print fname + '; Lluis: matype:', matype,'shape:',mat.shape,'opdims:',opdims
    9201 
    92029214    if oper.find(',') != -1:
    92039215        opern = oper.split(',')[0]
     
    92279239        idim = idim + 1
    92289240
     9241    if len(ldimop) == 0:
     9242        print errormsg
     9243        print '  ' + fname + ': no dimensions found for the operation !!'
     9244        print '    dimensions in file:', dimns
     9245        print '    dimensions for the operation:', opdims
     9246        quit(-1)
     9247
    92299248    Ndop = len(opdims)
    92309249    Ntotdims = np.prod(ldimop)
    9231     print fname + '; Lluis ldimop:', ldimop, 'Ntotdims:', Ntotdims
    92329250
    92339251    # Checking for coincidence in shapes
     
    92519269            if slicevals[idn] == -1:
    92529270                ijkop = ijkop + 1
     9271
    92539272                opslice.append(idcalc[ijkop])
    92549273            else:
Note: See TracChangeset for help on using the changeset viewer.