lisa_noise.spline¶
Functions¶
|
Add functionality to return equally spaced knots in either log or |
|
Evaluate a spline at pre-computed frequencies via the design matrix. |
|
Build a cubic spline design matrix. |
|
Evaluate a spline that fits the provided data. By default a cubic spline |
|
Evaluate a spline plus a series of inverse lorentzians that fits the |
Module Contents¶
- lisa_noise.spline.knots(minimum, maximum, n_knots, ghost_knots=None, log_knots=True, ghost_minimum=None, ghost_maximum=None)¶
Add functionality to return equally spaced knots in either log or linear spaces. By default, n_knots are placed between the specified minimum and maximum values, ghost_knots/2 are placed between ghost_minimum and minimum, and ghost_knots/2 are placed between maximum and ghost_maximum.
- Parameters:
minimum (float) – minimum value to start real knot placement
maximum (float) – maximum value to end real knot placement
n_knots (int) – number of knots to use for the real knot placement
ghost_knots (int, optional) – number of ghost knots to place
ghost_minimum (float, optional) – minimum value to start the ghost knot placement. If None, minimum / 10 is used. Default None
ghost_maximum (float, optional) – maximum value to start the ghost knot placement. If None, maximum * 10 is used. Default None
log_knots (Bool, optional) – if True, space the knots evenly in log space
- lisa_noise.spline.eval_spline_from_basis(B_free, b_ghost, params)¶
Evaluate a spline at pre-computed frequencies via the design matrix.
Equivalent to calling the spline directly with the full knot values but performs only a matmul — no scipy calls. Intended for use inside MCMC hot loops with any array backend.
- Parameters:
B_free ((N_eval, N_free) array) – Basis columns for the free (non-ghost) knots, from
spline_basis().b_ghost ((N_eval,) array) – Pre-computed contribution of the fixed ghost knots.
params ((N_free,) array) – Current knot values (e.g. log10 PSD at the free knots).
- Returns:
Spline values at the evaluation frequencies.
- Return type:
(N_eval,) array
- lisa_noise.spline.spline_basis(knot_x, eval_x, log=True)¶
Build a cubic spline design matrix.
Converts spline evaluation into a pure matrix-vector multiply with no scipy calls at evaluation time:
y(eval_x) ≈ B @ y_knots
- Parameters:
knot_x ((N_knots,) array) – Knot positions.
eval_x ((N_eval,) array) – Positions at which to evaluate the spline.
log (bool, optional) – If True, work in log10 space (both axes). Recommended for quantities spanning many decades such as PSDs. Default True.
- Returns:
B – Design matrix.
B @ y_knotsgives spline values ateval_x.- Return type:
(N_eval, N_knots) ndarray
- lisa_noise.spline.spline(frequency_array, data, knots, bounds=None, kind='cubic', **kwargs)¶
Evaluate a spline that fits the provided data. By default a cubic spline is used.
- Parameters:
frequency_array (np.ndarray) – array of frequencies to evaluate the spline
data (np.ndarray) – data to interpolate
knots (np.ndarray) – knot locations for the spline
bounds (np.ndarray, optional) – frequency bounds to evaluate the interpolant. Default None
kind (str, optional) – spline type to use. Must be an option for the scipy.interpolate.interp1d function. Default ‘cubic’
kwargs (dict, optional) – all kwargs passed to the scipy.interpolate.interp1d function
- lisa_noise.spline.spline_plus_inverse_lorentzian(frequency_array, data, knots, n_lorentz, kind='cubic', min_val=1e-16, smoothing_window=5, smoothing_poly=2, alpha=0.7, log=True)¶
Evaluate a spline plus a series of inverse lorentzians that fits the provided data. By default a cubic spline is used.
- Parameters:
frequency_array (np.ndarray) – array of frequencies to evaluate the spline
data (np.ndarray) – data to interpolate
knots (np.ndarray) – knot locations for the spline
n_lorentz (int) – number of lorentzians to include in the fit
kind (str, optional) – spline type to use. Must be an option for the scipy.interpolate.interp1d function. Default ‘cubic’
min_val (float, optional) – minimum value for the inverse lorentzian. Default 1e-16
smoothing_window (int, optional) – The length of the filter window used to smooth the final PSD. Default 5
smoothing_poly (int, optional) – The order of the polynomial used to smooth the final PSD. Default 2
alpha (float, optional) – The smoothing used in a sine-squared taper when connecting the lorentzians to the base spline
log (bool, optional) – If True, return the log of the spline plus lorentzian