Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
leliel12 committed Jul 23, 2021
2 parents eb0aa3d + a5127f0 commit dd2c186
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
11 changes: 7 additions & 4 deletions nirdust/bbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class NirdustResults:
fitted_blackbody = attr.ib()
dust = attr.ib(repr=False)

def nplot(self, ax=None, data_color="firebrick", model_color="navy"):
def plot(self, ax=None, data_color="firebrick", model_color="navy"):
"""Build a plot of the fitted spectrum and the fitted model.
Parameters
Expand Down Expand Up @@ -253,13 +253,16 @@ def nplot(self, ax=None, data_color="firebrick", model_color="navy"):
self.dust.spectral_axis,
self.dust.flux,
color=data_color,
label="continuum",
label="Dust emission",
)
ax.plot(
self.dust.spectral_axis, bb_fit, color=model_color, label="model"
self.dust.spectral_axis,
bb_fit,
color=model_color,
label="Black body",
)
ax.set_xlabel("Angstrom [A]")
ax.set_ylabel("Normalized Energy [arbitrary units]")
ax.set_ylabel("Intensity [arbitrary units]")
ax.legend()

return ax
Expand Down
20 changes: 10 additions & 10 deletions tests/test_bbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def test_NirdustResults_flux_axis(NGC4945_continuum):


@check_figures_equal()
def test_nplot(fig_test, fig_ref, NGC4945_continuum):
def test_plot_results(fig_test, fig_ref, NGC4945_continuum):

spectrum = NGC4945_continuum.cut_edges(19500, 22900).normalize()

Expand All @@ -320,19 +320,19 @@ def test_nplot(fig_test, fig_ref, NGC4945_continuum):
)

ax_test = fig_test.subplots()
fit_results.nplot(ax=ax_test)
fit_results.plot(ax=ax_test)

ax_ref = fig_ref.subplots()

ax_ref.plot(sp_axis, flux, color="firebrick", label="continuum")
ax_ref.plot(sp_axis, instanstella, color="navy", label="model")
ax_ref.plot(sp_axis, flux, color="firebrick", label="Dust emission")
ax_ref.plot(sp_axis, instanstella, color="navy", label="Black body")
ax_ref.set_xlabel("Angstrom [A]")
ax_ref.set_ylabel("Normalized Energy [arbitrary units]")
ax_ref.set_ylabel("Intensity [arbitrary units]")
ax_ref.legend()


@check_figures_equal()
def test_nplot_default_axis(fig_test, fig_ref, NGC4945_continuum):
def test_plot_results_default_axis(fig_test, fig_ref, NGC4945_continuum):
spectrum = NGC4945_continuum.cut_edges(19500, 22900).normalize()

sp_axis = spectrum.spectral_axis
Expand All @@ -347,12 +347,12 @@ def test_nplot_default_axis(fig_test, fig_ref, NGC4945_continuum):

ax_test = fig_test.subplots()
with patch("matplotlib.pyplot.gca", return_value=ax_test):
fit_results.nplot()
fit_results.plot()

ax_ref = fig_ref.subplots()

ax_ref.plot(sp_axis, flux, color="firebrick", label="continuum")
ax_ref.plot(sp_axis, instanstella, color="navy", label="model")
ax_ref.plot(sp_axis, flux, color="firebrick", label="Dust emission")
ax_ref.plot(sp_axis, instanstella, color="navy", label="Black body")
ax_ref.set_xlabel("Angstrom [A]")
ax_ref.set_ylabel("Normalized Energy [arbitrary units]")
ax_ref.set_ylabel("Intensity [arbitrary units]")
ax_ref.legend()

0 comments on commit dd2c186

Please sign in to comment.