- Timestamp:
- Aug 21, 2016, 12:59:49 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1030 r1034 38 38 # contflow: Function to bring back the increment in j,i grid points according to a trip: (inflow directions) 39 39 # dictionary_key: Function to provide the first key in a dictionay with a given value 40 # dictionary_key_list: Function to provide the first key in a dictiona y of lists with a given value40 # dictionary_key_list: Function to provide the first key in a dictionary of lists with a given value 41 41 # dictKeysVals_stringList: Function to provide strings from a dictionary with keys which contain values of lists 42 42 # dictvar_listS: Function to provide a Dc string separated list of DVs separated [key] [value] couples following a list of keys … … 47 47 # incomming_flow: Function to determine if a fgrid-flow inflows to the central grid point 48 48 # index_mat_way: Function to look for a value within a matrix following a direction 49 # list_combos: Function to construct a new list with all possible N-combinations of the list-values 49 50 # num_chainSnum: Function to pass a value to a `ChainStrNum' number 50 51 # num_split: Function to split a string at each numeric value keeping the number as the last character of each cut … … 250 251 251 252 return newstring 253 254 def list_combos(listv,Ncombos): 255 """ Function to construct a new list with all possible N-combinations of the list-values 256 listv= list of values 257 Ncombos= number of combinations 258 >>> list_combos(['a', 'b', 'c', 'd'],1) 259 ['a', 'b', 'c', 'd', 'aa', 'ab', 'ac', 'ad', 'ba', 'bb', 'bc', 'bd', 'ca', 'cb', 'cc', 'cd', 'da', 'db', 'dc', 'dd'] 260 """ 261 fname = 'list_combos' 262 263 newlist = list(listv) 264 Nlvs = len(listv) 265 for ic in range(Ncombos): 266 print fname + ' Lluis: ic:', ic, 'Nlvs:', Nlvs 267 prevlist = list(newlist) 268 for lv in prevlist: 269 for ilv in listv: 270 newlist.append(lv + ilv) 271 272 return newlist 252 273 253 274 def period_information(idate, edate, totunits): … … 544 565 print ' '+ fname + ": varibale '" + varName + "' with a " + \ 545 566 "statistical surname: '",st,"' !!" 546 Lst = len(st) 547 LvarName = len(varName) 548 varn = varName[0:LvarName - Lst] 567 varName = varName.replace(st,'') 549 568 ifst = True 550 break 551 if not ifst: 552 varn = varName 569 varn = varName 553 570 554 571 ncf = open(infile, 'r')
Note: See TracChangeset
for help on using the changeset viewer.