nibcq.measurement.Measurement

class nibcq.measurement.Measurement(device: nibcq._device.Device, test_parameters: TestParameters)

Bases: abc.ABC, nibcq.temperature.TemperatureAware

Abstract base class for all measurement subclasses.

This class provides the basic structure and properties for any measurement process. You will need to implement the ‘configure’ and ‘measure’ methods in subclasses. It also provides general properties for hardware, configuration parameters, result, and calibration file path. This class is designed to be extended for specific measurement types like OCV, ACIR, or EIS.

Parameters:
property test_parameters: TestParameters

Get the current test parameters for the measurement.

Returns the configuration parameters that define how the measurement should be performed, including settings like powerline frequency and other measurement-specific parameters.

Returns:

The current test parameters configuration

Return type:

TestParameters

Examples

>>> measurement = Measurement(device)
>>> params = measurement.test_parameters
>>> print(params.powerline_frequency)
PowerlineFrequency.FREQ_60_HZ
property result: float | SMUResult | list[SMUResult] | list[tuple[nibcq.switch.SMUCellData, SMUResult]] | list[tuple[nibcq.switch.SMUCellData, list[SMUResult]]] | list[tuple[str, tuple[datetime.datetime, datetime.datetime, float]]] | Any

Get the result of the last measurement.

Returns the measurement result from the most recent measurement operation. The result type depends on the specific measurement implementation and whether switching was used:

  • Single measurements:
    • float for OCV and DCIR

    • SMUResult for ACIR

    • list[SMUResult] for EIS

  • Switching measurements:
    • list[tuple[SMUCellData, SMUResult]] for ACIR with switching

    • list[tuple[SMUCellData, list[SMUResult]]], for EIS with switching

    • list[tuple[str, tuple[datetime, datetime, float]]], for OCV with switching

Returns:

float | SMUResult | list[SMUResult] | list[tuple[SMUCellData, SMUResult]] | list[tuple[SMUCellData, list[SMUResult]]] | list[tuple[str, tuple[datetime, datetime, float]]] | Any: The measurement result(s). For switching measurements, returns a list of tuples where each tuple contains the cell data and its corresponding results.

Raises:

RuntimeError – If no measurement has been performed yet or if the result is not available

Return type:

Union[float, SMUResult, list[SMUResult], list[tuple[nibcq.switch.SMUCellData, SMUResult]], list[tuple[nibcq.switch.SMUCellData, list[SMUResult]]], list[tuple[str, tuple[datetime.datetime, datetime.datetime, float]]], Any]

Examples

>>> measurement.run(test_parameters)
>>> result = measurement.result
>>> print(f"Measurement result: {result}")
>>>
>>> # For switching measurements
>>> switching_results = measurement.run_with_switching(compensation)
>>> for cell_data, cell_results in measurement.result:
...     print(f"Cell {cell_data.cell_serial_number}: {len(cell_results)} results")
abstractmethod run()

Run the measurement process with the given test parameters used to configure the device.

Returns:

A single result which is calculated and populated after fetching the data.

Return type:

Any

property acceptable_temperature_delta: float

Get the acceptable temperature delta for compensation validation.

Returns the maximum allowed temperature difference from the device’s temperature capability. This is a pass-through property that delegates to the underlying TemperatureCapability.

Returns:

The acceptable temperature delta in degrees, or NaN if no temperature capability

Return type:

float

Examples

>>> measurement = EIS(device)
>>> measurement.acceptable_temperature_delta = 2.5
>>> delta = measurement.acceptable_temperature_delta
property temperature: float

Get the latest temperature reading from the device.

Returns:

The most recent temperature measurement, or NaN if no temperature capability

Return type:

float

property temperature_range: CenteredRange

Get the latest temperature reading from the device, coupled with the user-set delta.

Returns:

A CenteredRange representing the most recent temperature measurement (NaN if not available), along with the acceptable temperature delta (NaN if not set).

Return type:

CenteredRange

measure_temperature() CenteredRange

Get a new temperature reading from the device.

Returns:

Current temperature reading, or NaN if no temperature capability

Return type:

CenteredRange

validate_temperature(target_temperature: CenteredRange) bool

Validate the current temperature against the compensation file’s target.

Delegates to the device’s temperature capability for validation. The capability handles all validation logic including checking if thermocouple is configured, using overridden delta values if set, and printing appropriate warnings.

Parameters:

target_temperature (CenteredRange) – The target temperature parameters for validation

Returns:

True if thermocouple is configured and temperature is within range.

False if thermocouple is not configured (capability missing or not set up), or if target temperature/delta is NaN.

Return type:

bool

Raises:

TemperatureError – If the current temperature exceeds the target ± delta range (only raised when capability is configured)

Examples

>>> measurement = EIS(device)
>>> measurement.measure_temperature()
>>> target = compensation.temperature_parameter
>>> is_valid = measurement.validate_temperature(target)