Skip to content

Commit

Permalink
Replace more cases of "wav" by "lam", fix redshift bug in plot
Browse files Browse the repository at this point in the history
  • Loading branch information
drvdputt committed Jul 8, 2024
1 parent 5d22489 commit 922f272
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pahfit/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,12 @@ def tabulate(
wmin = min(r[0] for r in ranges)
wmax = max(r[1] for r in ranges)
wfwhm = instrument.fwhm(instrumentname, wmin, as_bounded=True)[0, 0]
wav = np.arange(wmin, wmax, wfwhm / 2) * u.micron
lam = np.arange(wmin, wmax, wfwhm / 2) * u.micron
elif isinstance(wavelengths, Spectrum1D):
wav = wavelengths.spectral_axis.to(u.micron)
lam = wavelengths.spectral_axis.to(u.micron) / (1 + z)
else:
# any other iterable will be accepted and converted to array
wav = np.asarray(wavelengths) * u.micron
lam = np.asarray(wavelengths) * u.micron

# apply feature mask, make sub model, and set up functional
if feature_mask is not None:
Expand All @@ -783,12 +783,10 @@ def tabulate(
fitter = alt_model.fitter
except PAHFITModelError:
return Spectrum1D(
spectral_axis=wav, flux=np.zeros(wav.shape) * u.dimensionless_unscaled
spectral_axis=lam, flux=np.zeros(lam.shape) * u.dimensionless_unscaled
)

# shift the "observed wavelength grid" to "physical wavelength grid
wav /= 1 + z
flux_values = fitter.evaluate(wav.value)
flux_values = fitter.evaluate(lam.value)

# apply unit stored in features table (comes from from last fit
# or from loading previous result from disk)
Expand All @@ -798,7 +796,7 @@ def tabulate(
user_unit = self.features.meta["user_unit"]["flux"]
flux_quantity = (flux_values * units.intensity).to(user_unit)

return Spectrum1D(spectral_axis=wav, flux=flux_quantity)
return Spectrum1D(spectral_axis=lam, flux=flux_quantity)

def _excluded_features(self, instrumentname, redshift, lam_obs=None):
"""Determine excluded features Based on instrument wavelength range.
Expand Down

0 comments on commit 922f272

Please sign in to comment.