Skip to content

feat: subtract sample fluorescence on absolute 1-D SAXS profiles - #4

Merged
D-sudoasd merged 2 commits into
mainfrom
feat/fluorescence-1d-subtraction
Aug 19, 2026
Merged

feat: subtract sample fluorescence on absolute 1-D SAXS profiles#4
D-sudoasd merged 2 commits into
mainfrom
feat/fluorescence-1d-subtraction

Conversation

@D-sudoasd

Copy link
Copy Markdown
Owner

Problem

Metal SAXS at energies above absorption edges carries sample-generated X-ray fluorescence. Empty-cell/NIST-blank and BioSAXS buffer subtraction do not remove it. Users needed an opt-in, fail-closed 1-D correction that records provenance.

Cause

The package had no fluorescence ledger token or kernel. Detector-space blank math is the wrong place for an isotropic 1-D additive term.

Fix

  • New kernel subtract_fluorescence on absolute cm^-1 data: I_corr = I_abs - beta F(q)
  • Methods: constant, high_q_mean, high_q_median, measured_profile
  • Ledger token fluorescence; unknown u(F0)/u(beta) stay NaN; negatives are reported, not clipped
  • CLI saxsabs subtract-fluorescence
  • Workbench Tab 3 after optional buffer; Tab 2 1-D I(q) (not I-chi)
  • Optional BL19B2 integrate1d post-step
  • Default off; NIST 2-D blank formula unchanged; paper.md unchanged
  • Sequential buffer then fluorescence keeps buffer statistical extras and NaNs unknown combined terms

Verification

  • pytest tests/test_fluorescence_subtraction.py tests/test_intensity_state.py tests/test_cli.py tests/test_buffer_subtraction.py tests/test_workbench_scientific.py tests/test_bl19b2_integrate1d.py tests/test_detector_reduction.py -q: 238 passed
  • Full pytest -q: 785 passed
  • ruff check src tests: clean
  • Real CLI (this repo src on PYTHONPATH): two identical subtract-fluorescence --method constant --f0 2.0 runs with JSON method/f0/points

@D-sudoasd
D-sudoasd merged commit fa1c86c into main Aug 19, 2026
13 checks passed
@D-sudoasd
D-sudoasd deleted the feat/fluorescence-1d-subtraction branch August 19, 2026 10:54
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