saga.data

This module implements methods for loading and saving outputs from slurm jobs for all possible option combinations supplied in yaml files.

saga.data.load_csv(path, old_path=None, new_path=None, config=None, aggregate_config=None, chain_configs=None, aliases=None)

Parameters

pathstr, required

Path to CSV file containing table

old_pathstr, optional

Directory name to replace

new_pathstr, optional

Directory name to insert if not None

configdict, optional

Map of configuration option names to option values

aggregate_configdict, optional

Map of aggregate configuration option names to option values, used for determining correct directory names

chain_configsdict, optional

Map of configuration option names to lists of values across which to chain

aliasesdict, optional

Map of configuration option names to maps of option values to string aliases

Returns

pandas.DataFrame

Pandas dataframe of csv file data

Description

Read table stored in CSV format into a pandas DataFrame optionally replacing part of the path, for example, a directory name, with another value.

saga.data.load_th1(path, name='h1')

Parameters

pathstr, required

Path to ROOT file containing histogram

namestr, optional

Name of TH1 object within the ROOT file

Returns

np.array

Histogram data as a numpy array or empty list if file is not found

Description

Read TH1 histogram data from a ROOT file. This will work for any histogram: (TH1, TH2, TH3).

saga.data.load_yaml(path)

Parameters

pathstr, required

Path to yaml file

Returns

dict

dictionary of yaml contents

Description

Load a yaml from a file.

saga.data.save_bin_mig_mat_to_csv(bin_mig_mat, base_dir='./', basename='', delimiter=',', header=None, fmt=None, comments='')

Parameters

bin_mig_matnp.array, required

2D bin migration matrix with (i,j) -> (generated,reconstructed)

base_dirstr, required

Path to directory in which matrix will be saved

basenamestr, optional

Name of reconstructed bin variable

delimiterstr, optional

CSV format delimiter

headerstr, optional

CSV header

fmtstr, optional

CSV column formats, automatically set if not specified

commentsstr, optional

CSV comments

Raises

TypeError

Raise an error if the bin migration matrix is not square

Description

Save a 2D bin migration matrix mapping generated bins to reconstructed bins to a CSV file with an added initial row and column for the bin indices. Note that files will be saved to <base_dir>/bin_mig_mat_<basename>.csv.

saga.data.save_graph_systematics_to_csv(filename, x, yerrs_syst=None, delimiter=',', header=None, fmt=None, comments='')

Parameters

filenamestr, required

Output file name

xlist, required

Graph x values with shape (nbins)

yerr_systlist, optional

Graph y systematic error values decomposed into the different sources of systematic error with shape (nbins,nsources) or (nbins,nsources,2)

delimiterstr, optional

CSV format delimiter

headerstr, optional

CSV header

fmtstr, optional

CSV column formats

commentsstr, optional

CSV comments

Raises

ValueError

Raise an error if the shape of the systematics is does not match (nbins,nsources) or (nbins, nsources,2).

Description

Write a set of graph y systematic errors to a CSV file with the systematic error values broken down by source and allowing high and low errors. This means the argument yerr_syst should have shape (nbins, nsources) or (nbins, nsources,2) where nbins is the number of kinematic bins and nsources is the number of sources of systematic error.

saga.data.save_graph_to_csv(filename, ct, x, y, xerr=None, yerr=None, xerr_syst=None, yerr_syst=None, delimiter=',', header=None, fmt=None, comments='')

Parameters

filenamestr, required

Output file name

ctlist, required

Graph count values with shape (nbins)

xlist, required

Graph x values with shape (nbins)

ylist, required

Graph y values with shape (nbins)

xerrlist, optional

Graph x error values with shape (nbins)

yerrlist, optional

Graph y error values with shape (nbins)

xerr_systlist, optional

Graph x systematic error values with shape (nbins) or (nbins,2)

yerr_systlist, optional

Graph y systematic error values with shape (nbins) or (nbins,2)

delimiterstr, optional

CSV format delimiter

headerstr, optional

CSV header

fmtstr, optional

CSV column formats

commentsstr, optional

CSV comments

Raises

ValueError

Raise an error if the shape of the systematics arrays do not match (nbins) or (nbins,2).

Description

Write a graph to a CSV file with optional errors and systematic errors. Systematic errors may have high and low values.

saga.data.save_txt(filename, data, delimiter=',', header=None, fmt=None, comments='')

Parameters

filenamestr, required

Output file name

dataarray, required

2D data array with dimensions [N_COLUMNS,N_ROWS]

delimiterstr, optional

CSV format delimiter

headerstr, optional

CSV header

fmtstr, optional

CSV column formats

commentsstr, optional

CSV comments

Description

Save a square data array of dimensions [N_COLUMNS,N_ROWS] to a text file.