Repository navigation
#1365 Fix an error in SED * Bandpass when not using nm for the wavelengths - #1367
Conversation
jmeyers314
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| # 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) |
There was a problem hiding this comment.
That seems reasonable to me.
|
Thanks Josh. I'm happy with those additions. Thanks for finding those additional bugs. :) |
@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.