Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move plotting helper functions from SpectrumFitResult to SpectrumDatasetOnOff #2121

Merged
merged 5 commits into from Apr 18, 2019

Conversation

@adonath
Copy link
Member

@adonath adonath commented Apr 17, 2019

This PR moves the plotting functionality of the SpectrumFitResult over to the SpectrumDatasetOnOff and adapts the spectrum_analysis.ipynb notebook accordingly.

@adonath adonath self-assigned this Apr 17, 2019
@adonath adonath added this to To do in gammapy.makers via automation Apr 17, 2019
@adonath adonath added this to the 0.12 milestone Apr 17, 2019
Copy link
Contributor

@registerrier registerrier left a comment

Thanks @adonath . Looks good.

def plot_counts(self, ax):
"""Plot predicted and detected counts."""
self.npred().plot(ax=ax, label="mu_src")
self.excess().plot(ax=ax, label="Excess", fmt=".", energy_unit="TeV")
Copy link
Contributor

@registerrier registerrier Apr 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why forcing the units to be TeV? That might be optional? Or simply use the units of the counts?

Copy link
Member Author

@adonath adonath Apr 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -282,3 +280,63 @@ def energy_range(self):
e_lo = self.counts_on.energy.lo[self.mask]
e_hi = self.counts_on.energy.hi[self.mask]
return u.Quantity([e_lo.min(), e_hi.max()])

def _as_counts_spectrum(self, data):
Copy link
Contributor

@registerrier registerrier Apr 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also be a .copy() method on CountsSpectrum, no?

@adonath adonath merged commit a8d4881 into gammapy:master Apr 18, 2019
8 of 9 checks passed
gammapy.makers automation moved this from To do to Done Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants