smiet.numpy.utilities.trace_utils module¶
-
smiet.numpy.utilities.trace_utils.bandpass_filter_trace(trace, trace_sampling, f_min, f_max, sample_axis=
0)¶ Bandpass filter a trace between f_min and f_max. Both should be provided in the internal unit system, just like the trace_sampling parameter. The trace array can be multidimensional, in which case the sample_axis parameter indicates which dimension should be taken as the time samples (ie this parameter is passed on to the np.fft.rfft call).
- Parameters:¶
- trace : np.ndarray¶
The array containing the time traces to be filtered
- trace_sampling : float¶
The sampling interval of the time traces, in internal units
- f_min : float¶
The lower frequency to filter by, in internal units
- f_max : float¶
The upper frequency to filter by, in internal units
- sample_axis : int, default=0¶
The axis of trace which contains the time samples
- Returns:¶
filtered_trace – The filtered traces, in the same shape as trace
- Return type:¶
np.ndarray
Notes
To avoid issues when the maximum of the trace is too close to the edge, all traces are first shifted to have their maxima more or less in the middle. After the filter has been applied, the traces are rolled back so that they are on same time axis as the input traces.
- smiet.numpy.utilities.trace_utils.pulse_center_trace(trace, trace_times, trace_sampling, sample_axis, sample_time_axis)¶
Center the pulses in the traces.
To do this, the traces are first transformed to the frequency domain, then the phase shift corresponding to a time shift that centers the pulse is applied, and finally the traces are transformed back to the time domain.
The time shift is calculated as :
delta_t = 0.5 * n_samples * trace_sampling
where t_center is the center time of the trace
The phase shift can then be calculated by: phase_shift = exp(-2j * pi * f * delta_t)
where f is the frequency array, and delta_t is the time shift needed to center the pulse.
The time shift is also applied to the time array.
- Parameters:¶
- trace : np.ndarray¶
The array containing the time traces to be centered
- trace_times : np.ndarray¶
The time array corresponding to the traces
- trace_sampling : float¶
The sampling interval of the time traces, in internal units
- sample_axis : int¶
The axis of trace which contains the time samples
- sample_time_axis : int¶
The axis of trace_times which contains the time samples
- Returns:¶
centered_trace (np.ndarray) – The centered traces, in the same shape as trace
centered_trace_times (np.ndarray) – The centered time array, in the same shape as trace_times
-
smiet.numpy.utilities.trace_utils.reconstruct_starshape_from_vxvxB(geo_traces, ce_traces, antenna_positions_vvB, number_of_arms=
8)¶ Reconstruct traces on all arms from vxvxB-arm simulation (where geo and ce are orthogonal).
This is used for generating star-shapes from simulations that only have antennas on the vxvxB arm. The traces on the other arms are simply copied from the vxvxB arm, and the antenna positions are rotated accordingly.
This can also be passed traces synthesised for all slices. In that case, the output traces will have the same number of slices. If only at the ground, the n_slices = 1.
- Parameters:¶
- geo_traces : np.ndarray¶
Geomagnetic traces on the vxvxB arm, shape (n_antennas, n_samples, n_slices)
- ce_traces : np.ndarray¶
Charge-excess traces on the vxvxB arm, shape (n_antennas, n_samples, n_slices)
- antenna_positions_vvB : np.ndarray¶
Positions of antennas on vxvxB arm (distance in shower plane), shape (n_antennas,)
- number_of_arms : int, default=8¶
Total number of star-shape arms to reconstruct
- Returns:¶
geo_traces_starshape (np.ndarray) – Geomagnetic traces on all arms, shape (n_antennas*number_of_arms, n_samples, n_slices)
ce_traces_starshape (np.ndarray) – Charge-excess traces on all arms, shape (n_antennas*number_of_arms, n_samples, n_slices)
antenna_positions_starshape (np.ndarray) – Antenna positions on all arms, shape (n_antennas*number_of_arms, 3)
-
smiet.numpy.utilities.trace_utils.transform_traces_on_vxB(my_geo, my_ce, x, y, vxB_axis_mode=
'replace')¶ Adjust the (synthesised) traces on the vxB axis.
This function is meant to alter the traces on the vxB axis, as in the current version of the SMIET software the vxB axis cannot be synthesised. There are several strategies to handle this, and applying them should be facilitated by this function.
- Parameters:¶
- my_geo : np.ndarray¶
The electric field traces of the geomagnetic component, shaped as (NANTS, NSAMPLES)
- my_ce : np.ndarray¶
The electric field traces of the charge-excess component, shaped as (NANTS, NSAMPLES)
- x : np.ndarray¶
the x-coordinates of the antennas in the vxB axis, shaped as (NANTS,).
- y : np.ndarray¶
the y-coordinates of the antennas in the vxvxB axis, shaped as (NANTS,).
- vxB_axis_mode : {"replace", "zero"}¶
Operation to perform on the vxB axis. If “replace” (the default), the traces from the vxvxB component will be copied over to the vxB component. If “zero”, the vxB component will be set to zero.
- Returns:¶
my_geo_adjusted (np.ndarray) – The adjusted geomagnetic component traces, shaped as (NANTS, NSAMPLES)
my_ce_adjusted (np.ndarray) – The adjusted charge-excess component traces, shaped as (NANTS, NSAMPLES)