Belle II Software
release-08-01-10
|
Public Member Functions | |
def | __init__ (self, name, referenceFileName=None) |
def | hist (self, xs, weights=None, stackby=None, bins=None, lower_bound=None, upper_bound=None, outlier_z_score=None, include_exceptionals=True, allow_discrete=False, cumulation_direction=None, is_expert=True) |
def | profile (self, xs, ys, weights=None, stackby=None, bins=None, lower_bound=None, upper_bound=None, y_binary=None, y_log=None, outlier_z_score=None, include_exceptionals=True, allow_discrete=False, cumulation_direction=None, gaus_z_score=None, is_expert=True, is_asymmetry=False) |
def | scatter (self, xs, ys, stackby=None, lower_bound=(None, None), upper_bound=(None, None), outlier_z_score=(None, None), include_exceptionals=(True, True), max_n_data=100000, is_expert=True) |
def | grapherrors (self, xs_and_err, ys_and_err, stackby=None, lower_bound=(None, None), upper_bound=(None, None), outlier_z_score=(None, None), include_exceptionals=(True, True), max_n_data=100000, is_expert=True) |
def | hist2d (self, xs, ys, weights=None, stackby=None, bins=(None, None), lower_bound=(None, None), upper_bound=(None, None), outlier_z_score=(None, None), include_exceptionals=(True, True), allow_discrete=(False, False), quantiles=None, is_expert=True) |
def | fit_gaus (self, z_score=None) |
def | fit_line (self) |
def | fit_const (self) |
def | fit_diag (self) |
def | fit (self, formula, options, lower_bound=None, upper_bound=None, z_score=None) |
def | show (self) |
def | write (self, tdirectory=None) |
def | is_expert (self) |
def | title (self) |
def | title (self, title) |
def | xlabel (self) |
def | xlabel (self, xlabel) |
def | ylabel (self) |
def | ylabel (self, ylabel) |
def | contact (self) |
def | contact (self, contact) |
def | description (self) |
def | description (self, description) |
def | check (self) |
def | check (self, check) |
def | create_1d (self, th1_factory, xs, ys=None, weights=None, bins=None, stackby=None, lower_bound=None, upper_bound=None, outlier_z_score=None, include_exceptionals=True, allow_discrete=False, cumulation_direction=None) |
def | create (self, histogram_template, xs, ys=None, weights=None, stackby=None, cumulation_direction=None, reverse_stack=None) |
def | create_stack (cls, histograms, name, reverse_stack, force_graph=False) |
def | convert_tprofile_to_tgrapherrors (cls, tprofile, abs_x=False) |
def | fill_into_grouped (self, histogram_template, xs, ys=None, weights=None, groupbys=None, groupby_label="group") |
def | set_color (self, tobject, root_i_color) |
def | fill_into (self, plot, xs, ys=None, weights=None, filter=None) |
def | fill_into_tgrapherror (self, graph, xs, ys, filter=None) |
def | fill_into_tgraph (self, graph, xs, ys, filter=None) |
def | fill_into_th1 (self, histogram, xs, ys=None, weights=None, filter=None) |
def | add_nan_inf_stats (cls, histogram, name, xs) |
def | add_stats_entry (cls, histogram, label, value) |
def | get_additional_stats (cls, histogram) |
def | gaus_slice_fit (cls, th2, name, z_score=None) |
def | cumulate (cls, histogram, cumulation_direction=None) |
def | determine_bin_edges (self, xs, stackbys=None, bins=None, lower_bound=None, upper_bound=None, outlier_z_score=None, include_exceptionals=True, allow_discrete=False) |
def | determine_bin_range (self, xs, stackbys=None, n_bins=None, lower_bound=None, upper_bound=None, outlier_z_score=None, include_exceptionals=True) |
def | determine_range (self, xs, lower_bound=None, upper_bound=None, outlier_z_score=None, include_exceptionals=True) |
def | set_additional_stats_tf1 (cls, histogram) |
def | set_fit_tf1 (cls, histogram, fit_tf1) |
def | set_tf1 (cls, histogram, tf1) |
def | delete_tf1 (cls, histogram) |
def | create_additional_stats_tf1 (cls, histogram) |
def | combine_fit_and_additional_stats (cls, fit_tf1, additional_stats_tf1) |
def | copy_tf1_parameters (cls, tf1_source, tf1_target, offset=0) |
def | attach_attributes (self) |
def | set_maximum (self, maximum) |
def | set_minimum (self, minimum) |
def | set_tstyle (cls) |
Static Public Member Functions | |
def | unpack_2d_param (param) |
def | is_binary (xs) |
def | is_discrete (xs, max_n_unique=None) |
def | get_exceptional_values (xs) |
def | get_robust_mean_and_std (xs) |
def | format_bin_label (value) |
Public Attributes | |
name | |
A unique name to be used as the name of the ROOT object to be generated. | |
referenceFileName | |
name of the reference file, if not None the binning will be read from there | |
plot | |
The main plot object, may contain one or more (in case of stacked pltos) histograms. | |
histograms | |
A list of the histograms that make up the plot. | |
pvalue_warn | |
custom levels for pvalue warnings | |
pvalue_error | |
custom levels for pvalue errors | |
y_log | |
Indicator whether the y axes should be displayed as a log scale. | |
ylabel | |
default label for the histogram's Y axis More... | |
lower_bound | |
lower left corner of the histogram | |
upper_bound | |
upper right corner of the hisogram | |
check | |
cached value of the user-check action for this plot | |
contact | |
contact information for this plot | |
description | |
description of the plot | |
xlabel | |
cached value of the x-axis label for this plot | |
title | |
cached value of the title for this plot | |
Static Public Attributes | |
int | very_sparse_dots_line_style_index = 28 |
A an index that reference to a dot spacing such that the line is almost invisible for scatter. | |
Private Attributes | |
_description | |
Description of the plot purpose for display on the validation page. | |
_check | |
Detailed check instructions for display on the validation page. | |
_contact | |
Contact email address for display on the validation page. | |
_xlabel | |
X axes label of the validation plot. | |
_ylabel | |
Y axes label of the validation plot. | |
_title | |
Title of the validation plot. | |
_is_expert | |
per default all plots are expert and must be set to non-expert explicitly | |
Class for generating a validation plot for the Belle II validation page. Typically it generates plots from values stored in numpy arrays and feeds them into plot ROOT classes for storing them. It implements an automatic binning procedure based on the rice rule and robust z score outlier detection. It also keeps track of additional statistics typically neglected by ROOT such as a count for the non finit values such as NaN, +Inf, -Inf. The special attributes for the Belle II validation page like * title * contract * description * check are exposed as properties of this class.
def __init__ | ( | self, | |
name, | |||
referenceFileName = None |
|||
) |
Constructor of the ValidationPlot Parameters ---------- name : str A unique name to be used as the name of the ROOT object to be generated referenceFileName : str name of a reference file. If set the code will try to get the histogram or profile from that file and determine the number of bins and upper and lower bound (so far only implemented for 1D (TH1, TProfile), is ignored for 2D plots)
Definition at line 185 of file plot.py.
def add_nan_inf_stats | ( | cls, | |
histogram, | |||
name, | |||
xs | |||
) |
Extracts the counts of non finite floats from a series and adds them as additional statistics to the histogram. Parameters ---------- histogram : derived from ROOT.TH1 or ROOT.TGraph Something having a GetListOfFunctions method that name : str A label for the data series to be prefixed to the entries. xs : numpy.ndarray (1d) Data from which the non finit floats should be counted.
def add_stats_entry | ( | cls, | |
histogram, | |||
label, | |||
value | |||
) |
Add a new additional statistics to the histogram. Parameters ---------- histogram : derived from ROOT.TH1 or ROOT.TGraph Something having a GetListOfFunctions method that holds the additional statistics label : str Label of the statistic value : float Value of the statistic
def attach_attributes | ( | self | ) |
def check | ( | self | ) |
def check | ( | self, | |
check | |||
) |
def combine_fit_and_additional_stats | ( | cls, | |
fit_tf1, | |||
additional_stats_tf1 | |||
) |
Combine the fit function and the function carrying the additional statistics to one function. Parameters ---------- fit_tf1 : ROOT.TF1 The fit function additional_stats_tf1 : ROOT.TF1 The function carrying the additional statistics as parameters Returns ------- ROOT.TF1
def contact | ( | self | ) |
def contact | ( | self, | |
contact | |||
) |
def convert_tprofile_to_tgrapherrors | ( | cls, | |
tprofile, | |||
abs_x = False |
|||
) |
def copy_tf1_parameters | ( | cls, | |
tf1_source, | |||
tf1_target, | |||
offset = 0 |
|||
) |
def create | ( | self, | |
histogram_template, | |||
xs, | |||
ys = None , |
|||
weights = None , |
|||
stackby = None , |
|||
cumulation_direction = None , |
|||
reverse_stack = None |
|||
) |
def create_1d | ( | self, | |
th1_factory, | |||
xs, | |||
ys = None , |
|||
weights = None , |
|||
bins = None , |
|||
stackby = None , |
|||
lower_bound = None , |
|||
upper_bound = None , |
|||
outlier_z_score = None , |
|||
include_exceptionals = True , |
|||
allow_discrete = False , |
|||
cumulation_direction = None |
|||
) |
def create_additional_stats_tf1 | ( | cls, | |
histogram | |||
) |
Create a TF1 with the additional statistics from the histogram as parameters. Parameters ---------- histogram : ROOT.TH1 or ROOT.TGraph Something having a GetListOfFunctions method that holds the additional statistics. Returns ------- ROOT.TF1 Function with the additional statistics as parameters.
def create_stack | ( | cls, | |
histograms, | |||
name, | |||
reverse_stack, | |||
force_graph = False |
|||
) |
def cumulate | ( | cls, | |
histogram, | |||
cumulation_direction = None |
|||
) |
Cumulates the histogram inplace. Parameters ---------- histogram : ROOT.TH1 or ROOT.TProfile Filled histogram to be cumulated cumulation_direction : int, optional Direction is indicated by the sign. Positive means from left to right, negative means from right to left. If now cumulation direction is given return the histogram as is. Returns ------- ROOT.TH1 Cumulated histogram potentially altered inplace.
def delete_tf1 | ( | cls, | |
histogram | |||
) |
def description | ( | self | ) |
def description | ( | self, | |
description | |||
) |
def determine_bin_edges | ( | self, | |
xs, | |||
stackbys = None , |
|||
bins = None , |
|||
lower_bound = None , |
|||
upper_bound = None , |
|||
outlier_z_score = None , |
|||
include_exceptionals = True , |
|||
allow_discrete = False |
|||
) |
Deducing bin edges from a data series. Parameters ---------- xs : numpy.ndarray (1d) Data point for which a binning should be found. stackbys : numpy.ndarray (1d) Categories of the data points to be distinguishable bins : list(float) or int or None, optional Preset bin edges or preset number of desired bins. The default, None, means the bound should be extracted from data. The rice rule is used the determine the number of bins. If a list of floats is given return them immediatly. lower_bound : float or None, optional Preset lower bound of the binning range. The default, None, means the bound should be extracted from data. upper_bound : float or None, optional Preset upper bound of the binning range. The default, None, means the bound should be extracted from data. outlier_z_score : float or None, optional Threshold z-score of outlier detection. The default, None, means no outlier detection. include_exceptionals : bool, optional If the outlier detection is active this switch indicates, if values detected as exceptionally frequent shall be included nevertheless into the binning range. Default is True, which means exceptionally frequent values as included even if they are detected as outliers. Returns ------- np.array (1d), list(str) Pair of bin edges and labels deduced from the series. Second element is None if the series is not detected as discrete.
def determine_bin_range | ( | self, | |
xs, | |||
stackbys = None , |
|||
n_bins = None , |
|||
lower_bound = None , |
|||
upper_bound = None , |
|||
outlier_z_score = None , |
|||
include_exceptionals = True |
|||
) |
Calculates the number of bins, the lower bound and the upper bound from a given data series estimating the values that are not given. If the outlier_z_score is given the method tries to exclude outliers that exceed a certain z-score. The z-score is calculated (x - x_mean) / x_std. The be robust against outliers the necessary mean and std deviation are based on truncated mean and a trimmed std calculated from the inter quantile range (IQR). If additional include_exceptionals is true the method tries to find exceptional values in the series and always include them in the range if it finds any. Exceptional values means exact values that appear often in the series for whatever reason. Possible reasons include * Interal / default values * Failed evaluation conditions * etc. which should be not cropped away automatically if you are locking on the quality of your data. Parameters ---------- xs : numpy.ndarray (1d) Data point for which a binning should be found. stackbys : numpy.ndarray (1d) Categories of the data points to be distinguishable n_bins : int or None, optional Preset number of desired bins. The default, None, means the bound should be extracted from data. The rice rule is used the determine the number of bins. lower_bound : float or None, optional Preset lower bound of the binning range. The default, None, means the bound should be extracted from data. upper_bound : float or None, optional Preset upper bound of the binning range. The default, None, means the bound should be extracted from data. outlier_z_score : float or None, optional Threshold z-score of outlier detection. The default, None, means no outlier detection. include_exceptionals : bool, optional If the outlier detection is active this switch indicates, if values detected as exceptionally frequent shall be included nevertheless into the binning range. Default is True, which means exceptionally frequent values as included even if they are detected as outliers. Returns ------- n_bins, lower_bound, upper_bound : int, float, float A triple of found number of bins, lower bound and upper bound of the binning range.
def determine_range | ( | self, | |
xs, | |||
lower_bound = None , |
|||
upper_bound = None , |
|||
outlier_z_score = None , |
|||
include_exceptionals = True |
|||
) |
Parameters ---------- xs : numpy.ndarray (1d) Data point for which a binning should be found. lower_bound : float or None, optional Preset lower bound of the binning range. The default, None, means the bound should be extracted from data. upper_bound : float or None, optional Preset upper bound of the binning range. The default, None, means the bound should be extracted from data. outlier_z_score : float or None, optional Threshold z-score of outlier detection. The default, None, means no outlier detection. include_exceptionals : bool, optional If the outlier detection is active this switch indicates, if values detected as exceptionally frequent shall be included nevertheless into the binning range. Default is True, which means exceptionally frequent values as included even if they are detected as outliers. Returns ------- lower_bound, upper_bound : float, float A pair of found lower bound and upper bound of series.
def fill_into | ( | self, | |
plot, | |||
xs, | |||
ys = None , |
|||
weights = None , |
|||
filter = None |
|||
) |
def fill_into_grouped | ( | self, | |
histogram_template, | |||
xs, | |||
ys = None , |
|||
weights = None , |
|||
groupbys = None , |
|||
groupby_label = "group" |
|||
) |
def fill_into_tgraph | ( | self, | |
graph, | |||
xs, | |||
ys, | |||
filter = None |
|||
) |
def fill_into_tgrapherror | ( | self, | |
graph, | |||
xs, | |||
ys, | |||
filter = None |
|||
) |
def fill_into_th1 | ( | self, | |
histogram, | |||
xs, | |||
ys = None , |
|||
weights = None , |
|||
filter = None |
|||
) |
Fill the histogram blocking non finite values Parameters ---------- histogram : ROOT.TH1 The histogram to be filled xs : numpy.ndarray (1d) Data for the first axes ys : numpy.ndarray (1d), optional Data for the second axes weights : numpy.ndarray (1d), optional Weight of the individual points. Defaults to one for each filter : numpy.ndarray, optional Boolean index array indicating which entries shall be taken.
def fit | ( | self, | |
formula, | |||
options, | |||
lower_bound = None , |
|||
upper_bound = None , |
|||
z_score = None |
|||
) |
Fit a user defined function to a one dimensional histogram Parameters ---------- formula : str or TF1 Formula string or TH1 to be fitted. See TF1 constructurs for that is a valid formula options : str Options string to be used in the fit. See TH1::Fit() lower_bound : float Lower bound of the range to be fitted upper_bound : float Upper bound of the range to be fitted
def fit_const | ( | self | ) |
def fit_diag | ( | self | ) |
def fit_gaus | ( | self, | |
z_score = None |
|||
) |
Fit a gaus belle curve to the central portion of a one dimensional histogram The fit is applied to the central mean +- z_score * std interval of the histogram, such that it is less influence by non gaussian tails further away than the given z score. @param float z_score number of sigmas to include from the mean value of the histogram.
def fit_line | ( | self | ) |
|
static |
def gaus_slice_fit | ( | cls, | |
th2, | |||
name, | |||
z_score = None |
|||
) |
def get_additional_stats | ( | cls, | |
histogram | |||
) |
Get the additional statistics from the histogram and return them a dict. Parameters ---------- histogram : derived from ROOT.TH1 or ROOT.TGraph Something having a GetListOfFunctions method that holds the additional statistics Returns ------- collection.OrderedDict A map of labels to values for the additional statistics
|
static |
|
static |
def grapherrors | ( | self, | |
xs_and_err, | |||
ys_and_err, | |||
stackby = None , |
|||
lower_bound = (None, None) , |
|||
upper_bound = (None, None) , |
|||
outlier_z_score = (None, None) , |
|||
include_exceptionals = (True, True) , |
|||
max_n_data = 100000 , |
|||
is_expert = True |
|||
) |
def hist | ( | self, | |
xs, | |||
weights = None , |
|||
stackby = None , |
|||
bins = None , |
|||
lower_bound = None , |
|||
upper_bound = None , |
|||
outlier_z_score = None , |
|||
include_exceptionals = True , |
|||
allow_discrete = False , |
|||
cumulation_direction = None , |
|||
is_expert = True |
|||
) |
def hist2d | ( | self, | |
xs, | |||
ys, | |||
weights = None , |
|||
stackby = None , |
|||
bins = (None, None) , |
|||
lower_bound = (None, None) , |
|||
upper_bound = (None, None) , |
|||
outlier_z_score = (None, None) , |
|||
include_exceptionals = (True, True) , |
|||
allow_discrete = (False, False) , |
|||
quantiles = None , |
|||
is_expert = True |
|||
) |
|
static |
|
static |
def is_expert | ( | self | ) |
def profile | ( | self, | |
xs, | |||
ys, | |||
weights = None , |
|||
stackby = None , |
|||
bins = None , |
|||
lower_bound = None , |
|||
upper_bound = None , |
|||
y_binary = None , |
|||
y_log = None , |
|||
outlier_z_score = None , |
|||
include_exceptionals = True , |
|||
allow_discrete = False , |
|||
cumulation_direction = None , |
|||
gaus_z_score = None , |
|||
is_expert = True , |
|||
is_asymmetry = False |
|||
) |
def scatter | ( | self, | |
xs, | |||
ys, | |||
stackby = None , |
|||
lower_bound = (None, None) , |
|||
upper_bound = (None, None) , |
|||
outlier_z_score = (None, None) , |
|||
include_exceptionals = (True, True) , |
|||
max_n_data = 100000 , |
|||
is_expert = True |
|||
) |
def set_additional_stats_tf1 | ( | cls, | |
histogram | |||
) |
Combining fit TF1 with the additional statistics and attach them to the histogram. Parameters ---------- histogram : ROOT.TH1 or ROOT.TGraph or ROOT.TMultiGraph Something having a GetListOfFunctions method that should hold the combined fit and additional statistics function.
def set_color | ( | self, | |
tobject, | |||
root_i_color | |||
) |
Set the color of the ROOT object. By default the line color of a TGraph should be invisible, so do not change it For other objects set the marker and the line color Parameters ---------- tobject : Plotable object inheriting from TAttLine and TAttMarker such as TGraph or TH1 Object of which the color should be set. root_i_color : int Color index of the ROOT color table
def set_fit_tf1 | ( | cls, | |
histogram, | |||
fit_tf1 | |||
) |
Combining fit TF1 with the additional statistics and attach them to the histogram. Parameters ---------- histogram : ROOT.TH1 or ROOT.TGraph or ROOT.TMultiGraph Something having a GetListOfFunctions method that should hold the combined fit and additional statistics function.
def set_maximum | ( | self, | |
maximum | |||
) |
def set_minimum | ( | self, | |
minimum | |||
) |
def set_tf1 | ( | cls, | |
histogram, | |||
tf1 | |||
) |
def set_tstyle | ( | cls | ) |
|
static |
Unpacks a function parameter for the two dimensional plots. If it is a pair the first parameter shall apply to the x coordinate the second to the y coordinate. In this case the pair is returned as two values If something else is given the it is assumed that this parameter should equally apply to both coordinates. In this case the same values is return twice as a pair. Parameters ---------- param : pair or single value Function parameter for a two dimensional plot Returns ------- pair A pair of values being the parameter for the x coordinate and the y coordinate respectively
def write | ( | self, | |
tdirectory = None |
|||
) |
def xlabel | ( | self, | |
xlabel | |||
) |
def ylabel | ( | self, | |
ylabel | |||
) |
ylabel |