CsmplMixin

class cait.mixins.CsmplMixin[source]

Bases: object

A Mixin Class to the DataHandler Class with methods for the triggering of *.csmpl files.

include_csmpl_triggers(csmpl_paths: list, thresholds: list, trigger_block: Optional[int] = None, take_samples: Optional[int] = None, of: Optional[list] = None, path_dig: Optional[str] = None, clock: int = 10000000, path_sql: Optional[str] = None, csmpl_channels: Optional[list] = None, sql_file_label: Optional[str] = None, down: int = 1, window: bool = True, overlap: Optional[float] = None, read_triggerstamps: bool = False)[source]

Trigger *.csmpl files of a detector module and include them in the HDF5 set.

The trigger time stamps of all channels get aligned, by applying a trigger block to channels that belong to the same module. For determining the absolute time stamp of the triggers, we also need the SQL file that belongs to the measurement. The absolute time stamp will be precise only to seconds, as it is only stored with this precision in the SQL file. This is not a problem for our analysis, as all events within this files are down to micro seconds precisely matched to each other.

New in v1.1: We can also read the start time from the PAR file. In this case, the start time needs to be already stored in the metainfo dataset. We still need to provide a DIG file, to calculate the offset between the files. If we do not want to exclude the offset, we don’t need to provide a DIG file.

The data format and method was described in “(2018) N. Ferreiro Iachellini, Increasing the sensitivity to low mass dark matter in cresst-iii witha new daq and signal processing”, doi 10.5282/edoc.23762.

Parameters
  • csmpl_paths (list of strings) – The full paths for the csmpl files of all channels. If you want to trigger only one channel, then only put the path of this channel here.

  • thresholds (list of floats) – The trigger tresholds for all channels in Volt.

  • trigger_block (int or None) – The number of samples for that the trigger is blocked after a trigger. If None, it is the length of a record window.

  • take_samples (int or None) – The number of samples that we trigger from the stream file. Standard argument is None, which means all samples are triggered.

  • of (list of arrays) – The optimum filter transfer functions for all channels.

  • path_sql (string) – The path to the SQL database that contains the start of file timestamp.

  • path_dig (str) – Path to the DIG file, to read the offset between continuous DAQ and CCS. For this you need to include the metadata first! If not provided, no offset is calculated.

  • clock (int) – The frequency of the clock that times the data recording.

  • csmpl_channels (list of ints) – The CDAQ channels that we are triggering. The channels numbers are usually appended to the file name of the CSMPL files and written in the SQL database.

  • sql_file_label (string) – In the SQL database, we need to access the start time of file with the corresponding label of the file. The label can be looked up in the SQL file.

  • down (int) – The downsampling factor for triggering.

  • window (bool) – If true, the trigger window is multiplied with a window function before the filtering. This is strongly recommended! Otherwise some artifacts from major differences in the left and right baseline level can appear somewhere in the middle of the record window.

  • overlap (float) – A value between 0 and 1 that defines the part of the record window that overlaps with the previous/next one. Standard value is 1/4 - it is recommended to use this value!

  • read_triggerstamps (bool) – In case there is already a trigger_hours data set in the HDF5 stream group, we can read it instead of doing the triggering again. For this, set this argument to True.

include_ctrigger_stamps(paths, name_appendix='', trigger_block: Optional[int] = None, path_sql: Optional[str] = None, csmpl_channels: Optional[list] = None, sql_file_label: Optional[str] = None)[source]

Include time stamps from a CAT CTrigger data format.

These are included in the group stream. Choose and appropriate name_appendix to distinguish them from time stamps that are calculated with the Cait trigger!

The data format and method was described in “(2018) N. Ferreiro Iachellini, Increasing the sensitivity to low mass dark matter in cresst-iii witha new daq and signal processing”, doi 10.5282/edoc.23762.

Parameters
  • paths (tuple of strings) – The paths to the *.csmpl.trig files that contain the time stamps from the CAT CTrigger.

  • name_appendix (string) – A string that is appended to the HDF5 data sets trigger_hours, trigger_time_mus, trigger_time_s.

  • trigger_block (int) – The value of samples that is blocked for triggering in all channels, after one trigger.

  • path_sql (string) – Path to the SQL database file of the run.

  • csmpl_channels (list of ints) – The csmpl channel numbers.

  • sql_file_label (string) – In the SQL database, we need to access the start time of file with the corresponding label of the file. The label can be looked up in the SQL file.

include_noise_events(csmpl_paths, datatype='float32', origin=None, down=1)[source]

Include the events corresponding to chosen noise triggers.

Parameters
  • csmpl_paths (list of strings) – The paths to the *.csmpl files of all channels, should be nmbr_channels long.

  • datatype (string) – The datatype of the events that we want to store. Typically float32 is a good choice, float16 would lead to significantly reduced precision.

  • origin (string) – This is needed in case you want to include events to a dataset that itself is a merge of other datasets. Then typically a set of origin strings is included in the set, which specify the origin of the individual events within the merged set. By putting a origin string here, the events get included in the event data set exactly at the positions where the origin attribute is the same as the handed origin string.

  • down (int) – The factor by which we want to downsample the included events.

include_noise_triggers(nmbr, min_distance=0.5, max_distance=60, record_window_length=None, max_attempts=5, no_pileup=False, start_end=None)[source]

Include a number of random triggers from the Stream.

The random triggers are only choosen in intervals that are measurement time (frequently occuring test pulses) and that are away from test pulses. The triggers are stored in the stream group in the HDF5 file.

The data format and method was described in “(2018) N. Ferreiro Iachellini, Increasing the sensitivity to low mass dark matter in cresst-iii witha new daq and signal processing”, doi 10.5282/edoc.23762.

Parameters
  • nmbr (int) – The number of noise triggers we want to include.

  • min_distance (float) – The minimal distance in seconds of the start and end of a noise trigger window from a test pulse. If you choose record_length * 0.8 or higher, you avoid pile up.

  • max_distance (float) – The maximal distance of two test pulses in seconds, such that the interval in between still counts as measurement time.

  • record_window_length (float) – The length of the record window in seconds. If None, it is calculated from the record length and sample frequency.

  • max_attempts (int) – In case the chosen time stamp is piled up with an already chosen noise trigger, we chose another time stamp. This counts as one attempt. If the maximal number of attempts is exceeded, we skip one noise trigger and try for another gap. In this case, we will include one less time stamp than the parameter nmbr. This procedure prevents infinite loops due to a too high nmbr parameter.

  • no_pileup (bool) – If activated, not only test pulses but also triggered events are excluded from the noise trigger windows.

  • start_end (list of two floats) – Only used, if there are no test pulse hours. This determines the start ond stop of the interval in which noise triggers are sampled.

include_nps(nps)[source]

Include the Noise Power Spectrum to the HDF5 file.

Parameters

nps (array of shape (channels, samples/2 + 1)) – The optimum filter transfer function.

include_of(of_real, of_imag, down=1, group_name_appendix='')[source]

Include the optimum filter transfer function into the HDF5 file.

Parameters
  • of_real (array of shape (channels, samples/2 + 1)) – The real part of the transfer function.

  • of_imag (array of shape (channels, samples/2 + 1)) – The imaginary part of the transfer function.

  • down (int) – The downsample rate of the transfer function.

  • group_name_appendix (string) – A string that gets appended to the name optimumfilter of the group. Typically _tp for the test pulse standard event.

include_sev(sev, fitpar=None, mainpar=None, scale_fit_height=True, sample_length=None, t0_start=None, opt_start=False, group_name_appendix='')[source]

Include the Standard Event to a HDF5 file.

Parameters
  • sev (array with shape (channels, samples)) – The standard events of all channels.

  • fitpar (array with shape (channels, 6)) – The Proebst pulse shape fit parameters for all standard events.

  • mainpar (array with shape (channels, 10)) – The main parameters of all standard events.

  • scale_fit_height (bool) – If true, the fitted standard event amplitude parameters get divided by 1/height of the fitted parametric model. Use this with caution! With this you intentionally deviate from the best fit parameters.

  • sample_length (float) – The sample length in milliseconds. If None, it is calculated from the sample frequency.

  • t0_start (list of floats) – The start values for the fit of the parametric model, for all channels.

  • opt_start (bool) – If true, before the nelder-mead fit startes, a differential evolution fit is looking for suitable starting values.

  • group_name_appendix (string) – A string that gets appended to the name stdevent of the group. Typically _tp for the test pulse standard event.

include_test_stamps(path_teststamps, path_dig_stamps, path_sql=None, csmpl_channels=None, sql_file_label=None, clock=10000000, fix_offset=True)[source]

Include the test pulse time stamps in the HDF5 data set.

If the SQL path is not provided, then the filestart is read from the metainfo (recommended)!

Parameters
  • path_teststamps (string) – The path to the TEST_STAMPS file.

  • path_dig_stamps (string) – The path to the DIG_STAMPS file.

  • path_sql (string) – The path to the SQL database that contains the start of file timestamp.

  • csmpl_channels (list of ints) – The CDAQ channels that we are triggering. The channels numbers are usually appended to the file name of the CSMPL files and written in the SQL database.

  • sql_file_label (string) – In the SQL database, we need to access the start time of file with the corresponding label of the file. The label can be looked up in the SQL file.

  • clock (int) – The Frequency of the time clock, in Hz. Standard for CRESST is 10MHz.

  • fix_offset (bool) – This fixes the time offset between the trigger time stamps and the DAQ time stamps. Strongly recommended!!

include_triggered_events(csmpl_paths, max_time_diff=0.5, exclude_tp=True, sample_duration=None, name_appendix='', datatype='float32', min_tpa=0.0001, min_cpa=10.1, down=1, noninteractive=True, origin=None, individual_tpas=False)[source]

Include the triggered events from the CSMPL files.

It is recommended to exclude the testpulses. This means, we exclude them from the events group and put them separately in the testpulses and control pulses groups.

Parameters
  • csmpl_paths (list of strings) – The full paths for the csmpl files of all channels.

  • max_time_diff (float) – The maximal time difference between a trigger and a test pulse time stamp such that the trigger is still counted as test pulse.

  • exclude_tp (bool) – If true, we separate the test pulses from the triggered events and put them in individual groups.

  • sample_duration (float) – The duration of a sample in seconds. If None, the inverse of the sample frequency is taken.

  • name_appendix (string) – The name appendix of the data sets trigger_hours, trigger_time_s and trigger_time_mus in the HDF5 file. This is typically needed, when we want to include the events corresponding to time stamps that were triggered with the CAT CTrigger and then included in the HDF5 set.

  • datatype (string) – The datatype of the stored events.

  • min_tpa (float) – TPA values below this are not counted as testpulses.

  • min_cpa (float) – TPA values above this are counted as control pulses.

  • down (int) – The events get stored downsampled by this factor.

  • origin (str) – The name of the csmpl file from which we read, e.g. bck_xxx

  • individual_tpas (bool) – Write individual TPAs for the all channels. This results in a testpulseamplitude dataset of shape (nmbr_channels, nmbr_testpulses). Otherwise we have (nmbr_testpulses).