30 Write one row into CSV file
38 colnames : list of str
40 colvalues : list of float
45 f = open(outfile,
'w')
46 writer = csv.DictWriter(f, colnames)
48 for colname
in colnames:
49 headers[colname] = colname
50 writer.writerow(headers)
54 f = open(outfile,
'a')
57 writer = csv.DictWriter(f, colnames)
58 writer.writerow(colvalues)
72 Read pull values from pull distribution ASCII file
77 Pull distribution ASCII file
83 values : list of float
94 reader = csv.reader(open(filename,
'r'), delimiter=
',')
104 index = row.index(parname)
106 print(
'ERROR: Parameter "'+parname+
'" not found in list:')
109 raise NameError(parname)
113 values.append(float(row[index]))
127 Get arguments and options from argument list
131 options : list of dict
132 List of possible options and default values
134 Usage string to be shown in case of a problem
138 args, options : tuple of list and list of dict
139 Arguments and updated list of options
146 if len(sys.argv) < 1:
147 print(
'Usage: %s' % usage)
154 while i < len(sys.argv):
160 for option
in options:
163 if sys.argv[i] == option[
'option']:
168 if len(sys.argv) > i+1:
171 option[
'value'] = str(sys.argv[i])
173 print(
'Usage: %s' % usage)
179 print(
'Usage: %s' % usage)
188 args.append(sys.argv[i])
202 Append result column to FITS table
206 table : `~gammalib.GFitsTable`
208 results : list of dict
221 col = gammalib.GFitsTableDoubleCol(name, nrows)
225 for i, result
in enumerate(results):
240 Append model parameter column to FITS table
244 table : `~gammalib.GFitsTable`
246 model : `~gammalib.GModel`
248 results : list of dict
262 e_name =
'e_'+par.name()
265 col = gammalib.GFitsTableDoubleCol(name, nrows)
266 e_col = gammalib.GFitsTableDoubleCol(e_name, nrows)
268 e_col.unit(par.unit())
271 for i, result
in enumerate(results):
272 col[i] = result[
'values'][name]
273 e_col[i] = result[
'values'][e_name]
append_model_par_column(table, model, results)
read_pull_values(filename, parname)
get_args_options(options, usage)
append_result_column(table, results, name, unit, key)
write_csv_row(outfile, row, colnames, colvalues)