Calibration of housekeeping parameters¶
One of the duty of the electronic boards used by Strip is to measure instrument parameters like currents, voltages, temperatures, etc. These parameters are called housekeepings and are vital to monitor the status of the instrument. Like scientific samples, housekeeping parameters are measured by digital units and are stored as integer numbers, nicknamed ADU (analog-to-digital unit). Calibration curves must be applied to ADU numbers to retrieve a physically meaningful unit (e.g., milliampere, Kelvin, etc.). These calibration curves are provided in the form of Excel spreadsheets, and striptease provides a few utilities to ease the conversion between ADUs and physical units.
Usage of calibration tables¶
The most basic functions to apply calibration tables are provided by
the class CalibrationTables
. This class implements two
methods, named physical_units_to_adu()
and
adu_to_physical_units()
, which perform the two
conversions:
from calibration import CalibrationTables
cal = CalibrationTables()
print(cal.physical_units_to_adu(
polarimeter="R0",
hk="idrain",
component="HA1",
value=1000,
))
A CalibrationTable
object connects with the server when the
constructor is called, because it needs to know which is the
association between the board name (in the example above, R
) and
the board number used by the electronics. Once the object cal
has
been constructed, the connection is no longer used. If you have
already instanced a Config
object, you can pass it to the
constructor and it will be reused:
from calibration import CalibrationTables
from config import Config
from striptease import StripConnection
conn = StripConnection()
conn.login()
config = Config()
config.load(conn)
# Use "conn" and "config"
# …
# Reuse the configuration object
cal = CalibrationTables(config)
-
class
calibration.
CalibrationTables
(config=None)[source]¶ Calibration tables used to convert HK ADUs into physical units and back
This class loads the calibration tables for housekeeping parameters from a set of Excel files.
You can pass a
striptease.Config
class to this class. Not doing so is equivalent to the following code:from calibration import CalibrationTables from config import Config from striptease import StripConnection with StripConnection() as conn: conf = Config() conf.load(conn) cal_tables = CalibrationTables(conf)
-
adu_to_physical_units
(polarimeter, hk, component, value)[source]¶ Convert ADUs into physical units for an housekeeping parameter.
The meaning of the parameters polarimeter, hk, and component is the same as in
get_calibration_curve()
.
-
get_calibration_curve
(polarimeter, hk, component)[source]¶ Return a
CalibrationCurve
object for an housekeeping parameterParameters: - polarimeter (str) – the name of the polarimeter, e.g., I4 or W3
- hk (str) –
one of the following strings:
vdrain
: drain voltageidrain
: drain currentvgate
: gate voltagevphsw
: voltage pin for a phase switchiphsw
: current pin for a phase switch
- component (str) – name of the component within the
polarimeter. For LNAs, you can use whatever string
works with
striptease.get_lna_num()
. For phase switches, you must pass an integer number in the range 0…3.
Returns: A
CalibrationCurve
object.
-
physical_units_to_adu
(polarimeter, hk, component, value)[source]¶ Convert physical units into ADUs for an housekeeping parameter.
The meaning of the parameters polarimeter, hk, and component is the same as in
get_calibration_curve()
.
-
Low-level calibration functions¶
A calibration curve is stored in a CalibrationCurve object, which has the following fields:
slope
(float)intercept
(float)mul
(int)div
(int)add
(int)
The operation carried out by the electronics to convert physical units to ADU is the following (integer operations):
adu = value * mul / div + add
However, Striptease uses the following floating-point operation:
adu = int(value * slope + intercept)
These operations are implemented by the functions
calibration.physical_units_to_adu()
and
calibration.adu_to_physical_units()
, which require a
CalibrationCurve object.
-
class
calibration.
CalibrationCurve
(slope, intercept, mul, div, add)¶ Linear calibration curve (from physical units to ADU) for an housekeeping parameter.
-
slope
¶ Floating-point value for the slope of the calibration curve
-
intercept
¶ Floating-point value for the additive offset of the calibration curve
-
mul
¶ Integer numerator of the slope of the calibration curve
-
div
¶ Integer denominator of the slope of the calibration curve
-
add
¶ Integer value for the additive offset of the calibration curve
-