Skip to content

Add joint spectrum fitting for Gaussian, Lorentzian and Voigt peaks - #18

Open
david-hoffman wants to merge 23 commits into
codex-mainfrom
codex/spectrum-fitting
Open

david-hoffman wants to merge 23 commits into
codex-mainfrom
codex/spectrum-fitting

Conversation

@david-hoffman

@david-hoffman david-hoffman commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Adds spectrum_fit to fit positive Gaussian, Lorentzian or Voigt peaks jointly. It accepts a 1D spectrum, optional x coordinates, and either automatic peak detection, center guesses or full parameter guesses. Background is selectable: none, constant or linear. Amplitude means peak height. Returned parameters and covariance use the caller’s physical units. Existing public fitting interfaces are preserved.

The default optimizer is Levenberg–Marquardt. Internal coordinate scaling and positivity transforms keep amplitudes and widths positive while centers move freely. A documented callable protocol supports custom optimizers. The simulated voltage spectra, fits, residuals and underlying numerical data are saved in docs/examples/spectrum-fitting. Multi-peak examples add six Gaussian peaks with automatic detection, seven Lorentzian peaks from center guesses, and eight Voigt peaks from full guesses. Each shows the total fit, true/fitted components, and residuals with varied heights/widths, overlapping peaks and a sloping background.

CI repair: the documentation run failed before Linux worker 0 ran tests because collection used Python 3.10.21 while that worker and aggregation used 3.10.22. Independent artifact comparison found the interpreter patch was the sole portable identity difference. The workflow now shares exact platform pins across all three stages: Linux 3.10.22; macOS ARM64/Windows 3.10.11. Manifest/receipt checks, action hashes, matrix, dependencies, tests and coverage gates remain intact. A fresh infrastructure review found no material issues.

Validation for CI repair candidate 99ae885806e17181631b914ce58e83fbffc373d9:

  • Exact-candidate canonical full verification passed: python tools/verification.py full, with MPLBACKEND=Agg, the retained clean environment and its private MPLCONFIGDIR/PIP_CACHE_DIR. CPython 3.12.14, macOS 27 ARM64; all 24 steps passed in 1,836.13 seconds. 2,128 tests passed, 186 warnings; zero failures, errors or skips. Coverage: 3,339/3,339 statements and 858/858 branches, globally and individually across all 20 owned Python runtime files, with no exclusions or partial branches. Shell-hook statement/branch measurement is unsupported by coverage.py. Retained receipt: reports/verification/full-fi8zudm2/checks.json; SHA-256 e50a81e51dc00a0778bc39da7f9fdc97423d6e16d32b8b7a2daca6fc6723a600. All recorded input hashes match the unchanged, clean candidate.
  • Both earlier incomplete repair attempts remain retained and counted: the first stopped after local disk exhaustion; the second was paused for the owner's requested disk cleanup. Neither supplies passing evidence.
  • Independent reviewed test checkpoint: 297 spectrum cases across the approved 33 scenarios.
  • Independent numerical candidate review: D3 accepted parent 576602a6497ce1b893c2adce61c8a0a56136a592 under R4; 33 fresh representative physical-fit probes and independent full-covariance checks passed. All product and tests remain byte-identical. This repair changes only the workflow pins and associated task/lesson records. The prior fresh documentation review checked the published figures, tables, archived data, units, hashes and links without remaining findings.
  • Existing sharded-verification regression tests: 87 passed. Normal commit hook passed.
  • Hosted Linux/macOS/Windows CI for this exact repair candidate passed in run 37509134883, attempt 1. All 13 jobs succeeded, including both test shards and coverage aggregation on each platform, and the final required gate. GitHub run and PR metadata independently confirm candidate 99ae885806e17181631b914ce58e83fbffc373d9. The unchanged local checkout and current remote base a835a490373835fa01e4460ce2159365150d1946 were checked again after completion. Retained platform receipts confirm 2,128 passing tests per platform and 3,339/3,339 statements plus 858/858 branches covered globally and per file across all 20 owned Python runtime files, with no missing or excluded lines/branches. Collection, both shards and aggregation agree on Python 3.10.22 for Linux and 3.10.11 for macOS/Windows.

Fits use unweighted least squares. Covariance is a local approximation; the documented scope is physically plausible, resolved spectra. Numerical failure checks do not claim accurate parameter recovery across the entire floating-point range.

Delivery evidence and accounting

Approved R4 contract; 33 scenarios, 297 accepted spectrum cases. A/B launches: 18/14. The final correction window accepted round 3/3; prior rounds remain counted. Initial C plus three authorized repairs completed; repair allowance 3/3 spent. D3 independently accepted numerical parent 576602a6497ce1b893c2adce61c8a0a56136a592. The subsequent docs-only update adds one fresh visual/documentation review and a design helper; it opens no new numerical review window or product repair. The CI repair adds independent diagnostic and infrastructure reviews plus storage/evidence helpers; it is classified as environment/tooling and consumes no scientific C repair or A/B window. Current parent/helper metering remains unavailable. Total completed formal CLI roles: 39.

Measured completed-role usage: 50,825,949 input tokens, including 47,700,736 cached; 765,941 output tokens, including 290,725 reasoning. Cached/reasoning figures are subsets. Parent/helper usage and exact dollar billing are unavailable. No fixed execution cap or spending reset.

Reviewed tests SHA-256: 22083617a37363f398116749087c4b0a8f080cc3cb27e4ebcaaeb0093342bf35.
Public test-report SHA-256: b376f8eb13184564ec3836af0c818b65c011b3f5bf385a9f587cfa41f4d8e5ea.
D3 acceptance-report SHA-256: 0843ed6185e1ff0939c462ca651b5cd5788c4ef995e1490972e83de79d559a5d.
Current CI repair candidate tree: a23e219a39d84874a22c672f01808b2821a3f749.

Repair candidate CI checked merge 56d1ba1d29d58dc95650cf9aca24bd922b72e79c, with exact base a835a490373835fa01e4460ce2159365150d1946 and candidate 99ae885806e17181631b914ce58e83fbffc373d9 as parents. Its tree equals the verified candidate tree above. All 12 original artifact ZIPs are retained, with original ZIP/member hashes and sealed collection/shard/aggregate reports independently checked. The final evidence-validation report SHA-256 is 844fe909266149013c82217324ce655e310ae3115e0b4dad2bf5cec632ea0b68. Raw coverage remains inside those original compressed ZIPs to avoid duplicating hundreds of megabytes of generated files.

Prior candidate CI checked merge 404fbac041338702cb42ffd16b3fe204802172e1, whose parents are base a835a490373835fa01e4460ce2159365150d1946 and candidate 576602a6497ce1b893c2adce61c8a0a56136a592. Its complete 271-entry tree equals the prior verified runtime candidate tree b564758175bce129d0c2d364618297ffa4d2b0a9. The 98 Windows input-byte differences were individually proved to be LF-to-CRLF checkout conversions of those exact approved Git blobs; actual platform hashes and unchanged within-platform identity checks were retained.

Prior candidate retained CI proof SHA-256: 7a1d34af18fe41d1c49bf23bd2ba75a428f02bef6e97b6afe912cdade4523178.

Documentation review SHA-256: fbdb441ac0b4ea99a16a0e1ef8ba6cfba20706c4f545685b4ff03c6b9e0243cf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant