Calibration Module

The rocketlogger.calibration provides the support for processing calibration measurements, to calculate calibration parameters, and for generating RocketLogger calibration files.

RocketLogger Calibration Support.

Calibration file generation and accuracy verification.

Copyright (c) 2019-2020, ETH Zurich, Computer Engineering Group All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

rocketlogger.calibration.CALIBRATION_SETUP_BASIC = <rocketlogger.calibration.RocketLoggerCalibrationSetup object>

Basic calibration setup with 3 point measurements (min, zero, max).

rocketlogger.calibration.CALIBRATION_SETUP_SMU2450 = <rocketlogger.calibration.RocketLoggerCalibrationSetup object>

Reference calibration setup using the Keithley 2450 SMU setup.

rocketlogger.calibration.ROCKETLOGGER_CALIBRATION_FILE = '/etc/rocketlogger/calibration.dat'

Default RocketLogger calibration file location.

class rocketlogger.calibration.RocketLoggerCalibration(*args)[source]

Bases: object

RocketLogger calibration support class. Provides the calibration measurement data processing to generate calibration files.

The alternatives to initialize the calibrations class are:

  • Without parameter, a calibration class instance without initialized

    data is created

  • With 1 parameter, a file name, it serves as shortcut for

    read_calibration_file() to load an existing calibration file.

  • With 5 parameters it serves as shortcut for

    load_measurement_data() to load calibration measurement data.

load_design_data()[source]

Load calibration values derived from the design of the RocketLogger.

load_measurement_data(data_v, data_i1l, data_i1h, data_i2l, data_i2h)[source]

Load calibration measurement data from RocketLoggerData structures or RocketLogger data files. Loading new measurement data invalidates previously made calibration.

Parameters
  • data_v – Voltage V1-V4 calibration measurement data or filename

  • data_i1l – Current I1L calibration measurement data or filename

  • data_i1h – Current I1H calibration measurement data or filename

  • data_i2l – Current I2L calibration measurement data or filename

  • data_i2h – Current I2H calibration measurement data or filename

print_statistics()[source]

Print statistics of the calibration.

read_calibration_file(filename='/etc/rocketlogger/calibration.dat')[source]

Load an existing calibration file.

Parameters

filename – Name of the file to read the calibration values from

recalibrate(setup, fix_signs=True, target_offset_error=1, regression_algorithm=<function regression_linear>, **kwargs)[source]

Perform channel calibration using loaded measurement data. Overwrites any loaded calibration file parameters.

Parameters
  • setup – Calibration setup used for the measurements using the RocketLoggerCalibrationSetup helper class to describe

  • fix_signs – Set True to automatically fix sign error in calibration scales

  • target_offset_error – Factor in [1, inf) specifying the multiple of the zero error to use as offset error for the error calculations

  • regression_algorithm – Algorithm to use for the regression, taking the set-point measurement and reference values as arguments and providing the resulting offset and scale as output

  • kwargs – Optional names arguments passed to the regression algorithm function

write_calibration_file(filename='calibration.dat')[source]

Write the calibration to file.

Parameters

filename – Name of the file to write the calibration values to

write_log_file(filename='calibration.log')[source]

Write log of performed recalibration to file. Raises a calibration error if no recalibration has been performed beforehand.

Parameters

filename – Name of the file to write the calibration log to

exception rocketlogger.calibration.RocketLoggerCalibrationError[source]

Bases: Exception

RocketLogger calibration related errors.

class rocketlogger.calibration.RocketLoggerCalibrationSetup(setpoint_count, setpoint_step_voltage, setpoint_step_current_low, setpoint_step_current_high, setpoint_delay, dual_sweep)[source]

Bases: object

RocketLogger calibration measurement setup helper class.

Parameters
  • setpoint_count – number of calibration set-points per channel

  • setpoint_step_voltage – voltage step in volt between set-points

  • setpoint_step_current_low – low current step in ampere between set-points

  • setpoint_step_current_high – high current step in ampere between set-points

  • setpoint_delay – minimum delay in seconds between switching the set-point

  • dual_sweep – set True if dual sweep (up/down) is used

get_current_high_setpoints(adc_units=False)[source]

Get the real low current set-points used in the measurement setup.

Parameters

adc_units – set True to get step in estimated ADC bits

Returns

vector of the calibration set-points in ampere or ADC bits

get_current_high_step(adc_units=False)[source]

Get the absolute low current step used in the measurement setup.

Parameters

adc_units – set True to get step in estimated ADC bits

Returns

the absolute set-point step value in ampere or ADC bits

get_current_low_setpoints(adc_units=False)[source]

Get the real low current set-points used in the measurement setup.

Parameters

adc_units – set True to get step in estimated ADC bits

Returns

vector of the calibration set-points in ampere or ADC bits

get_current_low_step(adc_units=False)[source]

Get the absolute low current step used in the measurement setup.

Parameters

adc_units – set True to get step in estimated ADC bits

Returns

the absolute set-point step value in ampere or ADC bits

get_delay()[source]

Get the minimal delay between changing a set-point.

Returns

the minimal delay in seconds

get_setpoint_count()[source]

Get the number of set-points used in the setup set-point.

Returns

the number of set-points

get_voltage_setpoints(adc_units=False)[source]

Get the real voltage set-points used in the measurement setup.

Parameters

adc_units – set True to get step in estimated ADC bits

Returns

vector of the calibration set-points in volt or ADC bits

get_voltage_step(adc_units=False)[source]

Get the absolute voltage step used in the measurement setup.

Parameters

adc_units – set True to get step in estimated ADC bits

Returns

the absolute set-point step value in volt or ADC bits

rocketlogger.calibration.regression_linear(measurement, reference, zero_weight=1)[source]

Perform linear regression with extra weight on zero values.

Parameters
  • reference – the reference value to calibrate for

  • measurement – the measurement to calibrate on the reference

  • zero_weight – the relative weight of the zero set-point value compared to the other set-points (default: 1, equal weight than all other set-points)

Returns

(offset, scale) tuple of offset and scale values