diff --git a/sedkit/sed.py b/sedkit/sed.py index 40bae51..ca65bcf 100644 --- a/sedkit/sed.py +++ b/sedkit/sed.py @@ -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) diff --git a/sedkit/spectrum.py b/sedkit/spectrum.py index 874e933..4bbc4ca 100644 --- a/sedkit/spectrum.py +++ b/sedkit/spectrum.py @@ -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)] diff --git a/sedkit/tests/test_sed.py b/sedkit/tests/test_sed.py index e30b36a..de51af4 100644 --- a/sedkit/tests/test_sed.py +++ b/sedkit/tests/test_sed.py @@ -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"""