Changeset 275 in lmdz_wrf for trunk/tools/nc_var_tools.py
- Timestamp:
- Feb 25, 2015, 11:37:11 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r274 r275 98 98 99 99 return vals 100 101 def check_arguments(funcname,Nargs,args,char,expectargs): 102 """ Function to check the number of arguments if they are coincident 103 check_arguments(funcname,Nargs,args,char) 104 funcname= name of the function/program to check 105 Nargs= theoretical number of arguments 106 args= passed arguments 107 char= character used to split the arguments 108 """ 109 110 fname = 'check_arguments' 111 112 Nvals = len(args.split(char)) 113 if Nvals != Nargs: 114 print errormsg 115 print ' ' + fname + ': wrong number of arguments:',Nvals," passed to '", \ 116 funcname, "' which requires:",Nargs,'!!' 117 print ' given arguments:',args.split(char) 118 print ' expected arguments:',expectargs 119 quit(-1) 120 121 return 122 123 def Str_Bool(val): 124 """ Function to transform from a String value to a boolean one 125 >>> Str_Bool('True') 126 True 127 >>> Str_Bool('0') 128 False 129 >>> Str_Bool('no') 130 False 131 """ 132 133 fname = 'Str_Bool' 134 135 if val == 'True' or val == '1' or val == 'yes': 136 boolv = True 137 elif val == 'False' or val == '0' or val== 'no': 138 boolv = False 139 else: 140 print errormsg 141 print ' ' + fname + ": value '" + val + "' not ready!!" 142 quit(-1) 143 144 return boolv 145 146 ####### ###### ##### #### ### ## # 100 147 101 148 def valmodoper(varVal, valuesS): … … 12412 12459 #field_stats('full', 'geo_em.d01.nc', 'HGT_M') 12413 12460 12414 def check_arguments(funcname,Nargs,args,char,expectargs):12415 """ Function to check the number of arguments if they are coincident12416 check_arguments(funcname,Nargs,args,char)12417 funcname= name of the function/program to check12418 Nargs= theoretical number of arguments12419 args= passed arguments12420 char= character used to split the arguments12421 """12422 12423 fname = 'check_arguments'12424 12425 Nvals = len(args.split(char))12426 if Nvals != Nargs:12427 print errormsg12428 print ' ' + fname + ': wrong number of arguments:',Nvals," passed to '", \12429 funcname, "' which requires:",Nargs,'!!'12430 print ' given arguments:',args.split(char)12431 print ' expected arguments:',expectargs12432 quit(-1)12433 12434 return12435 12436 def Str_Bool(val):12437 """ Function to transform from a String value to a boolean one12438 >>> Str_Bool('True')12439 True12440 >>> Str_Bool('0')12441 False12442 >>> Str_Bool('no')12443 False12444 """12445 12446 fname = 'Str_Bool'12447 12448 if val == 'True' or val == '1' or val == 'yes':12449 boolv = True12450 elif val == 'False' or val == '0' or val== 'no':12451 boolv = False12452 else:12453 print errormsg12454 print ' ' + fname + ": value '" + val + "' not ready!!"12455 quit(-1)12456 12457 return boolv12458 12459 12461 def get_namelist_vars(values, namelist): 12460 12462 """ Function to get namelist-like values ([varname] = [value])
Note: See TracChangeset
for help on using the changeset viewer.