popmon.stitching package

Submodules

popmon.stitching.hist_stitcher module

class popmon.stitching.hist_stitcher.HistStitcher(mode='add', time_axis=None, time_bin_idx=None, read_key=None, delta_key=None, store_key=None)

Bases: Module

Module stitches histograms by date

__init__(mode='add', time_axis=None, time_bin_idx=None, read_key=None, delta_key=None, store_key=None)

Stitching histograms by first axis.

Parameters
  • mode (str) – options for histogram stitching: “add” or “replace”. default is “add”.

  • time_axis (str) – name of the first axis, to stitch on.

  • time_bin_idx (str) – value of delta dataset used for stitching, in case delta or first dataset is a batch without time_axis. Should be an ordered string or integer.

  • read_key (str) – key of input histogram-dict to read from data store. (only required when calling transform(datastore) as module)

  • delta_key (str) – key of delta histogram-dict to read from data store. (only required when calling transform(datastore) as module)

  • store_key (str) – key of output data to store in data store (only required when calling transform(datastore) as module)

stitch_histograms(mode=None, hists_basis=None, hists_delta=None, hists_list=None, time_axis='', time_bin_idx=None)

Stitching histograms by first axis.

Histograms in hists_delta are added to those in hists_basis. Bins are summed or replaced, set this with ‘mode’. ‘time_axis’ specifies the name of the first axis. If the time_axis is not found, it is created, and histograms get inserted the time_bin_idx values.

Parameters
  • mode (str) – options for histogram stitching: “add” or “replace” bins. default is “add”.

  • hists_basis (dict) – input dict of basis histograms.

  • hists_delta (dict) – delta dict of histograms to add to hists_basis.

  • hists_list (list) – alternative for [hists_basis, hists_delta, etc]. can have multiple deltas. first item in list is taken as hists_basis (optional)

  • time_axis (str) – time-axis used for stitching (optional).

  • time_bin_idx – (list of) time-value(s) at which to insert hist-deltas into hist-basis.

Returns

dict with stitched histograms. If stitching is not possible, returns hists_basis.

transform(hists_basis, hists_delta)

Central function of the module.

Typically transform() takes something from the datastore, does something to it, and puts the results back into the datastore again, to be passed on to the next module in the pipeline.

Parameters

datastore (dict) – input datastore

Returns

updated output datastore

Return type

dict

popmon.stitching.hist_stitcher.stitch_histograms(mode=None, hists_basis=None, hists_delta=None, hists_list=None, time_axis=None, time_bin_idx=None)

Stitching histograms by first axis.

Histograms in hists_delta are added to those in hists_basis. Bins are summed or replaced, set this with ‘mode’. ‘time_axis’ specifies the name of the first axis. If the time_axis is not found, it is created, and histograms get inserted the time_bin_idx values.

Parameters
  • mode (str) – options for histogram stitching: “add” or “replace” bins. default is “add”.

  • hists_basis (dict) – input dict of basis histograms.

  • hists_delta (dict) – delta dict of histograms to add to hists_basis.

  • hists_list (list) – alternative for [hists_basis, hists_delta, etc]. can have multiple deltas. first item in list is taken as hists_basis (optional)

  • time_axis (str) – time-axis used for stitching (optional).

  • time_bin_idx – (list of) time-value(s) at which to insert hist-deltas into hist-basis.

Returns

dict with stitched histograms. If stitching is not possible, returns hists_basis.