echidna.output package

Submodules

echidna.output.plot module

echidna.output.plot._produce_axis(spectra, dimension)[source]

This method produces an array that represents the axis.

The array is formed of the value at the bin-centre for each bin along the specified dimension.

Parameters:
  • spectra (echidna.core.spectra.Spectra) – The spectra you wish to produce the axis from.
  • dimension (string) – The dimension you wish to produce the axis for.
Returns:

numpy.array: The values for the axis.

echidna.output.plot._produce_bins(spectra, dimension)[source]

This method produces an array that represents the bin boundaries.

The array is formed of the value at each bin boundary from par._low to par._high along the specified dimension. The length of the array of bin boundaries is one greater than the length of the axis array.

Parameters:
  • spectra (echidna.core.spectra.Spectra) – The spectra you wish to produce the bin boundaries from.
  • dimension (string) – The dimension you wish to produce the bin boundaries for.
Returns:

numpy.array: The values for the axis.

echidna.output.plot.plot_projection(spectra, dimension, fig_num=1, show_plot=True)[source]

Plot the spectra as projected onto the dimension.

For example dimension == 0 will plot the spectra as projected onto the energy dimension.

Parameters:
  • spectra (echidna.core.spectra) – The spectra to plot.
  • dimension (string) – The dimension to project the spectra onto.
  • fig_num (int, optional) – The number of the figure. If you are producing multiple spectral plots automatically, this can be useful to ensure pyplot treats each plot as a separate figure. Default is 1.
  • show_plot (bool, optional) – Displays the plot if true. Default is True.
Returns:

matplotlib.pyplot.figure: Plot of the projection.

echidna.output.plot.plot_surface(spectra, dimension1, dimension2, fig_num=1, show_plot=True, **kwargs)[source]

Plot the two dimensions from spectra as a 2D histogram

Parameters:
  • spectra (echidna.core.spectra) – The spectra to plot.
  • dimension1 (string) – The name of the dimension you want to plot.
  • dimension2 (string) – The name of the dimension you want to plot.
Returns:

matplotlib.pyplot.figure: Plot of the surface of the two dimensions.

echidna.output.plot.spectral_plot(spectra_dict, dimension, fig_num=1, show_plot=True, log_y=False, per_bin=False, limit=None, title=None, text=None, calculator=None)[source]

Produce spectral plot.

For a given signal, produce a plot showing the signal and relevant backgrounds. Backgrounds are automatically summed to create the spectrum ‘Summed background’ and all spectra passed in spectra_dict will be summed to produce the “Sum” spectrum.

Parameters:
  • spectra_dict (dict) – Dictionary containing each spectrum you wish to plot, and the relevant parameters required to plot them.
  • dimension (string) – The dimension you wish to plot.
  • fig_num (int, optional) – The number of the figure. If you are producing multiple spectral plots automatically, this can be useful to ensure pyplot treats each plot as a separate figure. Default is 1.
  • show_plot (bool, optional) – Displays the plot if true. Default is True.
  • log_y – Use log scale on y-axis.
  • limit (spectra.Spectra, optional) – Include a spectrum showing a current or target limit.
  • title (string, optional) – Title of the plot.
  • text (list, optional) – Text to be written on top of plot.

Example

An example spectra_dict is as follows:

{Te130_0n2b._name: {'spectra': Te130_0n2b, 'label': 'signal',
                    'style': {'color': 'blue'}, 'type': 'signal'},
 Te130_2n2b._name: {'spectra': Te130_2n2b, 'label': r'$2\nu2\beta',
                    'style': {'color': 'red'}, 'type': 'background'},
 B8_Solar._name: {'spectra': B8_Solar, 'label': 'solar',
                  'style': {'color': 'green'}, 'type': 'background'}}
Returns:matplotlib.pyplot.figure: Plot of the signal and backgrounds.

echidna.output.plot_chi_squared module

* DEPRECIATED *

Contains functions to view and interrogate chi-squared minimisation

ivar MAIN_FONT:style properties for the main font to use in plot labels
vartype MAIN_FONT:
 dict
echidna.output.plot_chi_squared.chi_squared_map(syst_analyser, fig_num=1, preferred_values=True, minima=True, contours=False, save_as=None)[source]

Plot chi squared surface for systematic vs. signal counts

Parameters:
  • syst_analyser (echidna.limit.limit_setting.SystAnalyser) – A systematic analyser object, created during limit setting. Can be used during limit setting setting or can load an instance from hdf5
  • fig_num (int) – Fig number. When creating multiple plots in the same script, ensures matplotlib doesn’t overwrite them.
  • preferred_values (bool, optional) – if False “preferred values” curve is not overlayed on colour map. Default is True.
  • minima (bool, optional) – if False “minima” are not overlayed on colour map. Default is True.
  • contours (bool, optional) – if True produces a contour plot of chi squared surface. Default is False.
  • save_as (string, optional) – Name of plot to save. All plots are saved with in .png format.
Returns:

matplotlib.pyplot.figure: Plotted figure.

echidna.output.plot_chi_squared.chi_squared_vs_signal(signal_config, converter=None, fig_num=1, n_atoms=None, penalty=None, effective_mass=False, half_life=False, save_as=None, show=False, **kwargs)[source]

Plot the chi squared as a function of signal counts

Parameters:
  • signal_config (echidna.limit.limit_config.LimitConfig) – Signal config class, where chi squareds have been stored.
  • converter (echidna.calc.decay.DBIsotope, optional) – Converter used to convert between counts and half-life/effective mass.
  • fig_num (int) – Fig number. When creating multiple plots in the same script, ensures matplotlib doesn’t overwrite them.
  • n_atoms – Number of atoms for converter to use in calculations of half life or effective mass.
  • effective_mass (bool, optional) – if True, plot the x-axis as the signal contribution effective mass.
  • half_life (bool, optional) – if True, plot the x-axis as the signal contribution half life.
  • save_as (string, optional) – Name of plot to save. All plots are saved in .png format.
  • show (bool, optional) – Display the plot to screen. Default is False.
Raises:

TypeError – If ‘half_life’ or ‘effective_mass’ keyword arguments are used without echidna.calc.decay.DBIsotope object to use as converter.

Returns:

matplotlib.pyplot.figure: Plotted figure.

echidna.output.plot_chi_squared.main(args)[source]

Script to produce chi squared plots for a given systematic.

Note

Produces

  • Plot of chi squared vs. signal counts
  • Plot of systematic vs. signal chi squared surface, either contour plot or color map
  • Plot of systematic value vs. penalty term value
Parameters:args (dict) – command line arguments from argparse.
echidna.output.plot_chi_squared.penalty_vs_systematic(syst_analyser, fig_num=1, save_as=None)[source]

Plot penalty_value vs. systematic

Parameters:
  • syst_analyser (echidna.limit.limit_setting.SystAnalyser) – A systematic analyser object, created during limit setting. Can be used during limit setting setting or can load an instance from hdf5
  • fig_num (int, optional) – Fig number. When creating multiple plots in the same script, ensures matplotlib doesn’t overwrite them.
  • save_as (string, optional) – Name of plot to save. All plots are saved with in .png format.
Returns:

matplotlib.pyplot.figure: Plotted figure.

echidna.output.plot_chi_squared.push_pull(syst_analyser, fig=1, save_as=None)[source]

Plot penalty value - poisson likelihood chi squared.

When does minimising chi squared, which wants to “pull” the away from the data/prior value dominate and when does the penalty term, which wants to “pull” towards the data/prior, constraining the fit dominate?

Parameters:
  • syst_analyser (echidna.limit.limit_setting.SystAnalyser) – A systematic analyser object, created during limit setting. Can be used during limit setting setting or can load an instance from hdf5
  • fig_num (int) – Fig number. When creating multiple plots in the same script, ensures matplotlib doesn’t overwrite them.
  • save_as (string, optional) – Name of plot to save. All plots are saved with in .png format.
Returns:

matplotlib.pyplot.figure: Plotted figure.

echidna.output.plot_chi_squared.turn_on(syst_analyser, signal_config, fig=1, save_as=None)[source]

Plot deviation from chi-squared with no floated systematics.

When does the effect of floating the systematic “turn on”?

Parameters:
  • syst_analyser (echidna.limit.limit_setting.SystAnalyser) – A systematic analyser object, created during limit setting. Can be used during limit setting setting or can load an instance from hdf5.
  • signal_config (echidna.limit.limit_config.LimitConfig) – Signal config class, where chi squareds have been stored.
  • fig_num (int) – Fig number. When creating multiple plots in the same script, ensures matplotlib doesn’t overwrite them.
  • save_as (string, optional) – Name of plot to save. All plots are saved with in .png format.
Returns:

matplotlib.pyplot.figure: Plotted figure.

echidna.output.plot_chi_squared_root module

echidna.output.plot_chi_squared_root.chi_squared_vs_half_life(signal_config, converter)[source]

Plot the chi squared as a function of signal counts

Parameters:
  • signal_config (echidna.limit.limit_config.LimitConfig) – signal config class, where chi squareds have been stored.
  • converter (echidna.calc.decay.DBIsotope, optional) – Converter used to convert between counts and half-life/effective mass.
Returns:

ROOT.TGraph: Plot.

echidna.output.plot_chi_squared_root.chi_squared_vs_mass(signal_config, converter)[source]

Plot the chi squared as a function of signal counts

Parameters:
  • signal_config (echidna.limit.limit_config.LimitConfig) – signal config class, where chi squareds have been stored.
  • converter (echidna.calc.decay.DBIsotope, optional) – Converter used to convert between counts and half-life/effective mass.
Returns:

ROOT.TGraph: Plot.

echidna.output.plot_chi_squared_root.chi_squared_vs_signal(signal_config)[source]

Plot the chi squared as a function of signal counts

Parameters:signal_config (echidna.limit.limit_config.LimitConfig) – signal config class, where chi squareds have been stored.
Returns:ROOT.TGraph: Plot.

echidna.output.plot_root module

echidna.output.plot_root.plot_best_fit_vs_scale(summary, graphical=True)[source]
Plots the best fit of the parameter vs signal scales as a
ROOT.TGraph object.
Parameters:
  • summary (echidna.limit.summary.Summary) – The summary object which contains the data.
  • graphical (bool, optionl) – Plots hist to screen if True. Default is False.
Returns:

ROOT.TGraph: The plot.

echidna.output.plot_root.plot_chi_squared_per_bin(calculator, x_bins, x_low, x_high, x_title=None, graphical=False, h_name=None)[source]

Produces a histogram of chi-squared per bin.

Parameters:
  • calculator (echidna.limit.chi_squared.ChiSquared) – Calculator containing the chi-squared values to plot.
  • x_bins (int) – Number of bins.
  • x_low (float) – Lower edge of first bin to plot.
  • x_high (float) – Upper edge of last bin to plot.
  • x_title (string, optional) – X Axis title.
  • graphical (bool, optionl) – Plots hist to screen if True. Default is False.
Returns:

ROOT.TH1D: Histogram of chi-squared per bin.

echidna.output.plot_root.plot_penalty_term_vs_scale(summary, graphical=True)[source]
Plots the contribution of the penalty term to the test statistic for
the parameter vs signal scales as a ROOT.TGraph object.
Parameters:
  • summary (echidna.limit.summary.Summary) – The summary object which contains the data.
  • graphical (bool, optionl) – Plots hist to screen if True. Default is False.
Returns:

ROOT.TGraph: The plot.

echidna.output.plot_root.plot_projection(spectra, dimension, graphical=True, fig_num=1, h_name=None)[source]

Plot the spectra as projected onto the dimension.

Parameters:
  • spectra (echidna.core.spectra) – The spectra to plot.
  • dimension (string) – The dimension to project the spectra onto.
  • graphical (bool, optional) – Displays plot if True. Default is True.
Returns:

(ROOT.TH1D): Root histogram of the projection onto

the given dimension.

(ROOT.TCanvas): Root canvas object containing plot of

histogram.

echidna.output.plot_root.plot_sigma_best_fit_vs_scale(summary, graphical=True)[source]
Plots the best fit in term of number of sigma away from the prior of
the parameter vs signal scales as a ROOT.TGraph object.
Parameters:
  • summary (echidna.limit.summary.Summary) – The summary object which contains the data.
  • graphical (bool, optionl) – Plots hist to screen if True. Default is False.
Returns:

ROOT.TGraph: The plot.

echidna.output.plot_root.plot_stats_vs_scale(summary, graphical=True)[source]
Plots the test statistics vs signal scales as a ROOT.TGraph
object.
Parameters:
  • summary (echidna.limit.summary.Summary) – The summary object which contains the data.
  • graphical (bool, optionl) – Plots hist to screen if True. Default is False.
Returns:

ROOT.TGraph: The plot.

echidna.output.plot_root.plot_surface(spectra, dimension1, dimension2, graphical=True, h_name=None)[source]

Plots a 2D histogram of the dimensions in spectra.

Parameters:
  • spectra (echidna.core.spectra) – The spectra to plot.
  • dimension1 (string) – The dimension to plot.
  • dimension2 (string) – The dimension to plot.
  • graphical (bool, optional) – Displays plot if True. Default is True.
Returns:

(ROOT.TH2D): Root 2D histogram of the spectra surface

projection.

(ROOT.TCanvas): Root canvas object containing plot of

histogram.

echidna.output.plot_root.spectral_plot(spectra_dict, dimension='energy', show_plot=False, log_y=False, limit=None)[source]

Produce spectral plot.

For a given signal, produce a plot showing the signal and relevant backgrounds. Backgrounds are automatically summed to create the spectrum “Summed background” and all spectra passed in spectra_dict will be summed to produce the “Sum” spectra

Parameters:
  • spectra_dict (dict) – Dictionary containing each spectrum you wish to plot, and the relevant parameters required to plot them.
  • dimension (string, optional) – The dimension or axis along which the spectra should be plotted. Default is energy.
  • show_plot (bool, optional) – Displays plot if True. Default is False.
  • log_y (bool, optional) – Use log scale on y-axis.
  • limit (spectra.Spectra) – Include a spectrum showing a current or target limit.

Example

An example spectra_dict is as follows:

{Te130_0n2b._name: {'spectra': Te130_0n2b,
                    'label': 'signal',
                    'style': {'color': ROOT.kBlue},
                    'type': 'signal'},
 Te130_2n2b._name: {'spectra': Te130_2n2b,
                    'label': r'$2\nu2\beta',
                    'style': {'color': ROOT.kRed},
                    'type': 'background'},
 B8_Solar._name: {'spectra': B8_Solar,
                  'label': 'solar',
                  'style': {'color': ROOT.kGreen},
                  'type': 'background'}}
Returns:ROOT.TCanvas: Canvas containing spectral plot.

echidna.output.root_style module

echidna.output.root_style.root_style(font=132)[source]

Sets the style for ROOT plots. The SNO+ standard style is adapted from a .C sent to collaboration.

Parameters:font (int) – Integer denoting the font style for plots. Default is 132. See https://root.cern.ch/root/html/TAttText.html for details.
echidna.output.root_style.set_ticks(can)[source]

Display ticks on the upper and right axes.

Parameters:can (ROOT.TCanvas) – Canvas to set ticks on.

echidna.output.store module

echidna.output.store._load_old(file_path)[source]

Load a spectra from file_path.

Parameters:file_path (string) – Location to save to.
Returns:Loaded spectra (spectra.Spectra).
echidna.output.store.dict_to_string(in_dict)[source]

* DEPRECIATED * Converts a dicionary to a string so it can be saved in a hdf5 file.

Parameters:in_dict (dict) – Dictionary to convert.
Raises:TypeError – If the type of a value of in_dict is not supported currently. Supported types are string, float and int.
Returns:The converted dictionary.
Return type:string
echidna.output.store.dump(file_path, spectrum, append=False, group_name='spectrum')[source]

Dump the spectrum to the file_path.

Parameters:
  • file_path (string) – Location to save to.
  • spectrum (spectra.Spectra) – The spectrum to save
echidna.output.store.dump_ndarray(file_path, ndarray_object)[source]

Dump any other class, mostly containing numpy arrays.

Parameters:
  • file_path (string) – Location to save to.
  • ndarray_object (object) – Any class instance mainly consisting of numpy array(s).
Raises:

AttributeError – If attribute in not an ndarray and is larger than 64k - h5py limit for attribute sizes.

echidna.output.store.dump_summary(file_path, summary, append=False, group_name='summary')[source]

Dump the limit setting summary to the file_path.

Parameters:
  • file_path (string) – Location to save to.
  • summary (echdina.limit.summary.Summary) – The summary to save
echidna.output.store.load(file_path, group_name='spectrum')[source]

Load a spectrum from file_path.

Parameters:file_path (string) – Location to save to.
Returns:Loaded spectrum (spectra.Spectra).
echidna.output.store.load_ndarray(file_path, ndarray_object)[source]

Dump any other class, mostly containing numpy arrays.

Parameters:
  • file_path (string) – Location to load class attributes from.
  • array_object (object) – Any class instance mainly consisting of numpy array(s).
echidna.output.store.load_summary(file_path, group_name='summary')[source]

Load a limit setting summary from file_path.

Parameters:file_path (string) – Location to load from.
Returns:Summary: The Summary object.
echidna.output.store.string_to_dict(in_string)[source]

* DEPRECIATED * Converts a string to a dictionary so it can be loaded from the hdf5 file.

Parameters:in_string (string) – The string to convert into a dictionary.
Raises:TypeError – If the type of a value of in_dict is not supported currently. Supported types are string, float and int.
Returns:The converted string.
Return type:dict

Module contents