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
Add new flux point class #810
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Maybe let's continue with this now and re-discuss whether to introduce a separate class for int fluxes later?
How much extra work would it be to remove DifferentialFluxPoints
here?
I think we should do this ASAP, so that it's clear what code to work on and start adapting other scripts.
def test_plot(self, flux_points): | ||
import matplotlib.pyplot as plt | ||
ax = plt.gca() | ||
flux_points.plot(ax=ax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All plotting functions should do
if ax is None:
ax = plt.gca()
at the start, so no need to create an ax
and pass it from the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
def test_e_ref(self, flux_points): | ||
actual = flux_points.e_ref | ||
if flux_points.sed_type == 'dnde': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess all of these if / else aren't ideal.
Maybe at least two test classes to get rid of this would make sense?
(not sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I prefer to keep it because I don't want to duplicate the testing code.
info += "Flux points of type '{}'".format(self.sed_type) | ||
return info | ||
|
||
def info(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest to remove info
and just keep __str__
.
This is what we've done for most classes, at least for now.
Examples | ||
-------- | ||
|
||
>>> from gammapy.spectrum import FluxPoints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same example as in the class-level docstring.
Suggest to remove it here and keep it in the class-level docstring, like we have for most other classes.
Filename | ||
kwargs : dict | ||
Keyword arguments passed to `~astropy.table.Table.write`. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to also pass filename
through:
filename = make_path(filename)
It does e.g. os environ variable expansion, which is something I find convenient and use frequently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
try: | ||
return self.table['e_min'].quantity | ||
except KeyError: | ||
raise NotImplementedError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KeyError
is better than NotImplementedError
for something that isn't available.
Suggest to remove try-except here completely.
(and to not invent some e_min
based on other columns)
a89edb0
to
638c43a
Compare
🎉 |
This PR adds a prototype for the
FluxPoints
class, that implements the data specification defined byhttp://gamma-astro-data-formats.readthedocs.io/en/latest/results/flux_points/index.html#flux-points
So far it mainly handles validation of the input tables and plotting of flux points with errors and upper limits. I'll make a second PR to adapt
gammapy.catalog
to use this class.@cdeil @joleroi @woodmd