Changeset 2519 in lmdz_wrf


Ignore:
Timestamp:
May 9, 2019, 12:53:46 AM (6 years ago)
Author:
lfita
Message:

Adding

  • `ntimesHval_inlist': Function to count how many times a list have a value with a giving header
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r2517 r2519  
    182182#   characteristics of the number
    183183# Ntchar: Function to repeat a number of times a given string
     184# ntimesHval_inlist: Function to count how many times a list have a value with a giving header
    184185# num_chainSnum: Function to pass a value to a `ChainStrNum' number
    185186# num_ordinal: Function to provide the ordinal of a given number, language, format and gender
     
    1669916700    return newtimevals
    1670016701
     16702def ntimesHval_inlist(listv,Hval):
     16703    """ Function to count how many times a list have a value with a giving header
     16704      listv: list of values
     16705      Hval: headr to check
     16706    >>> ntimesHval_inlist(['ABC1', 'AB1', 'ABC2', 'ABC3'], 'ABC')
     16707    3
     16708    """
     16709    fname = 'ntimesHval_inlist'
     16710
     16711    Ntimes = 0
     16712
     16713    LHval=len(Hval)
     16714
     16715    for lv in listv:
     16716        if lv[0:LHval] == Hval: Ntimes = Ntimes + 1
     16717
     16718    return Ntimes
     16719
    1670116720#quit()
    1670216721
Note: See TracChangeset for help on using the changeset viewer.