stanza.analysis.fitting

Module Contents

Classes

NameDescription
PinchoffFitResultResult of pinchoff curve fitting.

Functions

NameDescription
pinchoff_curveSmooth pinchoff curve with coefficients a, b, c
derivative_extrema_indicesReturn the indices of key voltages for pinchoff curves.
_compute_initial_paramsCompute initial parameter estimates from normalized data.
_compute_parameter_boundsCompute robust parameter bounds from normalized data.
_map_index_to_voltageMap an array index to the corresponding voltage value.
compute_indices_from_thresholdFind cutoff and saturation indices based on threshold percentages.
fit_pinchoff_parametersFit the pinchoff parameters a, b, c of the pinchoff curve, and returns the cut-off, transition, and conducting voltages.

Data

DEFAULT_C_MARGIN DEFAULT_BOUNDS

API

1stanza.analysis.fitting.DEFAULT_C_MARGIN

Value: 10.0

1stanza.analysis.fitting.DEFAULT_BOUNDS

Value: [(1e-08, 1.0), (), ()]

1class stanza.analysis.fitting.PinchoffFitResult

Result of pinchoff curve fitting.

Attributes: v_cut_off: Cut-off voltage (where current flowing through the device approaches a near-zero value) v_transition: Transition voltage (midpoint of transition from cut-off to saturation) v_saturation: Conducting voltage (where current flowing through the device approaches a saturated state) popt: Fitted parameters [a, b, c] for pinchoff_curve in normalized space pcov: Covariance matrix of fitted parameters v_min: Minimum voltage value used for normalization v_max: Maximum voltage value used for normalization i_min: Minimum current value used for normalization i_max: Maximum current value used for normalization

Note: popt parameters are fitted in normalized [0,1] space. To generate the fitted curve in original space, use the fit_curve() method or manually normalize voltages before applying pinchoff_curve().

1v_cut_off: float | None

Value: None

1v_transition: float | None

Value: None

1v_saturation: float | None

Value: None

1popt: numpy.ndarray

Value: None

1pcov: numpy.ndarray

Value: None

1v_min: float

Value: 0.0

1v_max: float

Value: 1.0

1i_min: float

Value: 0.0

1i_max: float

Value: 1.0

1fit_curve(voltages: numpy.ndarray) -> numpy.ndarray

Generate fitted curve in original voltage/current space.

Parameters:

voltages
numpy.ndarray

Voltage array in original space

Returns:

Fitted current values in original space

1stanza.analysis.fitting.pinchoff_curve(
2 x: numpy.ndarray,
3 a: float,
4 b: float,
5 c: float
6) -> numpy.ndarray

Smooth pinchoff curve with coefficients a, b, c

From: Darulová, J. et al. Autonomous tuning and charge state detection of gate defined quantum dots. Physical Review, Applied 13, 054005 (2019).

Parameters:

Returns:

np.ndarray: Pinchoff current f(x) output

1stanza.analysis.fitting.derivative_extrema_indices(
2 x: numpy.ndarray, y: numpy.ndarray
3) -> tuple[int, int, int]

Return the indices of key voltages for pinchoff curves.

v_cut_off corresponds to the cut-off state (low current) v_saturation corresponds to the saturated state (high current) v_transition corresponds to the transition from cut-off to saturation (steepest slope)

Parameters:

Returns:

Tuple[int, int, int]: (transition_v_ind, saturation_v_ind, cut_off_v_ind)

1stanza.analysis.fitting._compute_initial_params(
2 v_norm: numpy.ndarray, i_norm: numpy.ndarray
3) -> numpy.ndarray

Compute initial parameter estimates from normalized data.

For inverted curves (decreasing with voltage), we use negative b values to represent the inversion while keeping amplitude positive.

1stanza.analysis.fitting._compute_parameter_bounds(
2 v_norm: numpy.ndarray, i_norm: numpy.ndarray
3) -> tuple[numpy.ndarray, numpy.ndarray]

Compute robust parameter bounds from normalized data.

Calculates appropriate lower and upper bounds for the three parameters [a, b, c] of the pinchoff_curve function based on the characteristics of the input data. The bounds are designed to constrain the optimization while allowing for both normal and inverted pinchoff curves.

Parameters:

v_norm
numpy.ndarray

Normalized voltage array (typically in [0, 1] range)

i_norm
numpy.ndarray

Normalized current array (typically in [0, 1] range)

Returns:

Tuple of (lower_bounds, upper_bounds) where each is a numpy array of shape (3,) containing bounds for parameters [a, b, c]:

  • a (amplitude): Positive value, typically 0.01*i_range to 2.0*i_range
  • b (slope): Can be negative for inverted curves, |b| <= 20.0/v_range
  • c (offset): Computed to ensure curve spans the voltage range If computed bounds are invalid (lower >= upper), falls back to DEFAULT_BOUNDS for that parameter.
1stanza.analysis.fitting._map_index_to_voltage(
2 index: int, voltages: numpy.ndarray
3) -> float | None

Map an array index to the corresponding voltage value.

Parameters:

index
int

Array index

voltages
numpy.ndarray

Array of voltage values

Returns:

Voltage at the given index, or None if index is out of bounds

1stanza.analysis.fitting.compute_indices_from_threshold(
2 fitted_current: numpy.ndarray,
3 percent_threshold: float,
4 original_current: numpy.ndarray | None = None
5) -> tuple[int, int]

Find cutoff and saturation indices based on threshold percentages.

Computes two thresholds: a lower threshold (min + percent_threshold * range) and an upper threshold (max - percent_threshold * range). Returns the indices where the fitted current first crosses these thresholds.

For normal curves (increasing current), returns where current rises above each threshold. For inverted curves (decreasing current), returns where current falls below each threshold.

Parameters:

fitted_current
numpy.ndarray

Fitted current values (normalized or unnormalized)

percent_threshold
float

Percentage (0 to 1) defining distance from min/max.

original_current
numpy.ndarray | None

Optional original current values before normalization.

Returns:

Tuple of (cutoff_index, saturation_index) where:

  • cutoff_index: Index where current enters the transition region from cutoff
  • saturation_index: Index where current enters the saturation region
    saturation_index is always >= cutoff_index (saturation occurs later in the voltage sweep)
1stanza.analysis.fitting.fit_pinchoff_parameters(
2 voltages: numpy.ndarray,
3 currents: numpy.ndarray,
4 sigma: float = 2.0,
5 percent_threshold: float | None = None
6) -> stanza.analysis.fitting.PinchoffFitResult

Fit the pinchoff parameters a, b, c of the pinchoff curve, and returns the cut-off, transition, and conducting voltages.

Parameters:

voltages
numpy.ndarray

Input voltages

currents
numpy.ndarray

Input currents

sigma
float

Gaussian filter bandwidth for smoothing

percent_threshold
float

If provided, use threshold-based cutoff instead of derivative-based. Value between 0 and 1 representing percentage above baseline tail of the fitted curve.

Returns:

PinchoffFitResult containing fitted voltages and parameters