pyhiperta.integration
Integration of waveforms videos into a single (charge, time of max) pair of image.
Classes:
| Name | Description |
|---|---|
IntegrationFunctionType |
Describes the signature of a function that can be used for windowed integration and associated correction. |
Functions:
| Name | Description |
|---|---|
integrate_local_peak |
Integrate (sum the number of photoelectrons) in the waveform pulses in a window around the pulse maximum. |
windowed_integration_correction |
Calculate the correction to apply to compensate the bias introduced by the windowed integration of real data. |
IntegrationFunctionType
Bases: Protocol
flowchart TD
pyhiperta.integration.IntegrationFunctionType[IntegrationFunctionType]
click pyhiperta.integration.IntegrationFunctionType href "" "pyhiperta.integration.IntegrationFunctionType"
Describes the signature of a function that can be used for windowed integration and associated correction.
Source code in src/pyhiperta/integration.py
integrate_local_peak
Integrate (sum the number of photoelectrons) in the waveform pulses in a window around the pulse maximum.
The method does the following: find the maximum in time for each pixel independently, then sum the frames
from max - nb_slice_before_peak to max + nb_slice_after_peak (inclusive on both end).
If the window wouldn't fit entirely in the available frames, because the maximum position is too
close to one of the edges, the window is shifted towards the center until it includes the same number
of frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform
|
ndarray
|
Batch or single video samples of the shower events. Shape: (N_batch, N_frames, N_pixels) |
required |
nb_frames_before_max
|
int
|
Number of frames before the maximum to include in the integration window. |
required |
nb_frames_after_max
|
int
|
Number of frames after the maximum to include in the integration window. |
required |
time_bin_duration_ns
|
float
|
Amount of time between 2 frames in the waveforms. It is used to compute the maximum signal time. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray]
|
Signal charge (integrated waveform signal) and peak maximum time. |
Examples:
>>> waveforms = 10.0 * np.random.random((12, 40, 1855)) # "random shower samples"
>>> images = integrate_local_peak(waveforms, 3, 3) # shape (12, 1855)1
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of frames to include before or after the maximum is strictly negative. |
Source code in src/pyhiperta/integration.py
windowed_integration_correction
windowed_integration_correction(ref_pulse_sample_times_ns, ref_pulse_waveform, integration_function, nb_frames_before_max_real_data, nb_frames_after_max_real_data, real_data_sampling_period_ns)
Calculate the correction to apply to compensate the bias introduced by the windowed integration of real data.
The windowed integration results are biased with respect to an integration on the total time range, because the integration window is typically shorter than the time range of the full signal (this is on purpose: the edges of the signals are cut-off because they are closer to noise level than the pulse center).
The bias introduced depends on the integration window parameters: position around maximum and range. To be able to compare integrated charge computed with different integration windows, we need to be able to correct the biases. The correction is such that correction * windowed_integration(noise_less_signal, n_slice_before, n_slice_after) = integration(noise_less_signal)
The noise less signal is called the "reference pulse" and typically provided by camera teams, it is the response of a pixel to a single photo-electron.
The waveform signals (reference pulse and real data) come as as number of p.e. at a certain time, ie it is binned number of p.e. wrt time. To compute the correction, the reference pulse is re-binned (typically it has a different bin size than real data) to real data bins which introduces a small error: the ratio between real data bins and the reference bins is not an integer, so the bins on the edge of the integration window have a signal that is a bit mixed with the neighbor's bin (outside of the window).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref_pulse_sample_times_ns
|
ndarray
|
Array containing the timestamps at which the number of photoelectrons are measured, for the reference pulse. Shape: (N_samples,) |
required |
ref_pulse_waveform
|
ndarray
|
Array containing the number of photoelectrons at each timestamp, for the reference pulse. ref_pulse_waveform[0] is the reference pulse of the channel 0 (low gain) and ref_pulse_waveform[1] is the reference pulse for channel 1 (high gain) Shape: (2, N_samples) |
required |
integration_function
|
IntegrationFunctionType
|
Function performing a window integration. It must accept the "waveform", "nb_frames_before_max" and "nb_frames_after_max" arguments. |
required |
nb_frames_before_max_real_data
|
int
|
Number of frames before the maximum to include in the integration window, when used with real data.
The number of frames of the reference pulse to integrate will be computed based on the reference pulse sampling
period and |
required |
nb_frames_after_max_real_data
|
int
|
Number of frames after the maximum to include in the integration window, when used with real data.
The number of frames of the reference pulse to integrate will be computed based on the reference pulse sampling
period and |
required |
real_data_sampling_period_ns
|
float
|
Sampling period (amount of time between 2 samples) of the real data, in nanoseconds. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Correction value for each channel such that correction * windowed_integration(noiseless_real_data) = full_integration(noiselesss_real_data) Shape: (2,) |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/pyhiperta/integration.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |