ilex.fitting
- class QUfit_likelihood(*args: Any, **kwargs: Any)[source]
- PA(RM, pa0)[source]
PA function to evaluate
- Parameters:
RM (float) – Rotation Measure [rad/m^2]
pa0 (float) – Initial reference polarisation position angle [rad]
- property model_parameters
- RM_QUfit(Q, U, Ierr, Qerr, Uerr, f, rm_priors=[-1000, 1000], pa0_priors=[-3.1415926, 0], **kwargs)[source]
Fit RM using QUfit method
- Parameters:
f (np.ndarray) – Frequencies in MHz
Q (np.ndarray) – Stokes Q parameter
U (np.ndarray) – Stokes U parameter
Ierr (np.ndarray) – Stokes I parameter noise, used to calculate L debiased
Qerr (np.ndarray) – Stokes Q parameter noise
Uerr (np.ndarray) – Stokes U parameter noise
- fit_RMquad(Q, U, Qerr, Uerr, f, f0, **kwargs)[source]
- Info:
Use Quadratic method to fit for RM and pa0.
- Parameters:
Q (np.ndarray) – stokes Q spectra
U (np.ndarray) – stokes U spectra
Qerr (np.ndarray) – stokes Q rms spectra
Uerr (np.ndarray) – stokes U rms spectra
f (np.ndarray) – frequencies [MHz]
f0 (float) – reference Frequency [MHz]
**kwargs (Dict) – keyword arguments for RM tools run_synthesis
- Returns:
rm (float) – rotation measure
rm_err (float) – error in rotation measure
pa0 (float) – position angle at f0
pa0_err (float) – position angle err
- fit_RMsynth(I, Q, U, Ierr, Qerr, Uerr, f, clean_cutoff=0.1, **kwargs)[source]
Use RM synthesis to calculate RM, pa0 and f0, f0 is the weighted midband frequency and pa0 the pa at f0.
- Parameters:
I (np.ndarray) – stokes I spectra
Q (np.ndarray) – stokes Q spectra
U (np.ndarray) – stokes U spectra
Ierr (np.ndarray) – stokes I rms spectra
Qerr (np.ndarray) – stokes Q rms spectra
Uerr (np.ndarray) – stokes U rms spectra
f (np.ndarray) – frequencies [MHz]
clean_cutoff (float) – cutoff arg for run_rmclean()
**kwargs (Dict) – keyword arguments for RM tools run_synthesis
- Returns:
rm (float) – rotation measure
rm_err (float) – error in rotation measure
f0 (float) – reference frequency at weighted mid-band
pa0 (float) – position angle at f0
- gaussian(x, a, mu, sig)[source]
Gaussian Pulse Function
- Parameters:
x (np.ndarray) – X data
a (float) – amplitude
mu (float) – position of Gaussian Pulse
sig (float) – width of Gaussian Pulse
- Returns:
Y data
- Return type:
np.ndarray
- lorentz(x, w, a)[source]
Lorentz function - Usually used to model scintillation bandwidth
- Parameters:
x (np.ndarray) – X data - Usually Frequency array
w (float) – width - Usually Scintillation Bandwidth
a (float) – Amplitude - Usually m^2 where m is modulation index
- Returns:
Y data
- Return type:
np.ndarray
- make_scatt_pulse_profile_func(n=1)[source]
Make scatter pulse profile wrapping function for fitting
- Parameters:
n (int) – number of pulses in scatter profile
- Returns:
func – lambda function for scatter pulse profile with n pulses
- Return type:
__func__
- model_curve(y, n: int = 5, samp: int | None = None)[source]
Fit Polynomial model to data
- Parameters:
y (np.ndarray) – data to model
n (int, optional) – Polynomial order, by default 5
samp (int, optional) – number of samples to sample modelled data, by default None
- Returns:
Modelled data
- Return type:
np.ndarray
- scat(dx, tau, sig=10)[source]
1 sided (positive side) exponential Scattering tail function
- Parameters:
x (np.ndarray) – X data
tau (float) – Scattering Timescale
sig (float) – number of standard deviations for defined scat function from mean
- Returns:
Y data
- Return type:
np.ndarray
- scatt_pulse_profile(x, p)[source]
Scattering time series profile with n pulses. Numerical convolution if done incorrectly can shift the resultant data in an undesirable way. One way to avoid this is to take a large window around the known signal to encompass the all pulses and convolve this with a symmetrical scattering tail. This of course isn’t realistic when taking a crop of data whose bounds cut through potential signal.
To keep this function robust, the algorithm implemented here takes each gaussian profile and extends it until symmetrical, this avoids any potential shifting due to improper convolution.
- Parameters:
x (np.ndarray) – X data array
p (Dict(float)) –
dictionary of parameters for scattered Gaussian pulses, for each pulse n:
[a[n]] - Pulse amplitude
[mu[n]] - Pulse position
[sig[n]] - Pulse width
[tau] - scattering timescale
- Returns:
y – Y data array
- Return type:
np.ndarray