Changeset 2459 in lmdz_wrf


Ignore:
Timestamp:
Apr 23, 2019, 2:31:25 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `leapyr': Function to determine if it is a leap year (independently of datetime)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2458 r2459  
    142142# latex_text: Function to transform a text to LaTeX following style rules
    143143# Latin_Greek: Function to pass an ASCII latin character to its equivalent greek
     144# leapyr: Function to determine if it is a leap year (independently of datetime)
    144145# leapdays: Function to provide how many leap days are between two years
    145146# linearint_weights: Function to provide the weights for a linear interpolation of a value between a couple of values as a weighted distance mean
     
    1580315804#        print '  ' , '(', inds[i,j,0], ',', inds[i,j,1], ')'
    1580415805
     15806def leapyr(yr):
     15807    """ Function to determine if it is a leap year (independently of datetime)
     15808    FROM: https://en.wikipedia.org/wiki/Leap_year
     15809      yr: year to check
     15810    >>> leapyr(2019)
     15811    False
     15812    >>> leapyr(1976)
     15813    True
     15814    >>> leapyr(1800)
     15815    False
     15816    >>> leapyr(1850)
     15817    False
     15818    """
     15819    fname = 'leapyr'
     15820
     15821    isleap = False
     15822    if np.mod(yr,4) == 0: isleap = True
     15823    if np.mod(yr,100) == 0: isleap = False
     15824    if np.mod(yr,400) == 0: isleap = True
     15825
     15826    return isleap
     15827
    1580515828def fix_CFdates(timevals, origcftimeu, origcal,                                      \
    1580615829  newcftimeu= 'hours since 1949-12-01 00:00:00', newcal='gregorian'):
Note: See TracChangeset for help on using the changeset viewer.