Changeset 1061 in lmdz_wrf for trunk


Ignore:
Timestamp:
Aug 30, 2016, 12:52:36 PM (9 years ago)
Author:
lfita
Message:

Adding optional values in `files_folder_HMT': folder='.',head=,middle=,tail=

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1042 r1061  
    53625362    return runmean
    53635363
    5364 def files_folder_HMT(folder,head,middle,tail):
     5364def files_folder_HMT(folder='.',head='',middle='',tail=''):
    53655365    """ Function to retrieve a list of files from a folder [fold] and files with [head]*[middle]*[tail]
    53665366    >>> files_folder_HMT('.','t','wrf','mean.nc')
    53675367    ['clt_wrfout_tmean.nc', 'tas_wrfout_tmean.nc', 'ta_wrfout_xmean.nc']
     5368    >>> files_folder_HMT(folder='/home/lluis/etudes/WRF_LMDZ/WaquaL_highres/tests/model_graphics/WRF/current', \
     5369      head='hfls', tail='.nc')
     5370    ['hfls_wrfout.nc', 'hfls_wrfout_tmean.nc']
    53685371    """
    53695372    import subprocess as sub
     
    53895392            indhead = ifile.index(head)
    53905393            indmiddle = ifile.index(middle)
     5394            if indmiddle == 0: indmiddle = indhead
    53915395            indtail = ifile.index(tail)
    5392             if indhead < indmiddle < indtail: listfiles.append(ifile)
     5396            if indtail == 0: indtail = inhead + inmiddle
     5397            if indhead <= indmiddle <= indtail: listfiles.append(ifile)
    53935398
    53945399    return listfiles
Note: See TracChangeset for help on using the changeset viewer.