Skip to content

v0.22.2 - Input Validation for Threshold Fitting (2026-06-18)

What Changed?

This release adds input validation to fit_thresholds.py to catch bad measurement data before it causes a crash in plot_thresholds.py. When a threshold scan is performed outside the detector's response region, the fitting now fails with a clear warning instead of silently producing corrupt output.


What's New

Main Feature: Early Validation in fit_channel_data()

What it does: Detects two categories of bad fit data before calling scipy.curve_fit:

  1. Flat data: all threshold counts are identical (scan range too low)
  2. Non-finite parameters: fitted mu or sigma is inf or nan
  3. Non-positive sigma: sigma <= 0 (physically meaningless fit)

When any of these conditions is detected, the affected channel is skipped with a yellow warning message. Other channels continue to be processed normally.

How to use it: No change required. Run fit_thresholds.py as before. If a channel has bad data, you will now see:

Warning: Channel 1: all counts are identical (3). Threshold scan range may be too low. Skipping channel 1.

Installation

Quick Start

# Get the release
git checkout v0.22.2

# Setup
task env:setup

# Run CLI
uv run kazunoko --help

What's Different from the Last Version?

✅ Added

  • fit_thresholds.py: validation that raises ValueError when all counts are identical before calling curve_fit
  • fit_thresholds.py: validation that raises ValueError when fitted mu or sigma is non-finite (inf/nan)
  • fit_thresholds.py: validation that raises ValueError when fitted sigma is non-positive
  • fit_thresholds.py: warning when covariance matrix contains non-finite values

🐛 Fixed

  • plot_thresholds.py no longer crashes with RendererAgg incompatible constructor arguments when thresholds_fitted.json contains Infinity in curve_y

Is It Safe to Upgrade?

Backward Compatible: Yes

  • Users with valid measurement data will see no change in behavior
  • Users with flat or out-of-range data will now get actionable warnings instead of a downstream crash

Tests Passed

  • ✅ Builds without errors
  • ✅ Valid data: fitting proceeds normally for all channels
  • ✅ Flat data (all counts identical): channel skipped with warning
  • ✅ Non-finite parameters after fit: channel skipped with warning

Release Details

  • Date: 2026-06-18
  • Version: v0.22.2
  • Files Changed: 4
  • Commits: 765110a (bump), fix(examples) commits

Next Steps

  • Consider adding a warning when the scan range covers fewer than N data points for reliable fitting