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
Introduction of a new specialized class for lightcurves #5174
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: cgalelli <claudio.galelli@obspm.fr>
Signed-off-by: cgalelli <claudio.galelli@obspm.fr>
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.
Thank you @cgalelli ! I think this can go in and then we work on the improvements
I would add a customised .plot
) | ||
|
||
if format == "lightcurve": | ||
return LightCurve.from_maps( |
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.
Is this the responsibility of the parent class?
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.
The idea here was not only to give "responsability" to the parent, but to create a Lightcurve "by force" when using FluxPoints with a time axis (e.g. to keep compatibility with old code but still access the new functionalities and checks)
…plot function for lightcurve. Signed-off-by: cgalelli <claudio.galelli@obspm.fr>
Signed-off-by: cgalelli <claudio.galelli@obspm.fr>
|
||
return super().from_table(table, **kwargs) | ||
|
||
def to_stingray_lightcurve(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.
It seems you can create a stingray light curve with flux units https://docs.stingray.science/en/stable/notebooks/Lightcurve/Lightcurve%20tutorial.html#Error-Distributions-in-stingray.Lightcurve
maybe you can add a .from_stingray
as well, then stingray functionalities can be fully used by gammapy
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 can add a translator function on that direction as well. I would still be wary of actually using the stingray functions with flux (and they say so in the paragraph), but if they themselves show an example it means that it's not unheard of, just not exactly the standard approach. I can put a disclaimer in the docstring for both to and from-stingray
Signed-off-by: cgalelli <claudio.galelli@obspm.fr>
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.
Thanks @cgalelli ... I have put some comments in order to make a step forward
|
||
|
||
class LightCurve(FluxPoints): | ||
"""Specialized 'FluxPoints' heir class for lightcurves""" |
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.
To be developed: description, exemple, parameters and attributes, ....
|
||
@classmethod | ||
def read(cls, filename, **kwargs): | ||
kwargs.setdefault("format", "lightcurve") |
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.
One would need to add a metadata class, as for the flux class, or re-used this metadata class
kwargs.setdefault("axis_name", "time") | ||
return super().plot(**kwargs) | ||
|
||
def fvar(self, flux_quantity="flux"): |
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.
docstring to add
def fvar(self, flux_quantity="flux"): | ||
return compute_lightcurve_fvar(self, flux_quantity) | ||
|
||
def fpp(self, flux_quantity="flux"): |
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.
docstring to add
return compute_lightcurve_fpp(self, flux_quantity) | ||
|
||
def doubling_time(self, flux_quantity="flux"): | ||
return compute_lightcurve_doublingtime(self, flux_quantity) |
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.
docstring to add
def doubling_time(self, flux_quantity="flux"): | ||
return compute_lightcurve_doublingtime(self, flux_quantity) | ||
|
||
def structure_function(self, flux_quantity="flux", tdelta_precision=5): |
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.
docstring to add
@@ -849,3 +865,98 @@ def resample_axis(self, axis_new): | |||
fluxpoints.append(fp_new) | |||
|
|||
return self.__class__.from_stack(fluxpoints, axis=axis_new) | |||
|
|||
|
|||
class LightCurve(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.
Add all the test functions
In this draft PR I introduce the basic structure for a specialized
LightCurve
class which inherits fromFluxPoints
.I tried to keep the code duplication as minimal as possible.
The first implementation introduces read/write and from/to_table method adaptations from
FluxPoints
, and simple methods for variability tools. It also includes the translator forstingray
(as an optional inclusion) previously presented in #5170 .The class could also use utilities proposed in #5145 and #5156 once they are added, and any future specific utilities.