flint.bptools.smoother¶
Functions¶
|
Divide the bandpass complex gains (solved for initially by something like |
|
Divide the bandpass complex gains (solved for initially by something like |
|
Smooth bandpass solutions by applying a savgol filter to the real and imaginary components |
|
Smooth a 1-dimensional dataset. Internally it uses a savgol filter as |
Module Contents¶
- flint.bptools.smoother.divide_bandpass_by_ref_ant(complex_gains: numpy.ndarray, ref_ant: int) numpy.ndarray[source]¶
Divide the bandpass complex gains (solved for initially by something like calibrate) by a nominated reference antenna. In the case of
calibratethere is no implicit reference antenna.The input complex gains should be in the form: >> (ant, channel, pol)
Internally this function will construct a phasor: >> phasor = Jones_{ref_ant} / abs(Jones_{ref_ant}) >> shift = Jones_{ref_ant}[0] / and(Jones_{ref_ant}[0]) >> phasor_shifted = phasor / shift
which is applied to all antennas in
complex_gains. The resulting solutions will all have been referenced to the G_x of the reference antenna. In other words, the phase of all G_x items of the reference antenna will be zero.- Parameters:
complex_gains (np.ndarray) – The complex gains that will be normalised
ref_ant (int) – The desired reference antenna to use
- Returns:
The normalised bandpass solutions
- Return type:
np.ndarray
- flint.bptools.smoother.divide_bandpass_by_ref_ant_preserve_phase(complex_gains: numpy.ndarray, ref_ant: int) numpy.ndarray[source]¶
Divide the bandpass complex gains (solved for initially by something like calibrate) by a nominated reference antenna. In the case of
calibratethere is no implicit reference antenna. This is valid for cases where the xy-phase is set to 0 (true via the ASKAP on-dish calibrator).This particular function is most appropriate for the calibrate style solutions, which solve for the Jones in one step. In HMS notation this are normally split into two separate 2x2 matrices, one for the gains with zero off-diagonal elements and a leakage matrix with ones on the diagonal.
This is the preferred function to use whena attempting to set a phase reference antenna to precomputed Jones bandpass solutions.
The input complex gains should be in the form: >> (ant, channel, pol)
Internally reference phasores are constructed for the G_x and G_y terms of the reference antenna. They are then applied: >> G_xp = G_x / G_xref >> G_xyp = G_xy / G_yref >> G_yxp = G_yx / G_xref >> G_y = G_y / G_yref
which is applied to all antennas in
complex_gains.- Parameters:
complex_gains (np.ndarray) – The complex gains that will be normalised
ref_ant (int) – The desired reference antenna to use
- Returns:
The normalised bandpass solutions
- Return type:
np.ndarray
- flint.bptools.smoother.smooth_bandpass_complex_gains(complex_gains: numpy.ndarray, window_size: int = 16, polynomial_order: int = 4, apply_median_filter: bool = True, smooth_jones_elements: tuple[int, Ellipsis] = (0, 1, 2, 3)) numpy.ndarray[source]¶
Smooth bandpass solutions by applying a savgol filter to the real and imaginary components of each of the antenna based polarisation solutions across channels.
Experience suggests that this performs better once the data have been divided by a reference antenna. Flagged channels (represented by NaNs) will be maintained in the smoothed output data.
The input bandpass data contained by
complex_gainsis expected to be in the form: > [ants, chans, pols]If
median_filterisTruethen the raw data (without any interpolation) will first be passed through a median boxcar filter with a window size ofwindow_size.- Parameters:
complex_gains (np.ndarray) – Data to be smoothed.
window_size (int, optional) – The size of the window function of the savgol filter. Passed directly to savgol. Defaults to 16.
polynomial_order (int, optional) – The order of the polynomial of the savgol filter. Passed directly to savgol. Defaults to 4.
apply_median_filter (bool, optional) – Apply a median filter to the data before applying the savgol filter using the same window size. Defaults to True.
smoothe_jones_elements (Tuple[int, ...], optional) – Which elements of the antennae Jones will be smoothed through frequency, i.e. X_x, X_y, Y_x, Y_y. Defaults to (0, 1, 2, 3).
- Returns:
Smoothed complex gains
- Return type:
np.ndarray
- flint.bptools.smoother.smooth_data(data: numpy.ndarray, window_size: int, polynomial_order: int, apply_median_filter: bool = False) numpy.ndarray[source]¶
Smooth a 1-dimensional dataset. Internally it uses a savgol filter as implemented in scipy.signal.savgol_filter. It is intended to be used to smooth the real and imaginary components of the complex gains of the bandpass solutions.
Datapoints that are NaN’s are first filled by linearly interpolation the closest valid data points. Once the savgol filter has been applied these datapoints are then remasked with a NaN.
If
median_filterisTruethen the raw data (without any interpolation) will first be passed through a median boxcar filter with a window size ofwindow_size.- Parameters:
data (np.ndarray) – The 1-dimensional data to be smoothed.
window_size (int) – The size of the window function of the savgol filter. Passed directly to savgol.
polynomial_order (int) – The order of the polynomial of the savgol filter. Passed directly to savgol.
apply_median_filter (bool, optional) – Apply a median filter to the data before applying the savgol filter using the same window size. Defaults to False.
- Returns:
Smoothed dataset
- Return type:
np.ndarray