MainParametersMixin

class cait.mixins.MainParametersMixin[source]

Bases: object

cmp(group: str = 'events', with_processing: Callable | List[Callable] = None, tag: str = None, batch_size: int = 2, **kwargs)[source]

Calculate main parameters of the group specified by group.

See cait.versatile.MainParameters for a description of the parameters calculated here.

Parameters:
  • group (str, optional) – The group for which the main parameters are calculated, e.g. “events”, “testpulses”, “noise”, etc. Defaults to “events”.

  • with_processing (Union[Callable, List[Callable]], optional) – Optional processing to apply to each event before MainParameters is applied. See add_processing().

  • tag (str, optional) – Optional suffix to append to the names normally written to the DataHandler. Useful e.g. in conjunction with with_processing or kwargs arguments to separate different passes. The suffix is separated from the name automatically by a dash, i.e. tag=”fqlc” will result in datasets such as pulse_height-fqlc, onset-fqlc, etc. Defaults to None, in which case no suffix is appended.

  • batch_size (int, optional) – Override the default batch size of 2 when using apply(). May improve speed in certain circumstances.

  • kwargs (Any) – Keyword arguments to pass to MainParameters.

import cait as ai
import cait.versatile as vai

# Create an empty datahandler
dh = ai.DataHandler(nmbr_channels = 2)
dh.set_filepath(path_h5='.', fname='mock', appendix=False)
dh.init_empty()

# Create mock data and add it to the handler
md = vai.MockData(record_length=2**14, dt_us=dh.dt_us)
it = md.get_event_iterator()
dh.include_event_iterator("events", it, copy_events=False)

# CMP for group "events" with DataHandler's dt_us
dh.cmp()

# CMP for group "testpulses"
dh.cmp("testpulses")

The with_processing argument can be used to calculate the main parameters after applying a transform, such as after application of an optimum filter. This can be done in the following way (assuming the above code snippet has been used to create mock data in the DataHandler):

of = md.of  # Retrieve OF from mock data
dh.cmp(
        "events",
        with_processing=vai.OptimumFiltering(of),  # Apply optimum filtering
        tag="of",  # Append this to field names so as not to overwrite old data
        )