ops.calibration.data — Encapsulates data collected during calibration

This module contains the CalibrationData class, which encapsulates the data collected during calibration, and a set of functions used to save and load instances of this class.

The CalibrationData Class

class ops.calibration.data.CalibrationData

Encapsulates the data collected during calibration. The calibration data consists of a list of the measurements (accessible using the measurements property) and a set of three estimation functions: getCurrentFromTargetTemperature(), getFinalTemperatureFromCurrent(), and getTemperatureFromVoltage().

These are fitted to the measurements taken during calibration (using numpy.polyfit()) if at least minMeasurementsForEstimation measurements have been taken. To check whether the functions have been sucessfully fitted, use isComplete.

When measurements are added to or removed from the calibration data, the estimation functions are automatically refitted.

General Attributes

CalibrationData.system
The ProductionSystem whose calibration data the instance holds, or None. If the instance associated with a system is changed, this parameter is automatically updated. Otherwise, it is read-only.
CalibrationData.fileName

The name of the file the instance has last been saved to, or the name of the file the instance has been read from, or None.

CalibrationData itself does not use this attribute at all; it needs to be kept up to date by the client code responsible for saving and loading.

Measurements

CalibrationData.addMeasurement(current, voltage, temperature)

Adds a new measurement to the calibration data. Arguments are the heating current used for the measurement (in mA), and the final temperature sensor voltage (in V) and final temperature (in °C) that are reached with that current. Any measurements for that current that may have been added previously are replaced.

Also recalculates the estimation functions, and sends a CalibrationDataChanged event if the instance is associated with a ProductionSystem.

CalibrationData.removeMeasurement(current)

Removes the measurements taken for the given heating current (in mA) from the calibration data. Raises a KeyError if there are no measurements for that current.

Also recalculates the estimation functions, and sends a CalibrationDataChanged event if the instance is associated with a ProductionSystem.

CalibrationData.measurements
A tuple of tuples that each contain the heating current, final temperature sensor voltage, and final heating temperature for a measurement that is part of the calibration data. The tuple’s items are ordered by their heating currents. Read-only.
CalibrationData.heatingCurrents
A sorted tuple of the heating currents the measurements that are part of the calibration data have been taken for. Read-only.
CalibrationData.temperatureSensorVoltages
A tuple of the temperature sensor voltages that have been measured during calibration, sorted by the heating currents they have been measured for. Read-only.
CalibrationData.temperatures
A tuple of the heating temperatures that have been measured during calibration, sorted by the heating currents they have been measured for. Read-only.
CalibrationData.hasMeasurements
Indicates whether the instance has at least one measurement.

Estimation Functions

CalibrationData.isComplete
Indicates whether all three estimations functions have been sucessfully fitted. Read-only.
CalibrationData.getCurrentFromTargetTemperature(targetTemperature)
Estimates the heating current (in mA) necessary for the heater to reach, but not exceed, a given target temperature (in °C). Raises a NotCalibratedError if the estimation function could not be fitted.
CalibrationData.getFinalTemperatureFromCurrent(current)
Estimates the temperature (in °C) that the heater will reach, but not exceed, for a given heating current (in mA). Raises a NotCalibratedError if the estimation function could not be fitted.
CalibrationData.getTemperatureFromVoltage(voltage)
Estimates the temperature (in °C) that corresponds to a given temperature sensor voltage (in V). Raises a NotCalibratedError if the estimation function could not be fitted.

Fitting

CalibrationData.polynomialDegree
The degree of the polynomials that make up the estimation functions. This is a class attribute, but can be set on an instance to override the default value.
CalibrationData.minMeasurementsForEstimation
The number of measurements that is required before the estimation functions are fitted. This is a class attribute, but can be set on an instance to override the default value.

Persistence Functions

CalibrationData objects are saved as XML documents, using the extension cal. The files are structured according to the following XML Schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="calibration-data">
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="measurement">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="current" type="xs:double" />
              <xs:element name="voltage" type="xs:double" />
              <xs:element name="temperature" type="xs:double" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

The docment is not formally validated when it is parsed, however. Some errors, such as extraneous elements, will slip through.

ops.calibration.data.toXML(calibrationData)
Creates an XML document from the given CalibrationData object and returns it as a string.
ops.calibration.data.fromXML(string)

Creates a CalibrationData object from the given string, which must be a valid XML document.

If an error occurs while parsing the document, the function returns None.