STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
calibration_orchestrator Namespace Reference

Classes

class  SensorTypeInfo
class  UDPSensorReceiver
class  CalibrationOrchestrator

Functions

float adc_to_voltage (int adc_signed)
Dict[str, SensorTypeInfo] _build_sensor_types ()
 main ()

Variables

 level
 INFO
 format
 logger = logging.getLogger(__name__)
bool _cfg_loaded = True
bool ROBUSTNESS_AVAILABLE = True
bool ACTUATOR_COMM_AVAILABLE = True
str PACKET_HEADER_FORMAT = "<BBI"
int PACKET_HEADER_SIZE = 6
str SENSOR_DATA_PACKET_FORMAT = "<BB"
int SENSOR_DATA_PACKET_SIZE = 2
str SENSOR_DATA_CHUNK_FORMAT = "<I"
int SENSOR_DATA_CHUNK_SIZE = 4
str SENSOR_DATAPOINT_FORMAT = "<BI"
int SENSOR_DATAPOINT_SIZE = 5
int PACKET_TYPE_SENSOR_DATA = 3
int MAX_PACKET_SIZE = 512
float ADC_REF_VOLTAGE = 2.5
int ADC_FULL_SCALE = 2**31
Dict[str, SensorTypeInfo] SENSOR_TYPES = _build_sensor_types()
int N_PARAMS = 9

Detailed Description

Unified Calibration Orchestrator
=================================
Two-phase calibration lifecycle for all sensor types (PT, TC, RTD, LC)
backed by the full mathematical framework from the paper:

  ▸ Environmental-robust basis functions φ(v, e)  [Eq 66-72]
  ▸ Total Least Squares (TLS) calibration         [Eq 112-118]
  ▸ Bayesian regression with hierarchical priors   [Eq 126-149]
  ▸ Recursive Least Squares with forgetting        [Eq 162-166]
  ▸ Generalised Likelihood Ratio drift detection    [Eq 235-248]
  ▸ Empirical Bayes population prior evolution
  ▸ Active learning — system requests recalibration when quality degrades
  ▸ Transfer learning across sensors and sessions

Phase 1  – CALIBRATION (human-in-the-loop)
  User supplies known reference values.  The orchestrator collects raw ADC
  via UDP, converts to voltage, runs TLS + Bayesian update, validates
  quality, and saves coefficients.

Phase 2  – MONITORING / SELF-RECALIBRATION (autonomous, runs forever)
  After Phase 1 the orchestrator enters a continuous monitoring loop:
    ▸ RLS online parameter updates per channel (with forgetting factor)
    ▸ GLR drift detection (proper log-likelihood ratio)
    ▸ Bayesian full-recalibration when drift detected
    ▸ Empirical Bayes population prior propagation across all channels
    ▸ Active learning: system raises recalibration alerts
    ▸ Automatic periodic saves of coefficients + learned priors

Everything is config-driven — board IPs, ports, sensor counts, and
calibration paths are read from config/config.toml.

Usage:
  python3 calibration_orchestrator.py                   # Full lifecycle
  python3 calibration_orchestrator.py --skip-phase1     # Monitor only
  python3 calibration_orchestrator.py --phase1-only     # Calibrate & exit
  python3 calibration_orchestrator.py --sensors PT TC   # Specific types

Function Documentation

◆ _build_sensor_types()

Dict[str, SensorTypeInfo] calibration_orchestrator._build_sensor_types ( )
protected

Definition at line 150 of file calibration_orchestrator.py.

◆ adc_to_voltage()

float calibration_orchestrator.adc_to_voltage ( int adc_signed)

◆ main()

calibration_orchestrator.main ( )

Definition at line 1501 of file calibration_orchestrator.py.

References main().

Referenced by main().

Variable Documentation

◆ _cfg_loaded

bool calibration_orchestrator._cfg_loaded = True
protected

Definition at line 70 of file calibration_orchestrator.py.

◆ ACTUATOR_COMM_AVAILABLE

bool calibration_orchestrator.ACTUATOR_COMM_AVAILABLE = True

Definition at line 105 of file calibration_orchestrator.py.

◆ ADC_FULL_SCALE

int calibration_orchestrator.ADC_FULL_SCALE = 2**31

Definition at line 124 of file calibration_orchestrator.py.

◆ ADC_REF_VOLTAGE

float calibration_orchestrator.ADC_REF_VOLTAGE = 2.5

Definition at line 123 of file calibration_orchestrator.py.

◆ format

calibration_orchestrator.format

Definition at line 52 of file calibration_orchestrator.py.

◆ INFO

calibration_orchestrator.INFO

Definition at line 52 of file calibration_orchestrator.py.

◆ level

calibration_orchestrator.level

Definition at line 52 of file calibration_orchestrator.py.

◆ logger

calibration_orchestrator.logger = logging.getLogger(__name__)

Definition at line 54 of file calibration_orchestrator.py.

◆ MAX_PACKET_SIZE

int calibration_orchestrator.MAX_PACKET_SIZE = 512

Definition at line 120 of file calibration_orchestrator.py.

◆ N_PARAMS

int calibration_orchestrator.N_PARAMS = 9

Definition at line 183 of file calibration_orchestrator.py.

◆ PACKET_HEADER_FORMAT

str calibration_orchestrator.PACKET_HEADER_FORMAT = "<BBI"

Definition at line 111 of file calibration_orchestrator.py.

◆ PACKET_HEADER_SIZE

int calibration_orchestrator.PACKET_HEADER_SIZE = 6

Definition at line 112 of file calibration_orchestrator.py.

◆ PACKET_TYPE_SENSOR_DATA

int calibration_orchestrator.PACKET_TYPE_SENSOR_DATA = 3

Definition at line 119 of file calibration_orchestrator.py.

◆ ROBUSTNESS_AVAILABLE

bool calibration_orchestrator.ROBUSTNESS_AVAILABLE = True

Definition at line 97 of file calibration_orchestrator.py.

◆ SENSOR_DATA_CHUNK_FORMAT

str calibration_orchestrator.SENSOR_DATA_CHUNK_FORMAT = "<I"

Definition at line 115 of file calibration_orchestrator.py.

◆ SENSOR_DATA_CHUNK_SIZE

int calibration_orchestrator.SENSOR_DATA_CHUNK_SIZE = 4

Definition at line 116 of file calibration_orchestrator.py.

◆ SENSOR_DATA_PACKET_FORMAT

str calibration_orchestrator.SENSOR_DATA_PACKET_FORMAT = "<BB"

Definition at line 113 of file calibration_orchestrator.py.

◆ SENSOR_DATA_PACKET_SIZE

int calibration_orchestrator.SENSOR_DATA_PACKET_SIZE = 2

Definition at line 114 of file calibration_orchestrator.py.

◆ SENSOR_DATAPOINT_FORMAT

str calibration_orchestrator.SENSOR_DATAPOINT_FORMAT = "<BI"

Definition at line 117 of file calibration_orchestrator.py.

◆ SENSOR_DATAPOINT_SIZE

int calibration_orchestrator.SENSOR_DATAPOINT_SIZE = 5

Definition at line 118 of file calibration_orchestrator.py.

◆ SENSOR_TYPES

Dict[str, SensorTypeInfo] calibration_orchestrator.SENSOR_TYPES = _build_sensor_types()

Definition at line 180 of file calibration_orchestrator.py.