NuRadioReco.framework.electric_field module
- class NuRadioReco.framework.electric_field.ElectricField(channel_ids, position=None, shower_id=None, ray_tracing_id=None)[source]
Bases:
BaseTrace
,ParameterStorage
Initialize a new electric field object
This object stores a 3 dimensional trace plus additional meta parameters
- Parameters:
- channel_ids: array of ints
the channels ids this electric field is valid for. (For cosmic rays one electric field is typically valid for several channels. For neutrino simulations, we typically simulate the electric field for each channel separately)
- position: 3-dim array/list of floats
the position of the electric field
- shower_id: int or None
the id of the corresponding shower object
- ray_tracing_id: int or None
the id of the corresponding ray tracing solution
Methods
add_parameter_type
(parameter_type)Add a parameter class to the list of allowed parameter classes.
add_to_trace
(channel[, ...])Adds the trace of another channel to the trace of this channel.
apply_time_shift
(delta_t[, silent, ...])Uses the fourier shift theorem to apply a time shift to the trace Note that this is a cyclic shift, which means the trace will wrap around, which might lead to problems, especially for large time shifts.
get_filtered_trace
(passband[, filter_type, ...])Returns the trace after applying a filter to it.
get_frequencies
([window_mask])Returns the frequencies of the frequency spectrum.
get_frequency_spectrum
([window_mask])Returns the frequency spectrum.
Returns the number of samples in the time domain.
get_parameter
(key)Get a parameter
get_parameter_error
(key)Get the error of a parameter
Get all parameters
get position of the electric field relative to station position
Returns the sampling rate of the trace.
get_stokes_parameters
([window_samples, ...])Return the stokes parameters for the electric field.
Returns the time trace.
returns a unique identifier consisting of the tuple channel_ids, shower_id and ray_tracing_id
has_parameter
(key)Returns True if the parameter key is present, False otherwise
has_parameter_error
(key)Returns True if an uncertainty for the parameter key is present, False otherwise
remove_parameter
(key)Remove a parameter
set_frequency_spectrum
(frequency_spectrum, ...)Sets the frequency spectrum.
set_parameter
(key, value)Set a parameter
set_parameter_error
(key, value)Set the error of a parameter
set_position
(position)set position of the electric field relative to station position
set_trace
(trace, sampling_rate)Sets the time trace.
add_trace_start_time
deserialize
get_channel_ids
get_hilbert_envelope
get_hilbert_envelope_mag
get_ray_tracing_solution_id
get_shower_id
get_times
get_trace_start_time
has_channel_ids
resample
serialize
set_channel_ids
set_trace_start_time
- get_unique_identifier()[source]
returns a unique identifier consisting of the tuple channel_ids, shower_id and ray_tracing_id
- get_stokes_parameters(window_samples=None, vxB_vxvxB=False, magnetic_field_vector=None, site=None, filter_kwargs=None)[source]
Return the stokes parameters for the electric field.
By default, the stokes parameters are returned in (eTheta, ePhi); this assumes the 3d efield trace is stored in (eR, eTheta, ePhi). To return the stokes parameters in (vxB, vxvxB) coordinates instead, one has to specify the magnetic field vector.
- Parameters:
- window_samplesint | None, default: None
If None, return the stokes parameters over the full traces. If not None, returns a rolling average of the stokes parameters over
window_samples
. This may be more optimal if the duration of the signal is much shorter than the length of the full trace.- vxB_vxvxBbool, default: False
If False, returns the stokes parameters for the (assumed) (eTheta, ePhi) coordinates of the electric field. If True, convert to (vxB, vxvxB) first. In this case, one has to additionally specify either the magnetic field vector or the sit.
- magnetic_field_vector3-tuple of floats | None, default: None
The direction of the magnetic field (in x,y,z)
- sitestring | None, default: None
The site of the detector. Can be used instead of the
magnetic_field_vector
if the magnetic field vector for this site is included inradiotools
- filter_kwargsdict | None, default: None
Optional arguments to bandpass filter the trace before computing the stokes parameters. They are passed on to get_filtered_trace(**filter_kwargs)
- Returns:
- stokesarray of floats
The stokes parameters. If
window_samples=None
(default), the shape of the returned array is(4,)
and corresponds to the I, Q, U and V parameters. Otherwise, the array will have shape(4, len(efield) - window_samples + 1)
and correspond to the values of the stokes parameters over the specified window sizes.
See also
NuRadioReco.utilities.trace_utilities.get_stokes
Function that computes the stokes parameters
- add_parameter_type(parameter_type)
Add a parameter class to the list of allowed parameter classes.
- Parameters:
- parameter_typeparameter class
The parameter class is defined in
NuRadioReco.framework.parameters
- add_to_trace(channel, min_residual_time_offset=1e-05, raise_error=True)
Adds the trace of another channel to the trace of this channel.
The trace of the incoming channel is only added within the time window of the current channel. If the current channel has an empty trace (i.e., a trace containing zeros) with a defined trace_start_time, this function can be seen as recording the incoming channel in the specified readout window. Hence, the current channel is referred to as the “readout” in the comments of this function.
- Parameters:
- channel: BaseTrace
The channel whose trace is to be added to the trace of the current channel.
- min_residual_time_offset: float (default: 1e-5 * units.ns)
Minimum residual time between the target bin of this channel and the target bin of the channel to be added. Below this threshold the residual time shift is not applied to increase performance and minimize numerical artifacts from Fourier transforms.
- raise_error: bool (default: True)
If True, an error is raised if (part of) the current channel (readout window) is outside the incoming channel.
- add_trace_start_time(start_time)
- apply_time_shift(delta_t, silent=False, fourier_shift_threshold=1e-05)
Uses the fourier shift theorem to apply a time shift to the trace Note that this is a cyclic shift, which means the trace will wrap around, which might lead to problems, especially for large time shifts.
- Parameters:
- delta_t: float
Time by which the trace should be shifted
- silent: boolean (default:False)
Turn off warnings if time shift is larger than 10% of trace length Only use this option if you are sure that your trace is long enough to acommodate the time shift
- fourier_shift_threshold: float (default: 1e-5 * units.ns)
Threshold for the Fourier shift. If the shift is closer to a multiple of 1 / sampling_rate than this, the trace is rolled instead of using the Fourier shift theorem to save time and avoid numerical errors in the Fourier transforms.
- get_filtered_trace(passband, filter_type='butter', order=10, rp=None)
Returns the trace after applying a filter to it. This does not change the stored trace.
- Parameters:
- passband: list of floats
lower and upper bound of the filter passband
- filter_type: string
type of the applied filter. Options are rectangular, butter and butterabs
- order: int
Order of the Butterworth filter, if the filter types butter or butterabs are chosen
- get_frequencies(window_mask=None)
Returns the frequencies of the frequency spectrum.
- Parameters:
- window_mask: array of bools (default: None)
If not None, used to determine the number of samples in the time domain used for the frequency spectrum.
- Returns:
- frequencies: np.array of floats
The frequencies of the frequency spectrum.
- get_frequency_spectrum(window_mask=None)
Returns the frequency spectrum.
- Parameters:
- window_mask: array of bools (default: None)
If not None, specifies the time window to be used for the FFT. Has to have the same length as the trace.
- Returns:
- frequency_spectrum: np.array of floats
The frequency spectrum.
- get_hilbert_envelope()
- get_hilbert_envelope_mag()
- get_number_of_samples()
Returns the number of samples in the time domain.
- Returns:
- n_samples: int
number of samples in time domain
- get_parameter(key)
Get a parameter
- get_parameter_error(key)
Get the error of a parameter
- get_parameters()
Get all parameters
- get_sampling_rate()
Returns the sampling rate of the trace.
- Returns:
- sampling_rate: float
sampling rate, i.e., the inverse of the bin width
- get_times()
- get_trace()
Returns the time trace.
If the frequency spectrum was modified before, an ifft is performed automatically to have the time domain representation up to date.
- Returns:
- trace: np.array of floats
the time trace
- get_trace_start_time()
- has_parameter(key)
Returns True if the parameter key is present, False otherwise
- has_parameter_error(key)
Returns True if an uncertainty for the parameter key is present, False otherwise
- remove_parameter(key)
Remove a parameter
- resample(sampling_rate)
- set_frequency_spectrum(frequency_spectrum, sampling_rate)
Sets the frequency spectrum.
- Parameters:
- frequency_spectrumnp.array of floats
The frequency spectrum
- sampling_ratefloat or str
The sampling rate of the trace, i.e., the inverse of the bin width. If sampling_rate=”same”, sampling rate is not changed (requires previous initialisation).
- set_parameter(key, value)
Set a parameter
- set_parameter_error(key, value)
Set the error of a parameter
- set_trace(trace, sampling_rate)
Sets the time trace.
- Parameters:
- tracenp.array of floats
The time series
- sampling_ratefloat or str
The sampling rate of the trace, i.e., the inverse of the bin width. If sampling_rate=”same”, sampling rate is not changed (requires previous initialisation).
- set_trace_start_time(start_time)