Commit Graph
136 Commits
Author SHA1 Message Date
unzhakov 18a46ad02f feat(cli): propagate export options through JSON/paceENSDF flows
- main(argv) signature enables in-process CLI invocation and testing
- parser defaults for --e-step/--neutrino-mass/--intensity-cutoff/
  --csv-separator/--normalize-to-one now None = 'not provided'
- JSON flow applies file values by default and CLI flags as overrides
  (previously these five options were silently discarded)
- paceENSDF flow resolves None flags to literal defaults
- new tests/integration/test_cli_flows.py: JSON propagation,
  degenerate-mode non-zero exit with no file (JSON + paceENSDF)
- adapted two neutrino-mass default tests to None-parsing semantics
2026-10-02 05:46:08 +03:00
unzhakov 62bf7fdac2 fix(output): apply positive-integral export guard to to_one mode
CSVEmitter.export_to_csv raised ValueError only in intensity mode;
degenerate exports with --normalize-to-one silently wrote all-zero
CSV files. The guard now runs before the mode split and no file is
written in either mode.
2026-10-01 23:02:33 +03:00
unzhakov ee7aedc80a fix(spectrum): lone branch defines endpoint in single-branch mode
When config.branches carries exactly one branch (e.g. after
--intensity-cutoff filtering), the branch endpoint/transition define
the spectrum, energy grid, analyzer unified branch view and CSV
header. The stale top-level endpoint inherited from the parent decay
no longer leaks into physics (proven wrong on Cs137: spectrum
extended to 1176 keV while the lone survivor ends at 514 keV).
2026-10-01 22:04:17 +03:00
unzhakov 6bb7b950c7 style: apply black formatting to pending files 2026-09-30 10:41:28 +03:00
unzhakov ea4b652ccb chore: ignore ROOT data files produced by notebooks 2026-09-30 03:16:45 +03:00
unzhakov 40d0836056 docs: document core spectrum, physical branch columns, CSV-driven plots 2026-09-30 03:11:05 +03:00
unzhakov f5b79000a4 fix(scripts): list min/max calls, typed mains, drop unused header reads 2026-09-30 03:11:05 +03:00
unzhakov dc350aacfc fix(fitter): stop referencing removed detector_response module 2026-09-30 03:08:13 +03:00
unzhakov 8172ba2541 test: adapt existing suites to unconditional core, drop dead detector tests 2026-09-30 03:08:13 +03:00
unzhakov 7dc2ec79d1 feat(cli): report core in dry-run, build plots from exported CSV 2026-09-30 03:04:18 +03:00
unzhakov afb7afc5b7 feat(output): physical branch spectra, universal factor, CSV-driven plotting 2026-09-30 03:04:18 +03:00
unzhakov bab19de458 feat: make phase space and Fermi function unconditional core components 2026-09-30 03:04:18 +03:00
unzhakov 8bc9b0fd87 test: pin core-spectrum invariant (phase_space x fermi always included) 2026-09-30 03:04:18 +03:00
unzhakov 687e05cbe2 style: reformat assertion blocks in test files 2026-09-29 13:06:22 +03:00
unzhakov be3e288e0d docs: update documentation files and fix linting issues 2026-07-07 13:32:48 +03:00
unzhakov 9bf1e1333e refactor: rename visualize module to output module and separate concerns into core, csv_export, and visualization modules 2026-07-07 12:59:11 +03:00
unzhakov 6dc1e3924d feat: add CLI options for custom CSV separator and normalize-to-one branch normalization 2026-07-06 17:32:56 +03:00
unzhakov 1b4d418b5f feat: change CSV output format to use tab delimiters instead of comma delimiters 2026-07-03 18:01:39 +03:00
unzhakov 643e035c54 feat: update CSV headers and plot titles to show active/excluded branches and intensity cutoff exclusions 2026-07-03 17:45:35 +03:00
unzhakov c6aaf3b76a fix: use underscores in branch names for CSV headers in concise mode 2026-07-03 15:21:44 +03:00
unzhakov c2795bf86e fix: use underscores in branch names for CSV headers 2026-07-03 15:10:10 +03:00
unzhakov a7eef7bc20 feat: polish CSV header format with improved metadata and column naming 2026-07-03 14:58:19 +03:00
unzhakov 876e1e3ab8 Add massive neutrino support and improve CSV/CLI output
- Add neutrino mass parameter to SpectrumConfig and CLI interface
- Update PhaseSpace component to handle neutrino mass effects properly
- Update CSV headers to show basic endpoint and all transition types
- Add --csv-verbosity option to CLI with 'full' and 'concise' options
- Fix comparison plots to properly show linear scale variations
- Add comprehensive tests for neutrino mass functionality
2026-07-02 10:33:28 +03:00
unzhakov 406fd57bcd chore: add .pi-lens/ to .gitignore 2026-05-26 15:01:17 +03:00
unzhakov 8b0ced4b65 fix: resolve 4 fatal bugs — json_to_config, create_config_from_source, Am-241 constant, CLI positional args 2026-05-26 14:57:35 +03:00
unzhakov 38e97213c5 Remove root output 2026-05-22 18:25:57 +03:00
unzhakov 8599574723 docs: fix stale file references in TODO.md structure and completions 2026-05-22 15:18:17 +03:00
unzhakov 2fedd03d92 fix: bump __version__ to 0.4.0 to match pyproject.toml 2026-05-22 15:18:09 +03:00
unzhakov fd76eff109 docs: add docs_check.py to quality gates, add bs_exp CLI, document pytest markers 2026-05-22 15:18:00 +03:00
unzhakov 5dd9c7977a feat: add docs_check.py for automated documentation consistency checks 2026-05-22 15:17:52 +03:00
unzhakov d8838d19f4 chore: remove obsolete notebooks and add uv.lock 2026-05-22 12:20:36 +03:00
unzhakov ab164fbf98 fix: robust Am-241 calibration with width-constrained peak detection
- Use find_peaks width=(5,50) to reject noise bumps
- Simplify peak matching: find two strongest peaks with largest
  channel separation, assign min/max known energies
- Require absolute threshold of 400 counts to avoid noise peaks
- Calibration now correctly maps: ch 97→13.0 keV, ch 537→59.54 keV
- Tc-99 endpoint at ch 2750 → 293.6 keV (expected ~294)
- Add .rpiv/ to .gitignore
2026-05-21 18:21:51 +03:00
unzhakov 8952d0f789 fix: robust Am-241 peak detection for energy calibration
- Search full spectrum (exclude pulser region) instead of just low-energy
- Include 59.54 keV line in known Am-241 energies
- Brute-force peak-to-energy matching with physical gain constraint
  (3-40 ch/keV) to reject spurious fits
- Fixed find_peaks parameters: height=100, distance=5 for accurate
  peak detection
- Calibration now correctly maps: ch 97→13 keV, ch 134→17.4 keV,
  ch 537→59.6 keV, giving Tc-99 endpoint at ch 2750→291.6 keV
- Add .rpiv/ to .gitignore
2026-05-21 16:43:10 +03:00
unzhakov 5ec6305e09 fix: conditional matplotlib backend for interactive + headless use 2026-05-21 16:05:58 +03:00
unzhakov fa4e61a9f6 chore: add .rpiv/ to .gitignore 2026-05-21 16:03:20 +03:00
unzhakov 5c2b12c0e6 feat: experimental data calibration pipeline with ROOT I/O
- Fix chi2 calculation bug in calibration.py (remove incorrect
  coeffs[::-1] reversal in np.polyval)
- Fix broken beta_spectrum/cli.py (remove orphaned detector response
  add_argument calls and unused imports)
- Add ExpSpectrum.apply_calibration() and EnergyCalibrator.from_am241_spectrum()
- Add LivetimeDetermination class for pulser-based livetime
- Add SpectrumPipeline orchestration (read→subtract→calibrate→livetime→validate)
- Add ROOT I/O with PyROOT primary + uproot fallback
- Add bs_exp CLI with process, livetime, export subcommands
- Add exp_calibration notebook with pre-calibration visualization
- Add comprehensive tests (73 passing)
- Add bs_exp console script and [root] extra to pyproject.toml
- Remove obsolete detector_response module and unused notebooks
2026-05-21 16:01:25 +03:00
unzhakov caa4a77ebd fix: correct energy calibration from Am-241 peaks
- Am-241 peaks at ch 134=13.8, ch 163=17.8, ch 218=26.3 keV
- Calibration: E = 0.397 + 0.0995 × ch (previously wrong)
- Kurie fit endpoint 425 keV vs Q=297.5 keV — spectrum extends
  beyond MCA range (407 keV), simple extrapolation unreliable
- Proper endpoint extraction requires theory model + detector
  convolution (fitter module), not simple Kurie plot
2026-05-18 00:01:28 +03:00
unzhakov 42dcad56a2 fix: add data/raw/ to .gitignore 2026-05-17 22:57:19 +03:00
unzhakov 5f70e3a15a feat: add raw binary spectrum reader and data quality analysis
- exp_data/raw_reader.py: read binary MCA spectra (128-byte header,
  int32 counts), subtract cumulative spectra, Am-241 calibration
- exp_data/spectrum.py: allow negative counts for difference spectra
- scripts/analyze_raw.py: analyze 236 individual runs from cumulative
  data, compute rates and endpoint drift
- Am-241 calibration: E = -0.96 + 0.451 * ch (CAM1),
  E = 0.75 + 0.442 * ch (CAM2)
- Results: stable rate ~2M counts/run, stable endpoint ~374 keV
  (smeared Q-value), spike at runs 214-219 (acquisition glitch)
2026-05-17 22:55:52 +03:00
unzhakov 3c0a43ad4d docs: update TODO and AGENTS for v0.4.0 completion
- Mark v0.4.0 as complete in TODO.md with all phases checked
- Update Phase 4 items with actual outcomes
- Next step: Track A 99Tc spectrum-shape analysis
- Add AGENTS instruction to update project metadata on significant
  structural changes (package additions, version bumps, etc.)
2026-05-17 19:31:39 +03:00
Evgeniy Unzhakov 27a6993419 Merge pull request #3 from unzhakov/dev/phase2-fitter
AreDev/phase2 fitter
2026-05-17 19:21:14 +03:00
unzhakov 38b44b56e6 feat: v0.4.0 package restructuring — split into 4 modules
Separate monolithic beta_spectrum package into:
  beta_spectrum   — pure theory (components, spectrum, CLI, visualize)
  exp_data        — experimental data handling (spectrum, calibration,
                    fitters, corrections)
  fitter          — analysis framework (model, fit_engine, extractor,
                    result)
  beta_spectrum.visualize — plotting (BetaSpectrumAnalyzer)

Phase 1 — exp_data module:
  ExpSpectrum dataclass with metadata, normalization, serialization
  EnergyCalibrator (linear/quadratic calibration)
  GaussianFitter + PeakFitter for calibration sources
  DeadTimeCorrection, PileUpCorrection, BackgroundSubtractor
  43 new tests, ruff + mypy clean

Phase 2 — fitter module:
  SpectrumModel wraps BetaSpectrum + DetectorResponse with convolution
  SpectrumFitter with χ² minimization, covariance, profile likelihood,
  confidence intervals, robust loss functions
  CWExtractor + GVAExtractor for C(W) and g_V/g_A extraction
  AnalysisResult + FitSummary for physics-specific results
  CurveFitter general-purpose callable model fitter
  34 new tests, ruff + mypy clean

Phase 3 — clean up beta_spectrum:
  Remove cw_extractor.py and fitter.py (moved to fitter/)
  Clean __init__.py to export only theory classes
  Add backward-compat methods to CWExtractor
  Fix BetaSpectrumAnalyzer._get_branch_spectrum returning BetaSpectrum
  objects instead of numpy arrays (plot fix)

Phase 4 — package structure:
  Auto-discovered by setuptools (4 packages)
  All imports updated across 26 source files
  Black formatting applied
  322 tests pass (262 original + 60 new)
  ruff + mypy clean on all source files

Bug fixes:
  - Fix multi-branch spectrum plotting: universal component keys
    (Fermi, Screening, etc.) don't have per-branch prefix; fixed
    fallback lookup.
  - Fix negative phase space beyond endpoint: BetaSpectrum returns
    negative values for W > W0; clamp branch spectra to zero.
2026-05-17 18:58:04 +03:00
unzhakov 745bbae4cd refactor: rename 'analyzer' to 'visualize' — analysis belongs to fitter module 2026-05-17 01:33:13 +03:00
unzhakov 10ad3a867b docs: restructure TODO.md with v0.4.0 package architecture plan 2026-05-17 00:34:16 +03:00
Evgeniy Unzhakov 0d51c68bcb Merge pull request #2 from unzhakov/dev/move-analyzer-to-separate-file
Dev/move analyzer to separate file
2026-05-16 23:59:41 +03:00
unzhakov 64785f4aa9 style: remove transition type from plot header — shown in branch legends instead 2026-05-16 23:24:33 +03:00
unzhakov 55cfb30b2b refactor: unify plotting — single-branch treated as multi-branch with one branch; remove old single-branch methods 2026-05-16 22:59:48 +03:00
unzhakov b3d6abb4d5 polish: unify plot output — external headers, compact legends, consistent titles 2026-05-16 21:21:28 +03:00
unzhakov f05a2de1b8 refactor: move BetaSpectrumAnalyzer to separate analyzer module 2026-05-16 20:41:58 +03:00
unzhakov 8314cee29c refactor: restructure metadata files for context efficiency
- Shrink global AGENTS.md: 153 → 56 lines (−63%)
  Removed: git workflow, TDD, overthinking guards, code style, reasoning protocol
  Kept: personality, git basics, thinking levels, general principles, backend
- Create project AGENTS.md: 71 lines
  Added: stack/commands, GitHub Flow git workflow, Conventional Commits,
  TDD (Python-specific), quality gates, debug verification
- Trim CONVENTIONS.md: 161 → 68 lines (−58%)
  Removed: verbose examples, redundant unit convention section,
  lengthy SpectrumComponent code example
- Delete DEVELOPMENT.md: 238 lines → 0 (migrated to AGENTS.md)
  Setup/release checklist removed (not agent concerns)
  Git workflow, TDD, quality gates, notebook QC, debug verification
  all migrated to AGENTS.md
- Update README.md project structure
Total per-session metadata: 552 → 195 lines (−65%)
2026-05-16 19:51:37 +03:00