Skip to content

Rework series, Tier B-05, integrate spectral bins as an opt-in while keeping upstream version as default - #37

Open
Yashvi-Sharma wants to merge 3 commits into
mainfrom
rework/tb-05-integrate-spectral-bins
Open

Yashvi-Sharma wants to merge 3 commits into
mainfrom
rework/tb-05-integrate-spectral-bins

Conversation

@Yashvi-Sharma

Copy link
Copy Markdown
Collaborator

No description provided.

Yashvi-Sharma and others added 3 commits November 9, 2026 16:03
The fork replaced upstream's point sampling of spectra with bin integration,
and deleted the upstream code paths rather than branching around them. That
cannot go upstream as-is: it moves the flux of every existing instrument.

!SIM.spectral.integrate_spectral_bins restores the upstream behaviour by
default and selects the fork's behaviour when set. One flag covers the whole
set, because the parts are not independently selectable:

- prepare_source resampling vs cube rebinning: resampling first and then
  integrating destroys narrow lines and is worse than either alone.
- edge-plane f0/f1 scaling vs rebinning: pre-scaling makes a partial-bin
  count, which rebinning then integrates again over the plane's own width.
- cube_waveset padding vs extract_from padding: a padded grid over an
  unpadded extraction leaves a zero cliff at both band edges.

Gating the single spectral_padding assignment in observe() reduces five other
sites to upstream by construction, since the padding stays 0 um.

The off path returns upstream's literal np.arange grid including its
off-by-one truncation. The two forms are not interchangeable: they differ by
4e-16 um over 1.9-2.1 at 0.01 and 2.2e-12 um over 0.3-2.5 at 1e-5, and the
truncation drops a whole bin, so a test asserts exact equality.

Left unconditional, since they are correct on both paths: the .copy() that
stops extraction mutating the caller's cube, abs(wdel) in the mask, float64
for cube data, and the CDELT3/CRVAL3 header written by _make_cubefields.

Deletes test_reuses_cached_spectrum_waveset, which referenced a module
attribute removed when the waveset cache was dropped, and so errored rather
than failed. The cache is deliberately gone: a SourceSpectrum can re-sample
itself in place through z, which another test asserts.

Note the two test_basic_instrument flux regressions are unaffected by this
flag; they come from the unflagged spatial projection rework, which is a
separate piece of work.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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