Changeset 1899 in lmdz_wrf for trunk


Ignore:
Timestamp:
Apr 9, 2018, 5:14:29 PM (7 years ago)
Author:
lfita
Message:

Adding:

-`advance_matDate': Function to advance matrix-date with a matrix-increment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1898 r1899  
    5050
    5151####### Content
     52# advance_matDate: Function to advance matrix-date with a matrix-increment
    5253# angle_DegMinSec: Function to transform an angle to Degrees Minutes Seconds
    5354# ASCII_LaTeX: Function to transform from an ASCII character to LaTeX codification
     
    1301213013#print WRFsetup('/home/lluis/estudios/RELAMPAGO/SimCoor/UBA/namelist.input,/home/lluis/estudios/RELAMPAGO/SimCoor/SMN/namelist.input,/home/lluis/estudios/RELAMPAGO/SimCoor/NOA-IERSD/namelist.input,/home/lluis/estudios/RELAMPAGO/SimCoor/UBAmili/namelist.input', 'basic', 'textabcol')
    1301313014
     13015def advance_matDate(matdate, matinc):
     13016    """ Function to advance matrix-date with a matrix-increment
     13017      matdate= matrix date (yr, mn, dd, hh, mi, ss)
     13018      matinc= matrix increment for the date (incyre, incmm, incdd, inchh, incmm, incss)
     13019      >>> advance_matDate([1976, 02, 27, 23, 59, 0], [0, 11, 0, 0, 2, 0])
     13020      [1977, 1, 28, 0, 1, 0]
     13021    """
     13022    import datetime as dt
     13023    fname = 'advance_matDate'
     13024
     13025    idate = dt.datetime(matdate[0], matdate[1], matdate[2], matdate[3], matdate[4],      \
     13026      matdate[5])
     13027    inct = dt.timedelta(days=matinc[2], hours=matinc[3], minutes=matinc[4],              \
     13028      seconds=matdate[5])
     13029    newdate = idate + inct
     13030    newmatdate = [newdate.year, newdate.month, newdate.day, newdate.hour,                \
     13031      newdate.minute, newdate.second]
     13032
     13033    # Specific Incrementing
     13034    if matinc[0] != 0 or matinc[1] != 0:
     13035        if newmatdate[1] + matinc[1] > 12:
     13036            newmatdate[0] = newmatdate[0] + 1
     13037            newmatdate[1] = 1
     13038        else:
     13039            newmatdate[1] = newmatdate[1] + matinc[1]
     13040        newmatdate[0] = newmatdate[0] + matinc[0]
     13041
     13042    return newmatdate
     13043print  advance_matDate([1976, 02, 27, 23, 59, 0], [0, 11, 0, 0, 2, 0])
    1301413044#quit()
    1301513045
Note: See TracChangeset for help on using the changeset viewer.