nibcq.compensation.Compensation

class nibcq.compensation.Compensation

Comprehensive compensation data container for ACIR/EIS measurement error correction.

This class serves as the central data structure for managing compensation information used to correct systematic errors in impedance measurements. It contains all necessary components including the compensation method, calibration data, temperature information, and frequency-specific compensation parameters.

The compensation system supports multiple correction methods: - NO_COMPENSATION: Raw measurements without correction - SHORT: Correction using short-circuit calibration data - GOLDEN_DUT: Correction using known reference device data

compensation_method

The type of compensation to apply (from CompensationMethod enum). Determines how compensation_parameters are used in calculations.

Type:

CompensationMethod

compensation_file_path

Optional path to the file containing compensation data. Used for traceability and reloading calibration information.

Type:

str, optional

target_temperature

Temperature conditions for optimal compensation accuracy. Compensation may be temperature-dependent for high-precision work.

Type:

CenteredRange, optional

compensation_parameters

Dictionary mapping frequencies (Hz) to complex compensation values (Ohms). Core calibration data for error correction.

Type:

Dict[float, complex]

Example

>>> compensation = Compensation(
...     compensation_method=CompensationMethod.SHORT,
...     compensation_file_path="/path/to/cal.json",
...     compensation_parameters={1000.0: 10+5j, 2000.0: 15+3j}
... )
>>> compensated_z = compensation.get_compensated_impedance(
...     frequency=1000.0,
...     measured_impedance=100+20j
... )
>>> # Result: 100+20j - 10+5j = 90+15j (SHORT compensation)
to_list() list[CompensationParameter]

Converts the AllCompensation instance to a list of CompensationParameters.

Parameters:

compensation (Compensation) – The in-memory compensation data to convert.

Returns:

A list of CompensationParameters extracted from the compensation data.

Return type:

list[CompensationParameter]

classmethod from_file(method: nibcq.enums.CompensationMethod, file_path: str) Compensation

Creates an AllCompensation instance from a compensation file.

Parameters:
  • method (CompensationMethod) – The compensation method to associate with this data

  • file_path (str) – Path to the compensation file to load

Returns:

Instance loaded from the file

Return type:

Compensation

get_compensated_impedance(frequency: float, measured_impedance: complex, interpolation_mode: nibcq.enums.InterpolationMode = None) complex

Get the compensated impedance value for a specific frequency.

This method applies compensation based on the compensation method without needing to convert between list/dict representations or use separate subtraction methods.

Parameters:
  • frequency (float) – The frequency for which to get compensated impedance

  • measured_impedance (complex) – The raw measured impedance value

  • interpolation_mode (InterpolationMode, optional) – Interpolation mode for compensation lookup (defaults to NEAREST)

Raises:

CompensationMethodError – If the compensation method is not supported or incorrect

Returns:

The compensated impedance value

Return type:

complex