Skip to content

plot_thresholds.py

Purpose: Visualize threshold fitting results as plots

Use case: Inspecting detector response curves, generating figures for reports

Features:

  • Reads fitted threshold data from thresholds_fitted.json (produced by fit_thresholds.py)
  • Plots the detector response curve and measured data points for each channel
  • Displays sigma level markers (0σ, 1σ, 3σ, 5σ)
  • Supports PNG, PDF, and SVG output formats

Required input: thresholds_fitted.json produced by fit_thresholds.py

Usage:

# Display plots without saving
uv run examples/plot_thresholds.py ./2026-03-20/

# Save as PNG (150 dpi)
uv run examples/plot_thresholds.py ./2026-03-20/ --save

# Save as high-resolution PNG (300 dpi)
uv run examples/plot_thresholds.py ./2026-03-20/ --dpi 300 --save

# Save as PDF
uv run examples/plot_thresholds.py ./2026-03-20/ --format pdf --save

# Use a custom fitted results file
uv run examples/plot_thresholds.py ./2026-03-20/ --pattern "threshold_*.json" --save

CLI Options:

Option Default Description
READ_FROM (required) Directory containing thresholds_fitted.json
--pattern thresholds_fitted.json Glob pattern to filter input files
--format / -f png Output format: png, pdf, or svg
--dpi / -d 150 Resolution for PNG output (50–600)
--save / -s off Save plots to directory
--verbose / --quiet --quiet Show or suppress status messages
--log-level error Log level (debug/info/error)