Reporting and Plotting#
datapipe_testbench.plotting#
Helper functions for plotting.
- class PerformancePoster[source]#
Bases:
objectClass for making a performance poster.
- aeff_rat_compare(ax, ref, others, yscale='linear', **extra_conf)[source]#
Compare effective area metrics using ratio.
- angres_compare(ax, ref, others, yscale='linear', **extra_conf)[source]#
Compare angular resolution metrics.
- angres_rat_compare(ax, ref, others, yscale='linear', **extra_conf)[source]#
Compare angular resolution metrics using ratio.
- bkg_rat_compare(ax, ref, others, yscale='linear', **extra_conf)[source]#
Compare background rate metrics using ratio.
- e_bias_res_compare(ax, ref, others, kind='Energy resolution', yscale='linear', **extra_conf)[source]#
Compare energy resolution and energy bias metrics.
- class SqrtScale(axis)[source]#
Bases:
ScaleBaseScale for bins in theta square or equivalent.
- Parameters:
- axis
Axis The axis for the scale.
- axis
Construct a new scale.
Notes
The following note is for scale implementers.
For back-compatibility reasons, scales take an
Axisobject as first argument. However, this argument should not be used: a single scale object should be usable by multipleAxises at the same time.
- crude_median_plot(ax, metric, yscale='sqrt', xscale='log', scale_min=-1, scale_max=2)[source]#
Plot crude median estimate of histogram.
Takes a
[x,y,z]shape histogram, finds the bin containing the median, and plots the center value of that bin in a 2d plot. Calculates the empirical cumulant, then find median by searching for the bin where the cumulant crosses 1/2.Requires at least 10 counts along z to estimate the median
- make_table_rows(res_dict)[source]#
Transform a result dict containing distance measures to a list that mdutils table function will accept.
- plot_complement_spans(span_dict, is_good_span, xlabel, title_prefix, log=True)[source]#
Make summary plots of a set of spans.
- Parameters:
- span_dict
Dictionary with all necessary information to do the rectangles plots.
- is_good_spanbool
Indicates if a given span shows something positive, colouring it green. If false the span will be painted using a red colour.
- xlabel
- title_prefix
- log
By default, True.
- plot_fail_spans(req_result, xlabel, title_prefix, log=True)[source]#
Make summary plot of ‘fail spans’.
- plot_irf_table(ax, table, column, prefix=None, lo_name=None, hi_name=None, label=None, **mpl_args)[source]#
Easily plot irf table.
- plot_linear_spans(req_result, xlabel, title_prefix, log=True)[source]#
Make summary plot of linear regions.
- plot_spans(ax, spans, y=0, height=0.2, alpha=0.3)[source]#
Easily plot spans found by
datapipe_testbench.stat_helpers.find_positive_spans.
datapipe_testbench.report#
Tools to help write a summary report.
- class Report(*args: Any, **kwargs: Any)[source]#
Bases:
DocumentClass to write a summary of a benchmark to .pdf.
- add_header(level, title)[source]#
Add new section to document.
- Parameters:
- levelint
Level 1-5 of the header to add.
- titlestr
Title for the header.
datapipe_testbench.requirements#
Sub-module to define anything related to requirement checks.
datapipe_testbench.comparers#
Not sure if this will be kept separate.
- class ComparisonResult(name: str, plots: dict, measure: dict | None = None, tests: dict | None = None)[source]#
Bases:
objectPlaceholder class for storing comparisons.
- store(store: ResultStore, metric_id)[source]#
Write the results to disk.
Writes the contained results to the provided
ResultStorein the format most appropriate for each kind of result.
datapipe_testbench.compare_1d#
Classes for comparing 1d metrics in various situations.
- class CompareByCat1D(cat_axis)[source]#
Bases:
objectClass for comparing 1d histograms grouped by category.
- distance_by_category(ref, others)[source]#
Measure the wasserstein distance between ref and comparison histograms grouped by category.
- plot_compare_by_category(ref, others, xscale='linear', yscale='log', density=False, yerr=True, n_cols=None)[source]#
Plot 1d ref and comparison histograms grouped by category.
- plot_compare_by_category_from_method(ref, others, method_name, xscale='linear', yscale='log', density=False, yerr=True, n_cols=None)[source]#
Plot 1d ref and comparison histograms grouped by category.
- plot_compare_tuples_by_category_in_bins(ref, others, bins, ybin_label='energy', ybin_unit='TeV', tup1_label='gammas', tup2_label='protons', density=True, yerr=True)[source]#
Plot two lines from same metric against two lines of other metric.
Takes tuples of metrics with the shape:
[category, bin_property, property]and plots the 1d distribution of property in a given bin from the two tuples into the same axes, making one column of axes per category, and one row per bin value provided.
datapipe_testbench.compare_2d#
Classes for comparing 2d metrics in various situations.
- class CompareByCat2D(cat_axis)[source]#
Bases:
objectClass for comparing 2d histograms grouped by category.
- compare_disp_with_lin(hists, lin_threshold=0.015)[source]#
Compare dispersion matrix with linearity.
Takes a set of 3d histograms with axes [category, x-axis, y-axis], using
x_axas true values, andy_axas reco/true - 1. It computes RMS in each true bin, comparing the result with the provided requirement values assumed to be in same units as the histograms.
- compare_disp_with_req(req_xs, req_ys, hists)[source]#
Compare dispersion matrix with requirements.
Takes a set of 3d histograms with axes [category, x-axis, y-axis], using
x_axas true values, andy_axas reco/true - 1. It computes RMS in each true bin, comparing the result with the provided requirement values assumed to be in same units as the histograms.
- plot_compare_2dhist_mean(ref, others, xscale='log', yscale='linear', **fig_args)[source]#
Compare means of 2d histograms.
- plot_compare_2dhist_rms(ref, others, xscale='log', yscale='linear', **fig_args)[source]#
Compare binwise RMS values, groups by category.
Takes a set of 3d histograms with axes
[category, x-axis, y-axis], for each x-bin an RMS is calculated using the y-values.
- plot_compare_2dhist_rms_with_req(req_xs, req_ys, ref, others, xscale='log', yscale='linear', **fig_args)[source]#
Compare binwise RMS values, groups by category.
Takes a set of 3d histograms with axes [category, x-axis, y-axis], for each x-bin an RMS is calculated using the y-values.
Then it draws the provided requirement values on top.
- plot_compare_cut_disp_by_cat(ref, others, cuts_dict, xscale='log', yscale='linear', **fig_args)[source]#
Plot “dispersion” plots in user defined bins along a third axis.
Takes a set of 4d histograms with axes:
[category, cut_axis, x-axis, y-axis]. and makes a plot grouping by category and further sub-grouping using the providedcuts_dictto split thecut_axis, making 2d histograms for eachcategoryand bin in thecut_axis.
datapipe_testbench.constants#
Constants.