gwadama.fat#
fat.py
Frequency analysis toolkit.
- gwadama.fat.correct_phase(phase, time, jump_start, jump_end, correction_factor=1.0)[source]#
Manually correct a phase jump.
Fine-tunes the manual phase correction by adjusting the phase after a phase jump. The phase after the jump is scaled by the correction factor.
- Parameters:
- phasendarray
The unwrapped phase of the signal.
- timendarray
The time array corresponding to the signal.
- jump_startfloat
The time where the phase jump starts.
- jump_endfloat
The time where the phase jump ends.
- correction_factorfloat, optional
The factor to scale the phase correction for fine-tuning. Default is 1.0.
- Returns:
- corrected_phasendarray
The phase with fine-tuned manual correction applied after the specified jump.
- gwadama.fat.highpass_filter(signal: ndarray, *, f_cut: int | float, f_order: int | float, sample_rate: int) ndarray [source]#
Apply a forward-backward digital highpass filter.
Apply a forward-backward digital highpass filter to ‘signal’ at frequency ‘f_cut’ with an order of ‘f_order’.
- gwadama.fat.instant_frequency(signal, *, sample_rate, phase_corrections=None)[source]#
Computes the instantaneous frequency of a time-domain signal.
Computes the instantaneous frequency of a time-domain signal using the central difference method, with optional phase corrections. If negative frequencies are detected, a warning is raised.
- Parameters:
- signalndarray
The input time-domain signal.
- sample_ratefloat
The sampling rate of the signal (in Hz).
- phase_correctionslist of tuples, optional
A list of phase corrections. Each tuple contains: (jump_start, jump_end, correction_factor). If None, no phase correction is applied.
- Returns:
- inst_freqndarray
The instantaneous frequency of the signal (in Hz). If negative frequencies are detected, a RuntimeWarning is issued.
- gwadama.fat.whiten(strain: ndarray, *, asd: ndarray, sample_rate: int, flength: int, highpass: float = None, pad: int = 0, unpad: int = 0, normed: bool = True, **kwargs) ndarray [source]#
Whiten a single strain signal.
Whiten a strain using the input amplitude spectral density ‘asd’, and shrinking signals afterwarwds to ‘l_window’ to account for the edge effects introduced by the windowing.
- Parameters:
- strainNDArray
Strain data points in time domain.
- asd2d-array
Amplitude spectral density assumed for the ‘set_strain’. Its components are: - asd[0] = frequency points - asd[1] = ASD points NOTE: It must has a linear and constant sampling frequency!
- sample_rateint
The thingy that makes things do correctly their thing.
- flengthint
Length (in samples) of the time-domain FIR whitening filter. Passed in seconds (flength/sample_rate) to GWpy’s whiten() function as the ‘fduration’ parameter.
- padint, optional
Marging at each side of the strain to add (zero-pad) in order to avoid edge effects. The corrupted area at each side is 0.5 * fduration in GWpy’s whiten(). Will be cropped afterwards, thus no samples are added at the end of the call to this function. If given, ‘unpad’ will be ignored.
- unpadint, optional
Marging at each side of the strain to crop. Will be ignored if ‘pad’ is given.
- highpassfloat, optional
Highpass corner frequency (in Hz) of the FIR whitening filter.
- normedbool
If True, normalizes the strains to their maximum absolute amplitude.
- **kwargs:
Extra arguments passed to gwpy.timeseries.Timeseries.whiten().
- Returns:
- strain_wNDArray
Whitened strain (in time domain).