Skip to content

Quality control#

For day-to-day instrument checks, define a QC configuration once, then measure against the current spectrum whenever you like and track the trend.

qc.create_configuration(
    "daily_snr",
    reference_sample="sucrose",
    metrics=[
        {"type": "snr", "name": "SNR", "lower_limit": 50},
        {"type": "linewidth_hz", "name": "Linewidth", "upper_limit": 2.0, "peak_index": 0},
    ],
)

result = qc.measure("daily_snr")
print("PASS" if result["overall_pass"] else "FAIL")

stats = qc.get_statistics("daily_snr", "SNR", days=30)
print(f"SNR mean {stats['mean']:.1f}, pass rate {stats['pass_rate'] * 100:.0f}%")

qc.measure records the result and returns a per-metric breakdown; over time, qc.get_trend and qc.generate_chart turn that history into control charts you can embed in reports.