plesty.fss.sine
Sine fit of a line position against a polarization rotator angle.
The two components of a fine-structure doublet are linearly polarized at right angles. While they are closer than the linewidth they appear as one line, and behind a rotating analyser the fitted centre of that line oscillates between them:
centre(θ) = mean + A·cos(k·(θ − axis))
k is the harmonic of the rotator: a half-wave plate turns the polarization
by twice its angle, so a doublet repeats every 90° of plate angle (k = 4);
a rotating polarizer repeats every 180° (k = 2). Behind either, the
peak-to-peak amplitude of the oscillation, 2·A, is the splitting.
A quarter-wave plate in front of a fixed polarizer also gives k = 4, at half
the contrast. A component linearly polarized at φ passes it with weight
½[1 + ½·cos 2φ + ½·cos(4θ − 2φ)] (the Stokes analysis of a rotating QWP), so
the centre of the doublet swings by only half the splitting, around a mean
shifted by a constant the fit absorbs. The splitting is then 2·A / ½:
CONTRAST holds the fraction of the splitting each rotator shows.
The model is linear in mean, A·sin(k·axis) and A·cos(k·axis), so
the fit is a weighted linear least-squares solve: no starting values, no
convergence to fail.
Attributes
Classes
Result of |
Functions
|
Fit |
|
Return the one-sigma error of a linear combination of the parameters. |
|
Return a fit whose every value is |
Module Contents
- plesty.fss.sine.HARMONICS: dict[str, int]
- plesty.fss.sine.CONTRAST: dict[str, float]
- class plesty.fss.sine.SineFit
Result of
fit_sine(), each value with its one-sigma error.- Variables:
mean – Mean line position (the unit of the positions).
amplitude – Half the peak-to-peak oscillation of the position,
≥ 0.axis_deg – Rotator angle of the longest position, in
[0, period).harmonic –
kof the model.r_squared – Coefficient of determination.
n_points – Finite points the fit used.
values – The raw parameters
(mean, a, b)ofmean + a·sin(kθ) + b·cos(kθ).covariance – Their covariance, in
valuesorder.
- mean: float
- mean_err: float
- amplitude: float
- amplitude_err: float
- axis_deg: float
- axis_deg_err: float
- harmonic: int
- r_squared: float
- n_points: int
- values: tuple[float, float, float]
- covariance: numpy.ndarray
- property period_deg: float
Rotator angle over which the position repeats.
- Return type:
float
- evaluate(angle_deg: numpy.typing.ArrayLike) numpy.ndarray
Evaluate the fitted position at rotator angles in degrees.
- Parameters:
angle_deg (numpy.typing.ArrayLike)
- Return type:
numpy.ndarray
- plesty.fss.sine.fit_sine(angle_deg: numpy.typing.ArrayLike, position: numpy.typing.ArrayLike, harmonic: int, sigma: numpy.typing.ArrayLike | None = None) SineFit
Fit
mean + A·cos(k·(θ − axis))to positions over rotator angles.Non-finite points are dropped. With sigma the fit is weighted by
1/σ²; as inplesty.lib.analyzer.fit_spectrum(), the covariance is scaled by the reduced chi-square, so the weights are relative. A point without a positive, finite error is dropped too — an unweighted point cannot be combined with weighted ones — unless no point has one, when the fit is unweighted.- Parameters:
angle_deg (numpy.typing.ArrayLike) – Rotator angle of each point, in degrees.
position (numpy.typing.ArrayLike) – Line position at each angle.
harmonic (int) –
k— 4 for a half-wave plate, 2 for a polarizer.sigma (numpy.typing.ArrayLike | None) – One-sigma error of each position.
- Returns:
The fit; every value is
nanwhen fewer than four points remain or the angles do not determine the model.- Raises:
ValueError – If the arrays differ in shape or harmonic is not positive.
- Return type:
- plesty.fss.sine._sigma(gradient: numpy.ndarray, covariance: numpy.ndarray) float
Return the one-sigma error of a linear combination of the parameters.
- Parameters:
gradient (numpy.ndarray)
covariance (numpy.ndarray)
- Return type:
float