Changeset 904 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 19, 2016, 7:59:25 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r896 r904 30 30 # dictionary_key: Function to provide the first key in a dictionay with a given value 31 31 # dictionary_key_list: Function to provide the first key in a dictionay of lists with a given value 32 # files_folder_HMT: Function to retrieve a list of files from a folder [fold] and files with [head]*[middle]*[tail] 32 33 # ijlonlat: Function to provide the imin,jmin imax,jmax of a lon,lat box 33 34 # incomming_flow: Function to determine if a fgrid-flow inflows to the central grid point … … 5269 5270 return runmean 5270 5271 5272 def files_folder_HMT(folder,head,middle,tail): 5273 """ Function to retrieve a list of files from a folder [fold] and files with [head]*[middle]*[tail] 5274 >>> files_folder_HMT('.','t','wrf','mean.nc') 5275 ['clt_wrfout_tmean.nc', 'tas_wrfout_tmean.nc', 'ta_wrfout_xmean.nc'] 5276 """ 5277 import subprocess as sub 5278 fname = 'files_folder' 5279 5280 if folder == 'h': 5281 print fname + '_____________________________________________________________' 5282 print files_folder.__doc__ 5283 quit() 5284 5285 # ins = folder + "/" + head + "*" + middle + '*' + tail 5286 ins = folder + "/" 5287 # print 'ins:',ins 5288 files = sub.Popen(["/bin/ls","-1",ins], stdout=sub.PIPE) 5289 fileslist = files.communicate() 5290 listfiles0 = str(fileslist).replace("'",'').replace('(','').replace(')','').split('\\n') 5291 5292 # Filtering output 5293 listfiles = [] 5294 for ifile in listfiles0: 5295 if ifile.find(head) != -1 and ifile.find(middle) != -1 and \ 5296 ifile.find(tail) != -1: 5297 indhead = ifile.index(head) 5298 indmiddle = ifile.index(middle) 5299 indtail = ifile.index(tail) 5300 if indhead < indmiddle < indtail: listfiles.append(ifile) 5301 5302 return listfiles 5303 5271 5304 def files_folder(folder,headfile): 5272 5305 """ Function to retrieve a list of files from a folder [fold] and head [headfile]
Note: See TracChangeset
for help on using the changeset viewer.