Changeset 2426 in lmdz_wrf


Ignore:
Timestamp:
Apr 9, 2019, 7:54:13 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `leapdays': Function to provide how many leap days are between two years
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2425 r2426  
    140140# latex_text: Function to transform a text to LaTeX following style rules
    141141# Latin_Greek: Function to pass an ASCII latin character to its equivalent greek
     142# leapdays: Function to provide how many leap days are between two years
    142143# linearint_weights: Function to provide the weights for a linear interpolation of a value between a couple of values as a weighted distance mean
    143144# linearint_3x3weights: Function to provide the weights for a linear interpolation of a value inside a 3x3 matrix of values as a weighted distance mean
     
    508509    return diffdate.days
    509510
     511def leapdays(yeari, yeare):
     512    """ Function to provide how many leap days are between two years
     513      yeari: initial year from [yeari] Jan 01
     514      yeare: end year until [yearf] Dec 12
     515    >>> leapdays(1970,1980)
     516    3
     517    >>> leapdays(1976,1976)
     518    1
     519    """
     520    fname = 'leapdays'
     521
     522    Nleapdays = 0
     523    for iyr in range(yeari,yeare+1):
     524        if days_month(iyr,2) == 29: Nleapdays=Nleapdays+1
     525
     526
     527    return Nleapdays
     528
    510529def datetimeStr_datetime(StringDT):
    511530    """ Function to transform a string date ([YYYY]-[MM]-[DD]_[HH]:[MI]:[SS] format) to a date object
     
    601620    >>> datetimeStr_conversion('1980/03/05 18-00-00','Y/m/d H-M-S','cfTime,minutes since 1979-12-01_00:00:00')
    602621    137880.0
     622    >>> datetimeStr_conversion('-12357.961','cfTimeCal,days since 1949-12-01 00:00:00,noleap','Y/m/d H-M-S')
     623
    603624    """
    604625    import datetime as dt
     
    10401061
    10411062    return dateYmdHMS
     1063
     1064print datetimeStr_conversion('-12357.961','cfTimeCal,days since 1949-12-01 00:00:00,noleap','Y/m/d H-M-S')
     1065quit()
    10421066
    10431067def period_information(idate, edate, totunits):
Note: See TracChangeset for help on using the changeset viewer.