smiet.numpy.utilities package

smiet.numpy.utilities.angle_between(v1, v2)

Returns the angle in radians between vectors ‘v1’ and ‘v2’

Parameters:
v1 : array_like

First vector

v2 : array_like

Second vector

Returns:

angle – The angle (in radians) between the vectors

Return type:

float

Examples

>>> angle_between((1, 0, 0), (0, 1, 0))
1.5707963267948966
>>> angle_between((1, 0, 0), (1, 0, 0))
0.0
>>> angle_between((1, 0, 0), (-1, 0, 0))
3.141592653589793
smiet.numpy.utilities.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.e_to_geo_ce(traces, x, y)

Decouples the electric field in the shower plane, i.e. the electric field should be in the (vxB, vxvxB, v) CS, into the geomagnetic and charge-excess components.

Parameters:
traces : np.ndarray

The traces in the shower plane, shaped as (samples, polarisations)

x : float

The antenna position along the vxB axis

y : float

The antenna position along the vxvxB axis

Returns:

  • e_geo (np.ndarray) – The geomagnetic component of the electric field

  • e_ce (np.ndarray) – The charge-excess component of the electric field

smiet.numpy.utilities.geo_ce_to_e(my_e_geo, my_e_ce, x, y)

Convert the geomagnetic and charge-excess components to a three-dimensional electric field in the shower plane, i.e. the (vxB, vxvxB, v) CS.

Note that the v-component is simply set to zero.

Parameters:
my_e_geo : np.ndarray

The electric field traces of the geomagnetic component, shaped as (n_antennas, n_samples, n_slices,)

my_e_ce : np.ndarray

The electric field traces of the charge-excess component, shaped as (n_antennas, n_samples, n_slices,)

x : float

The antenna position along the vxB axis, shaped as (n_antennas, )

y : float

The antenna position along the vxvxB axis, shaped as (n_antennas, )

Returns:

e_field – The three-dimensional electric field, in the shower plane CS, shaped as (samples, polarisations)

Return type:

np.ndarray

smiet.numpy.utilities.unit_vector(vector)

Normalize a vector to unit length

Parameters:
vector : array_like

The vector to normalize

Returns:

unit – The unit vector of the input vector.

Return type:

np.ndarray

Examples

>>> unit_vector(np.array([1, 0, 0]))
array([1., 0., 0.])
>>> unit_vector(np.array([0, 4, 0]))
array([0., 1., 0.])
>>> unit_vector(np.array([3, 6, -2]))
array([ 0.42857143,  0.85714286, -0.28571429])

Submodules