Viz Tool

In this notebook, we show the features of the VizTool, an interactive tool for visualization of events and main parameters.

import cait as ai

The VizTool’s main component is a 2D scatter plot. In this interactive plot, we can select and plot events, cut them away, define event lists and store them inside HDF5 files or as CSV.

The events are extracted from an HDF5 or CSV file. We will show the functionalities with an HDF5 file.

We can choose to show only certain events from the file, by handing the indices of these events to the instance of the VizTool. To show this feature, we first create a cait DataHandler and link it to our exemplary file, to create some list of indices.

dh = ai.DataHandler(nmbr_channels=2,
              sample_frequency=25000,
              record_length=16384)
dh.set_filepath('test_data/', 'test_001', appendix=False)
DataHandler Instance created.

Now lets define some arbitrary cut, just to show the procedure:

some_cut = ai.cuts.LogicalCut(dh.get('events', 'pulse_height')[0] < 2)  # cut on the phonon channel
some_cut.get_idx()
array([  0,   1,   6,   9,  10,  13,  14,  15,  16,  17,  18,  19,  20,
        22,  23,  24,  25,  28,  29,  30,  32,  34,  38,  44,  46,  47,
        48,  49,  50,  51,  52,  54,  55,  58,  60,  61,  62,  63,  64,
        65,  66,  67,  68,  70,  71,  72,  74,  75,  76,  80,  81,  86,
        89,  90,  93,  94,  95,  96,  97,  98,  99, 100, 102, 103, 104,
       105, 108, 109, 110, 112, 114, 118, 124, 126, 127, 128, 129, 130,
       131, 132, 134, 135, 138, 140, 141, 142, 143, 144, 145, 146, 147,
       148, 150, 151, 152, 154, 155, 156])

We see above the list of event indices, that survives the cut. As next step we need to define the values that we want to include in the interactiv plotting session. This we do in form of a dictionary. The keys of the dictionary are the labels that will be displayed on the plot. The value is always a list of the name of the dataset, the index in the first dimension (channel index) and last dimension (feature index). If there is no channel or feature index to be set, the value in the list can be put to None.

datasets = {
    'Time (h)': ['hours', None, None],
    'Pulse Height Phonon (V)': ['pulse_height', 0, None],
    'Pulse Height Light (V)': ['pulse_height', 1, None],
    'Rise Time Phonon (ms)': ['rise_time', 0, None],
    'Rise Time Light (ms)': ['rise_time', 1, None],
    'Decay Time Phonon (ms)': ['decay_time', 0, None],
    'Decay Time Light (ms)': ['decay_time', 1, None],
    'Onset Phonon (ms)': ['onset', 0, None],
    'Onset Light (ms)': ['onset', 1, None],
    'Slope Phonon (V)': ['slope', 0, None],
    'Slope Light (V)': ['slope', 1, None],
    'Variance Phonon (V^2)': ['var', 1, None],
    'Variance Light (V^2)': ['var', 0, None],
    'Mean Phonon (V)': ['mean', 0, None],
    'Mean Light (V)': ['mean', 1, None],
    'Skewness Phonon': ['skewness', 0, None],
    'Skewness Light': ['skewness', 1, None],
}

We create now the instance of the VizTool. We need to hand some information about the measurement, such that all values are calculated correctly. Try executing the cell with and without the set_idx(...) line, to see that the precalculated cut works!

In the scatter plot, you can click on events to see their pulse trace below. You can choose events with the box or lassoo select method. A histogram of the selected events will be shown in the two plots below (you can choose linear or log scaling on the y axis).

The selected events can be excluded from the plot with the Cut Selected Button.

You can calculate a preview of a standard event of your selected events with the Calc SEV button.

In the textbox, you can define a name for the selected events (you need to press Enter) and then store the cut flag (a boolean array) for the selected event in the HDF5 set (Save Selected) or export the index list as CSV (Export Selected).

# example for HF5

viz = ai.VizTool(path_h5='test_data/', 
              fname='test_001', 
              group='events', 
              datasets=datasets, 
              nmbr_channels=2, 
              batch_size=1000,
              sample_frequency=25000,
              record_length=16384)
viz.set_idx(some_cut.get_idx())  # this cut flag can be commented
viz.set_colors(dh.get('events', 'pulse_height')[0, some_cut.get_flag()])
viz.show()
DataHandler Instance created.

Once you choose a list of events for which you want to calcualte a standard event, you can access the saved list from the HDF5 set with the get method. You can define the index list with a LogicalCut object and then use it in the calc_sev method (see below):

sev_cuts = ai.cuts.LogicalCut(dh.get('events', 'sev_cuts')[0])

dh.calc_sev(use_idx=sev_cuts.get_idx())
Calculating SEV for Channel 0
18 Events used to generate Standardevent.
Parameters [t0, An, At, tau_n, tau_in, tau_t]:
 [-1.12068922  3.66933137  0.78329507  4.78793431  1.65149065  1.13027107]

Calculating SEV for Channel 1
18 Events used to generate Standardevent.
Parameters [t0, An, At, tau_n, tau_in, tau_t]:
 [ 0.53862549 -0.26813947 -1.59538539 36.47539468 24.38663557  4.47995442]
events SEV calculated.

Done.