Skip to content

Plugins: generators

J Tseng edited this page Jun 6, 2021 · 7 revisions

These plugins generate alert data which mimic experiment output. They are mostly intended for generating pseudo-experiments in a Monte Carlo trial.

In each case, one pseudo-experiment is generated for each alert.

In general, generators should create a dictionary containing their new data, and this dictionary appended to the tuple in the gen field. At the end of the string of generators, the gen.Combine module is used to combine them.

TimeDistSource

This is the base class of TimeDist and TimeSeries.

Configuration

field type description
filename string filename containing time distribution
filetype string file format

filetype can take the following values:

  • tn: a two-column csv file of time (low edge of bin) and number of events in that bin. The last bin is not used for generation so it can serve as the high edge of the time window.
  • json`: a python-formatted dictionary. The distribution is specified with the following elements:
    field type description
    sig_t_bins list(float) number of events in each bin
    sig_t_low float or list(float) low edge (or edges) of time bins
    sig_t_high float ending time of time distribution

If sig_t_low is a float, then sig_t_bins is assumed to be a list of equally spaced bins, with the number of bins given by the length of sig_t_bins. If sig_t_low is a list, it should have the same length as sig_t_bins. Times should also be sorted in increasing time.

Input

No additional input required. (No delay can be applied by this plugin; see TimeDist and TimeSeries.)

However, if there is a gen field containing previously generated data, new data will be appended to it (see below).

Output

On alert, the following will be added to the payload:

field type description
gen tuple(dict) updated tuple containing generated data dictionary

The newly generated data will be appended to any existing data in gen, and will contain the following dictionary:

field type description
gen_sig_t_bins numpy.array bin contents
gen_sig_t_low numpy.array low edges of time bins
gen_sig_t_high float high edge of the distribution

Actions

This plugin only responds to alert. It follows the default behaviors for the other actions.

TimeDist

This plugin sub-classes TimeDistSource.

TimeSeries

This plugin sub-classes TimeDistSource. It uses the time distribution from TimeDistSource to generate a series of event times.

Configuration

In addition to those of TimeDistSource:

field type description
seed int random number seed

Input

field type description
sig_t_delay float delay to be added to generated events
gen tuple(dict) (optional) previously generated data

(The time units are whatever the input distribution uses. Generally we expect the time unit to be seconds.)

Output

On alert, the following will be added to the payload:

field type description
gen tuple(dict) updated tuple containing generated data dictionary

The newly generated data will be appended to any existing data in gen, and will contain the following dictionary:

field type description
times numpy.array list of event times

The list of event times is not assumed to be in any order.

Actions

This plugin only responds to alert. It follows the default behaviors for the other actions.

Combine

Input

field type description
gen tuple(dict) tuple containing generated data dictionary

The gen dictionary contains fields such as the following:

field type description
t_bins numpy.array bin contents
t_low numpy.array low edges of time bins
t_high float high edge of the distribution
times numpy.array event times in seconds

Output

The following fields are then added to the payload directly.

field type description
t_bins numpy.array bin contents
t_low numpy.array low edges of time bins
t_high float high edge of the distribution
times numpy.array event times in seconds

Clone this wiki locally