Skip to content

#1365 Fix an error in SED * Bandpass when not using nm for the wavelengths - #1367

Merged
rmjarvis merged 6 commits into
releases/2.8from
#1365
Nov 12, 2026
Merged

rmjarvis merged 6 commits into
releases/2.8from
#1365

Conversation

@rmjarvis

Copy link
Copy Markdown
Member

@vera-rubin reported a bug in the SED * Bandpass code that applies the unit conversion in the wrong direction when the bandpass has units other than nm.

This PR fixes this bug as well as two other similar bugs that Codex found when I asked it to look for other related cases. The test suite now has tests of all three of these with a variety of wave units to check that the code works consistently regardless of which units you use to define the Bandpass or SED.

@rmjarvis rmjarvis added this to the v2.8 milestone Oct 16, 2026
@rmjarvis rmjarvis added bug report Bug report chromatic Related to the Chromatic classes, SEDs, bandpasses, etc. labels Oct 16, 2026
@rmjarvis rmjarvis linked an issue Oct 16, 2026 that may be closed by this pull request
@rmjarvis
rmjarvis requested a review from jmeyers314 October 16, 2026 01:10

@jmeyers314 jmeyers314 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See specific comment above. I already committed the change, but we can always roll back if needed.

Also, Claude found a related bug where div and thin() would fail for particular combinations of wave_type and astropy unit flux_types. E.g., units.erg/(units.sunits.cm**2units.AA) with wave_type 'nm' resulted in flux_type='fphotons' with flux_factor=10, but the flux_factor bit was getting dropped by .thin() and div. So added tests for that too.

Comment thread galsim/sed.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, but this line (and comment) caught my eye. The comment makes it sound as if only one of [self.redshift, other.redshift] can be non-zero, but I don't think the code enforces that anywhere. There may even be legitimate use cases for having both be non-zero, .e.g, high redshift quasar obscured by lower redshift dust (LyA forest). Right now if you multiply quasar(z=4) * dust(z=3) * dust(z=2) * dust(z=1), you get a result with z=10.

I think the solution is to replace the line above with redshift = max(self.redshift, other.redshift) (and then reword the comment). The physics should all still be okay; it's just producing something with a particular redshift label, but that label is arbitrary as far as the physics is concerned.

Comment thread galsim/sed.py
# An absorbing screen is always at z <= the source redshift, so the larger redshift
# is the source's. (The label divides out of spec below, so this only affects what
# redshift the product reports, not the spectrum it evaluates.)
redshift = max(self.redshift, other.redshift)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable to me.

@rmjarvis

Copy link
Copy Markdown
Member Author

Thanks Josh. I'm happy with those additions. Thanks for finding those additional bugs. :)

@rmjarvis
rmjarvis merged commit abf0f03 into releases/2.8 Nov 12, 2026
9 checks passed
@rmjarvis
rmjarvis deleted the #1365 branch November 12, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug report Bug report chromatic Related to the Chromatic classes, SEDs, bandpasses, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SED filtering uses the wrong wavelength for Angstrom Bandpasses

2 participants