skyllh.core.utils package
Submodules
skyllh.core.utils.multidimgridpdf module
This module contains utility functions for creating and managing MultiDimGridPDF instances.
- skyllh.core.utils.multidimgridpdf.kde_pdf_sig_spatial_norm_factor_func(pdf, tdm, fitparams)
This is the standard normalization factor function for the spatial signal MultiDimGridPDF, which is created from KDE PDF values. It can be used for the
norm_factor_func
argument of thecreate_MultiDimGridPDF_from_kde_pdf
function.
- skyllh.core.utils.multidimgridpdf.kde_pdf_bkg_norm_factor_func(pdf, tdm, fitparams)
This is the standard normalization factor function for the background MultiDimGridPDF, which is created from KDE PDF values. It can be used for the
norm_factor_func
argument of thecreate_MultiDimGridPDF_from_kde_pdf
function.
- skyllh.core.utils.multidimgridpdf.create_MultiDimGridPDF_from_photosplinetable(ds, data, info_key, splinetable_key, norm_factor_func=None, kind=None, tl=None)
Creates a MultiDimGridPDF instance with pdf values taken from photospline pdf, a spline interpolation of KDE PDF values stored in a splinetable on disk.
- Parameters:
ds (Dataset instance) – The Dataset instance the PDF applies to.
data (DatasetData instance) – The DatasetData instance that holds the auxiliary data of the data set.
info_key (str) – The auxiliary data name for the file containing PDF information.
splinetable_key (str) – The auxiliary data name for the name of the splinetablefile.
norm_factor_func (callable | None) –
The normalization factor function. It must have the following call signature:
__call__(pdf, tdm, fitparams)
kind (str | None) – The kind of PDF to create. This is either
'sig'
for a SignalMultiDimGridPDF or'bkg'
for a BackgroundMultiDimGridPDF instance. If set to None, a MultiDimGridPDF instance is created.tl (TimeLord instance | None) – The optional TimeLord instance to use for measuring timing information.
- Returns:
pdf (SignalMultiDimGridPDF instance | BackgroundMultiDimGridPDF instance |) – MultiDimGridPDF instance The created PDF instance. Depending on the
kind
argument, this is a SignalMultiDimGridPDF, a BackgroundMultiDimGridPDF, or a MultiDimGridPDF instance.
- skyllh.core.utils.multidimgridpdf.create_MultiDimGridPDF_from_kde_pdf(ds, data, numerator_key, denumerator_key=None, norm_factor_func=None, kind=None, tl=None)
Creates a MultiDimGridPDF instance with pdf values taken from KDE PDF values stored in the dataset’s auxiliary data.
- Parameters:
ds (Dataset instance) – The Dataset instance the PDF applies to.
data (DatasetData instance) – The DatasetData instance that holds the auxiliary data of the data set.
numerator_key (str) – The auxiliary data name for the PDF numerator array.
denumerator_key (str | None) – The auxiliary data name for the PDF denumerator array. This can be None, if no denumerator array is required.
norm_factor_func (callable | None) –
The normalization factor function. It must have the following call signature:
__call__(pdf, tdm, fitparams)
kind (str | None) – The kind of PDF to create. This is either
'sig'
for a SignalMultiDimGridPDF or'bkg'
for a BackgroundMultiDimGridPDF instance. If set to None, a MultiDimGridPDF instance is created.tl (TimeLord instance | None) – The optional TimeLord instance to use for measuring timing information.
- Returns:
pdf (SignalMultiDimGridPDF instance | BackgroundMultiDimGridPDF instance |) – MultiDimGridPDF instance The created PDF instance. Depending on the
kind
argument, this is a SignalMultiDimGridPDF, a BackgroundMultiDimGridPDF, or a MultiDimGridPDF instance.
skyllh.core.utils.ndphotosplinepdf module
This module contains utility functions for creating and managing NDPhotosplinePDF instances.
- skyllh.core.utils.ndphotosplinepdf.create_NDPhotosplinePDF_from_photosplinefit(ds, kind, info_key, splinefit_key, param_set=None, norm_factor_func=None, tl=None)
Creates a new NDPhotosplinePDF instance from a photospline fits file that is defined in the given data set.
- Parameters:
ds (Dataset instance) – The Dataset instance the PDF applies to.
kind (str | None) – The kind of PDF to create. This is either
'sig'
for a SignalNDPhotosplinePDF, or'bkg'
for a BackgroundNDPhotosplinePDF instance. If set to None, a NDPhotosplinePDF instance is created.info_key (str) – The auxiliary data name for the file containing PDF meta data information.
splinefit_key (str) – The auxiliary data name defining the path to the file containing the photospline fit.
param_set (Parameter | ParameterSet | None) – The Parameter instance or ParameterSet instance defining the parameters of the new PDF. The ParameterSet holds the information which parameters are fixed and which are floating (i.e. fitted).
norm_factor_func (callable | None) –
The normalization factor function. It must have the following call signature:
__call__(pdf, tdm, params)
tl (TimeLord instance | None) – The optional TimeLord instance to use for measuring timing information.
- Returns:
pdf (SignalNDPhotosplinePDF instance |) – BackgroundNDPhotosplinePDF instance | NDPhotosplinePDF instance The created PDF instance. Depending on the
kind
argument, this is a SignalNDPhotosplinePDF, a BackgroundNDPhotosplinePDF, or a NDPhotosplinePDF instance.
skyllh.core.utils.trials module
This module contains utility functions related analysis trials.
- skyllh.core.utils.trials.create_pseudo_data_file(ana, rss, filename, mean_n_bkg_list=None, mean_n_sig=0, bkg_kwargs=None, sig_kwargs=None, tl=None)
Creates a pickle file that contains the pseudo data for a single trial.
- Parameters:
ana (Analysis) – The Analysis instance that should be used to generate the pseudo data.
rss (RandomStateService) – The RandomStateService instance to use for generating random numbers.
filename (str) – The data file name into which the generated pseudo data should get written to.
mean_n_bkg_list (list of float | None) – The mean number of background events that should be generated for each dataset. If set to None (the default), the background generation method needs to obtain this number itself.
mean_n_sig (float) – The mean number of signal events that should be generated for the trial. The actual number of generated events will be drawn from a Poisson distribution with this given signal mean as mean.
bkg_kwargs (dict | None) – Additional keyword arguments for the generate_events method of the background generation method class. An usual keyword argument is poisson.
sig_kwargs (dict | None) – Additional keyword arguments for the generate_signal_events method of the SignalGenerator class. An usual keyword argument is poisson.
tl (TimeLord | None) – The instance of TimeLord that should be used to time individual tasks.
- skyllh.core.utils.trials.load_pseudo_data(filename, tl=None)
Loads the pseudo data for a single trial from the given file name.
- Parameters:
filename (str) – The name of the file that contains the pseudo data.
tl (TimeLord | None) – The instance of TimeLord that should be used to time individual tasks.
- Returns:
mean_n_sig (float) – The mean number of signal events that was used to generate the pseudo data.
n_sig (int) – The actual total number of signal events in the pseudo data.
n_bkg_events_list (list of int) – The total number of background events for each data set of the pseudo data.
n_sig_events_list (list of int) – The total number of signal events for each data set of the pseudo data.
bkg_events_list (list of DataFieldRecordArray instances) – The list of DataFieldRecordArray instances containing the background pseudo data events for each data set.
sig_events_list (list of DataFieldRecordArray instances or None) – The list of DataFieldRecordArray instances containing the signal pseudo data events for each data set. If a particular dataset has no signal events, the entry for that dataset can be None.