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

Public Member Functions

 __init__ (self, Optional[List[str]] sensor_names=None)
 start_receiver (self)
 stop (self)
 run_phase1 (self)
 run_phase2 (self)
 run_phase2_background (self)
 clear_calibration (self)
 propagate_zero_point (self, Tuple[str, int] calibrated_key, str stype)
 load_existing (self)

Public Attributes

dict sensor_types = {}
dict active_connectors = {}
dict board_ip_to_type = {}
dict ip_to_board_id = {}
dict robust = {}
tuple channel_to_board_ip
 engine
Dict[Tuple[str, int], deque] live_adc
dict ip_to_type = {}
dict references = {}
 env_state = EnvironmentalState()
 receiver = UDPSensorReceiver(port)
 min_points = int(orch_cfg.get("min_points", 5))
 target_points = int(orch_cfg.get("target_points", 15))
 max_points = int(orch_cfg.get("max_points", 30))
 target_r2 = float(orch_cfg.get("target_r_squared", 0.99))
 min_r2 = float(orch_cfg.get("min_r_squared", 0.95))
 glr_threshold = float(orch_cfg.get("drift_glr_threshold", 2.0))
 consensus_enabled = bool(orch_cfg.get("consensus_enabled", True))
 consensus_threshold = float(phase2.get("consensus_threshold_psi", 1.0))
 min_consensus_sensors = int(env_cal.get("min_consensus_sensors", 2))
 self_cal_alpha_threshold
 agreement_threshold = float(orch_cfg.get("agreement_threshold", 0.6))
dict latest_predictions = {}
bool running = False
bool collecting = False
str phase = "IDLE"
Optional[threading.Thread] monitor_thread = None
list pending_alerts = []
int pending_alerts_max = 50
 actuator_comm = None
dict stats
 robustness_manager = None
dict actuator_statuses = {}

Protected Member Functions

 _drain_queue (self)
 _parse_actuator_status (self)
 _print_actuator_status (self)
float _adc_uncertainty (self, key)
 _online_update (self, Tuple[str, int] key, float adc_code)
 _collect (self, float dur)
 _tls_bayesian_fit_all (self)
 _print_alerts (self)
 _run_consensus_and_self_cal (self)
 _save_all (self)
 _save_prior (self)
 _load_prior_from_polynomial_calibration (self)
 _print_status (self)
 _print_live (self)

Protected Attributes

dict _idx_to_key = {}
dict _key_to_idx = {}
 _save_interval = float(orch_cfg.get("auto_save_interval_sec", 300))
 _status_interval = float(orch_cfg.get("status_interval_sec", 30))
 _actuator_raw_samples = deque(maxlen=100)

Detailed Description

Two-phase calibration lifecycle backed by the paper's full math:
  • RobustCalibrationFramework per channel  (TLS, Bayesian, GLR, RLS)
  • AutonomousCalibrationEngine for cross-sensor empirical Bayes +
    active learning

Definition at line 282 of file calibration_orchestrator.py.

Constructor & Destructor Documentation

◆ __init__()

calibration_orchestrator.CalibrationOrchestrator.__init__ ( self,
Optional[List[str]] sensor_names = None )

Definition at line 290 of file calibration_orchestrator.py.

Member Function Documentation

◆ _adc_uncertainty()

float calibration_orchestrator.CalibrationOrchestrator._adc_uncertainty ( self,
key )
protected

◆ _collect()

◆ _drain_queue()

◆ _load_prior_from_polynomial_calibration()

calibration_orchestrator.CalibrationOrchestrator._load_prior_from_polynomial_calibration ( self)
protected
Load polynomial calibration (calibration_poly_coeffs + adc_norm_min/scale)
from calibration/ or calibration_backups/ and use as initial theta for RCFs.
Fixes 150 PSI reading as 56.8 — the default prior theta[1]=200 has wrong slope.

Definition at line 1198 of file calibration_orchestrator.py.

References robust.

Referenced by load_existing().

◆ _online_update()

◆ _parse_actuator_status()

calibration_orchestrator.CalibrationOrchestrator._parse_actuator_status ( self)
protected
Parse actuator current sense data from raw samples

Definition at line 619 of file calibration_orchestrator.py.

References _actuator_raw_samples.

◆ _print_actuator_status()

calibration_orchestrator.CalibrationOrchestrator._print_actuator_status ( self)
protected
Print actuator current sense status

Definition at line 641 of file calibration_orchestrator.py.

References actuator_statuses, and time.time().

◆ _print_alerts()

calibration_orchestrator.CalibrationOrchestrator._print_alerts ( self)
protected

Definition at line 933 of file calibration_orchestrator.py.

References _idx_to_key, and pending_alerts.

Referenced by run_phase2().

◆ _print_live()

◆ _print_status()

◆ _run_consensus_and_self_cal()

◆ _save_all()

◆ _save_prior()

calibration_orchestrator.CalibrationOrchestrator._save_prior ( self)
protected
Save the learned population prior for warm-starting future sessions.

Definition at line 1176 of file calibration_orchestrator.py.

References engine, feedtwin.session.model.AssemblyReport.engine, and feedtwin.session.model.Model.engine.

Referenced by _save_all().

◆ _tls_bayesian_fit_all()

◆ clear_calibration()

calibration_orchestrator.CalibrationOrchestrator.clear_calibration ( self)
Clear all references and per-channel calibration data. User can start fresh.

Definition at line 947 of file calibration_orchestrator.py.

References references, and robust.

◆ load_existing()

calibration_orchestrator.CalibrationOrchestrator.load_existing ( self)
Load latest calibrations + learned prior for cold-start Phase 2.

Definition at line 1276 of file calibration_orchestrator.py.

References _load_prior_from_polynomial_calibration(), engine, feedtwin.session.model.AssemblyReport.engine, feedtwin.session.model.Model.engine, robust, and sensor_types.

◆ propagate_zero_point()

calibration_orchestrator.CalibrationOrchestrator.propagate_zero_point ( self,
Tuple[str, int] calibrated_key,
str stype )

◆ run_phase1()

◆ run_phase2()

◆ run_phase2_background()

calibration_orchestrator.CalibrationOrchestrator.run_phase2_background ( self)

◆ start_receiver()

◆ stop()

Member Data Documentation

◆ _actuator_raw_samples

calibration_orchestrator.CalibrationOrchestrator._actuator_raw_samples = deque(maxlen=100)
protected

Definition at line 557 of file calibration_orchestrator.py.

Referenced by _parse_actuator_status().

◆ _idx_to_key

dict calibration_orchestrator.CalibrationOrchestrator._idx_to_key = {}
protected

Definition at line 391 of file calibration_orchestrator.py.

Referenced by _print_alerts().

◆ _key_to_idx

dict calibration_orchestrator.CalibrationOrchestrator._key_to_idx = {}
protected

Definition at line 392 of file calibration_orchestrator.py.

Referenced by _online_update(), and _run_consensus_and_self_cal().

◆ _save_interval

calibration_orchestrator.CalibrationOrchestrator._save_interval = float(orch_cfg.get("auto_save_interval_sec", 300))
protected

Definition at line 431 of file calibration_orchestrator.py.

Referenced by run_phase2().

◆ _status_interval

calibration_orchestrator.CalibrationOrchestrator._status_interval = float(orch_cfg.get("status_interval_sec", 30))
protected

Definition at line 432 of file calibration_orchestrator.py.

Referenced by run_phase2().

◆ active_connectors

dict calibration_orchestrator.CalibrationOrchestrator.active_connectors = {}

Definition at line 301 of file calibration_orchestrator.py.

◆ actuator_comm

calibration_orchestrator.CalibrationOrchestrator.actuator_comm = None

◆ actuator_statuses

dict calibration_orchestrator.CalibrationOrchestrator.actuator_statuses = {}

Definition at line 632 of file calibration_orchestrator.py.

Referenced by _print_actuator_status().

◆ agreement_threshold

calibration_orchestrator.CalibrationOrchestrator.agreement_threshold = float(orch_cfg.get("agreement_threshold", 0.6))

Definition at line 446 of file calibration_orchestrator.py.

Referenced by _run_consensus_and_self_cal().

◆ board_ip_to_type

dict calibration_orchestrator.CalibrationOrchestrator.board_ip_to_type = {}

Definition at line 302 of file calibration_orchestrator.py.

◆ channel_to_board_ip

tuple calibration_orchestrator.CalibrationOrchestrator.channel_to_board_ip
Initial value:
= (
{}
)

Definition at line 358 of file calibration_orchestrator.py.

◆ collecting

bool calibration_orchestrator.CalibrationOrchestrator.collecting = False

Definition at line 458 of file calibration_orchestrator.py.

Referenced by _collect().

◆ consensus_enabled

calibration_orchestrator.CalibrationOrchestrator.consensus_enabled = bool(orch_cfg.get("consensus_enabled", True))

Definition at line 434 of file calibration_orchestrator.py.

Referenced by _run_consensus_and_self_cal().

◆ consensus_threshold

calibration_orchestrator.CalibrationOrchestrator.consensus_threshold = float(phase2.get("consensus_threshold_psi", 1.0))

Definition at line 441 of file calibration_orchestrator.py.

◆ engine

calibration_orchestrator.CalibrationOrchestrator.engine
Initial value:
= AutonomousCalibrationEngine(
n_sensors=total_channels,
n_params=N_PARAMS,
forgetting_factor=forgetting,
)

Definition at line 384 of file calibration_orchestrator.py.

Referenced by _online_update(), _print_status(), _run_consensus_and_self_cal(), _save_all(), _save_prior(), and load_existing().

◆ env_state

calibration_orchestrator.CalibrationOrchestrator.env_state = EnvironmentalState()

◆ glr_threshold

calibration_orchestrator.CalibrationOrchestrator.glr_threshold = float(orch_cfg.get("drift_glr_threshold", 2.0))

◆ ip_to_board_id

dict calibration_orchestrator.CalibrationOrchestrator.ip_to_board_id = {}

Definition at line 347 of file calibration_orchestrator.py.

◆ ip_to_type

dict calibration_orchestrator.CalibrationOrchestrator.ip_to_type = {}

Definition at line 405 of file calibration_orchestrator.py.

Referenced by _drain_queue().

◆ latest_predictions

dict calibration_orchestrator.CalibrationOrchestrator.latest_predictions = {}

Definition at line 449 of file calibration_orchestrator.py.

Referenced by _online_update(), and _run_consensus_and_self_cal().

◆ live_adc

Dict[Tuple[str, int], deque] calibration_orchestrator.CalibrationOrchestrator.live_adc
Initial value:
= defaultdict(
lambda: deque(maxlen=200)
)

Definition at line 400 of file calibration_orchestrator.py.

Referenced by _adc_uncertainty(), _online_update(), _print_live(), _print_status(), _run_consensus_and_self_cal(), and propagate_zero_point().

◆ max_points

calibration_orchestrator.CalibrationOrchestrator.max_points = int(orch_cfg.get("max_points", 30))

Definition at line 427 of file calibration_orchestrator.py.

◆ min_consensus_sensors

calibration_orchestrator.CalibrationOrchestrator.min_consensus_sensors = int(env_cal.get("min_consensus_sensors", 2))

Definition at line 442 of file calibration_orchestrator.py.

Referenced by _run_consensus_and_self_cal().

◆ min_points

calibration_orchestrator.CalibrationOrchestrator.min_points = int(orch_cfg.get("min_points", 5))

Definition at line 425 of file calibration_orchestrator.py.

Referenced by _save_all(), and _tls_bayesian_fit_all().

◆ min_r2

calibration_orchestrator.CalibrationOrchestrator.min_r2 = float(orch_cfg.get("min_r_squared", 0.95))

Definition at line 429 of file calibration_orchestrator.py.

◆ monitor_thread

Optional[threading.Thread] calibration_orchestrator.CalibrationOrchestrator.monitor_thread = None

Definition at line 460 of file calibration_orchestrator.py.

Referenced by run_phase2_background(), and stop().

◆ pending_alerts

calibration_orchestrator.CalibrationOrchestrator.pending_alerts = []

Definition at line 463 of file calibration_orchestrator.py.

Referenced by _online_update(), and _print_alerts().

◆ pending_alerts_max

int calibration_orchestrator.CalibrationOrchestrator.pending_alerts_max = 50

Definition at line 464 of file calibration_orchestrator.py.

Referenced by _online_update().

◆ phase

str calibration_orchestrator.CalibrationOrchestrator.phase = "IDLE"

◆ receiver

calibration_orchestrator.CalibrationOrchestrator.receiver = UDPSensorReceiver(port)

Definition at line 422 of file calibration_orchestrator.py.

Referenced by _drain_queue(), start_receiver(), and stop().

◆ references

dict calibration_orchestrator.CalibrationOrchestrator.references = {}

◆ robust

◆ robustness_manager

calibration_orchestrator.CalibrationOrchestrator.robustness_manager = None

Definition at line 497 of file calibration_orchestrator.py.

Referenced by _save_all().

◆ running

bool calibration_orchestrator.CalibrationOrchestrator.running = False

◆ self_cal_alpha_threshold

calibration_orchestrator.CalibrationOrchestrator.self_cal_alpha_threshold
Initial value:
= float(
orch_cfg.get("self_cal_alpha_threshold", 0.6)
)

Definition at line 443 of file calibration_orchestrator.py.

Referenced by _run_consensus_and_self_cal().

◆ sensor_types

dict calibration_orchestrator.CalibrationOrchestrator.sensor_types = {}

Definition at line 292 of file calibration_orchestrator.py.

Referenced by _print_status(), _save_all(), load_existing(), and run_phase1().

◆ stats

dict calibration_orchestrator.CalibrationOrchestrator.stats
Initial value:
= {
"phase1_points": 0,
"tls_fits": 0,
"bayesian_updates": 0,
"rls_updates": 0,
"drifts_detected": 0,
"recalibrations": 0,
"active_learning_alerts": 0,
"saves": 0,
"start_time": time.time(),
}
TOML_NODISCARD_CTOR time() noexcept=default

Definition at line 484 of file calibration_orchestrator.py.

Referenced by _collect(), _online_update(), _print_status(), _run_consensus_and_self_cal(), _save_all(), and _tls_bayesian_fit_all().

◆ target_points

calibration_orchestrator.CalibrationOrchestrator.target_points = int(orch_cfg.get("target_points", 15))

Definition at line 426 of file calibration_orchestrator.py.

◆ target_r2

calibration_orchestrator.CalibrationOrchestrator.target_r2 = float(orch_cfg.get("target_r_squared", 0.99))

Definition at line 428 of file calibration_orchestrator.py.


The documentation for this class was generated from the following file: