ccatkidlib.analysis.fit package

Subpackages

Submodules

ccatkidlib.analysis.fit.fit module

ccatkidlib.analysis.fit.fit.circle_fit(x: ndarray, y: ndarray, bounds: tuple[list[float], list[float]] = None, full_output: bool = False, loss: str = 'soft_l1', f_scale: float = 1, method: str = 'trf')
ccatkidlib.analysis.fit.fit.init_circle_fit(x, y)
ccatkidlib.analysis.fit.fit.linear_fit(x: ndarray, y: ndarray) tuple[float, float]

Calculate 2D linear regression for given x and y np.arrays by solving matrix equation

Parameters:
  • x (np.ndarray) – Array of independent variable data

  • y (np.ndarray) – Array of dependent variable data

Returns:

Slope, intercept

Return type:

tuple[int, int]

ccatkidlib.analysis.fit.fit.phase_fit(f: ndarray, phase: ndarray, I: ndarray | None = None, Q: ndarray | None = None, R: float | None = None, window: float | None = None, unwrap_threshold=5.969026041820607, params: Parameters | None = None, nonlinear: bool = False, method: str = 'least_squares')

Method for fitting to the phase of a kinetic inductance detector (KID)

Notes

Using method from https://doi.org/10.1117/12.3019161.

Parameters:
  • f (np.ndarray) – Array of frequencies (in Hz)

  • phase (np.ndarray) – Array of phases (in rad)

  • I (np.ndarray, optional) – Array of in-phase components of complex transmission. Required for nonlinear fit

  • Q (np.ndarray, optional) – Array of quadrature components of complex transmission. Required for nonlinear fit

  • params (lmfit.Parameters, optional) – lmfit Parameters object to use as initial guess for fit

  • R (float, optional) – Radius of the IQ circle. Only required for nonlinear fit and if not passed as a lmfit.Parameter in params

  • nonlinear (bool, optional) – Whether to use nonlinear fit. Defaults to False

ccatkidlib.analysis.fit.fit.y_to_x_interp(ys, y_to_x_spline=None, x_to_y_spline=None)
ccatkidlib.analysis.fit.fit.y_to_x_spline(x: ndarray, y: ndarray, k: int = 3, y_low=None, y_up=None) tuple[None | BSpline, BSpline | None]
Parameters:
  • x (np.ndarray) – Array of independent variables

  • y (np.ndarray) – Array of dependent variables

  • k (int) – Degree of polynomials to interpolate with. Defaults to degree 3.

Returns:

y to x BSpline, x to y BSpline. Only returns one BSpline, the other will be None

Return type:

tuple[None | scipy.interpolate.BSpline, scipy.interpolate.BSpline | None]

Module contents