Changeset 1201 in lmdz_wrf for trunk/tools/generic_tools.py
- Timestamp:
- Oct 18, 2016, 11:50:40 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r1197 r1201 86 86 # str_list: Function to obtain a list from a string givin a split character 87 87 # str_list_k: Function to obtain a list of types of values from a string giving a split character 88 # stringS_dictvar: Function to provide a dictionary from a Srting which list of DVs separated [key] [value] couples 88 89 # stringList_dictKeysVals: Function to provide a dictionary with keys which contain values of lists from a string 89 90 # subbasin_point: Function to provide sub-basins given a grid point following a matrix of trips … … 5517 5518 print errormsg 5518 5519 print ' ' + fname + ': longitude values with shape:', lon.shape, \ 5519 'is different tha tlatitude values with shape:', lat.shape, '(dif. size) !!'5520 'is different than latitude values with shape:', lat.shape, '(dif. size) !!' 5520 5521 quit(-1) 5521 5522 … … 8973 8974 return matches, locs 8974 8975 8975 def dictvar_listS(listv, dictv, Dc , DVs):8976 def dictvar_listS(listv, dictv, Dc=',', DVs=':'): 8976 8977 """ Function to provide a Dc string separated list of DVs separated [key] [value] couples following a list of keys 8977 8978 listv: list of keys from dictionary to use … … 9000 9001 9001 9002 return stringv 9003 9004 def stringS_dictvar(stringv, Dc=',', DVs=':'): 9005 """ Function to provide a dictionary from a Srting which list of DVs separated [key] [value] couples 9006 stringv: String with a dictionary content as [key1][DVs][val1][Dc][key2][DVs][Val2][Dc]... 9007 Sc: character to separate key values 9008 DVs: character to separate key-value couples 9009 >>> stringS_dictvar('i:1,iv:4,vii:7',',',':') 9010 {'i': '1', 'vii': '7', 'iv': '4'} 9011 """ 9012 fname = 'stringS_dictvar' 9013 dictv = {} 9014 for Svals in stringv.split(Dc): 9015 keyn = Svals.split(DVs)[0] 9016 valn = Svals.split(DVs)[1] 9017 dictv[keyn] = valn 9018 9019 return dictv 9002 9020 9003 9021 def list_coincidences(listA, listB):
Note: See TracChangeset
for help on using the changeset viewer.