Skip to content

Commit

Permalink
Fixed compare_model method
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Sep 20, 2024
1 parent 2b288f4 commit 2a5d046
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 10 additions & 7 deletions sedkit/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,17 +856,20 @@ def compare_model(self, modelgrid, fit_to='spec', rebin=True, **kwargs):

if spec is not None:

if rebin and fit_to == 'spec':
model = model.resamp(spec.spectrum[0])
# If you want to resample, you need to trim here
# if rebin and fit_to == 'spec':
# model = model.resamp(spec.spectrum[0])
#
# # Fit the model to the SED
# gstat, yn, xn = list(spec.fit(model, wave_units='AA'))
# wave = model.wave * xn
# flux = model.flux * yn

# Fit the model to the SED
gstat, yn, xn = list(spec.fit(model, wave_units='AA'))
wave = model.wave * xn
flux = model.flux * yn
normed = model.norm_to_spec(spec)

# Plot the SED with the model on top
fig = self.plot(output=True)
fig.line(wave, flux)
fig.line(normed.wave, normed.flux, color='red')

show(fig)

Expand Down
2 changes: 2 additions & 0 deletions sedkit/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,9 @@ def resamp(self, wave=None, resolution=None, name=None):
wave = wave.value

# Bin the spectrum
print(wave, self.wave)
binned = u.spectres(wave, self.wave, self.flux, self.unc)
print(binned[0])

# Update the spectrum
spectrum = [i * Q for i, Q in zip(binned, self.units)]
Expand Down
2 changes: 1 addition & 1 deletion sedkit/tests/test_sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_compare_model(self):
"""Test for the compare_model method"""
v = sed.VegaSED()
bt = mg.BTSettl()
v.compare_model(bt, teff=3000)
v.compare_model(bt, teff=10000)

def test_plot(self):
"""Test plotting method"""
Expand Down

0 comments on commit 2a5d046

Please sign in to comment.