-
Notifications
You must be signed in to change notification settings - Fork 194
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 PhaseCurve class for periodic systems #1300
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.
@labsaha - I left two inline comments. Let me know if you have any questions.
gammapy/time/models.py
Outdated
log = logging.getLogger(__name__) | ||
|
||
|
||
class PhaseCurve(object): |
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.
@labsaha - all of the code in the class (including the docstring) should be indented.
gammapy/time/tests/test_models.py
Outdated
|
||
|
||
@pytest.fixture(scope='session') | ||
def phase(): |
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.
Please call this phase_curve
since it is a PhaseCurve
object.
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.
@labsaha - I left a few inline comments, mostly for clean-up. Please do that and push the changes as another commit.
I'll then have a closer look at the API and implementation.
gammapy/time/models.py
Outdated
Φ(t)=Φ0+f0(t−t0)+(1/2)f1(t−t0)^2+(1/6)f2(t−t0)^3 | ||
|
||
|
||
Returns |
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 class docstring should not have a returns section.
It has a Parameters section that documents the parameters of __init__
.
__init__
always returns an instance, doesn't contain a return statement and doesn't need a documentation of the return value.
Presumably here you're documenting the return value of one of the methods. That should be in the docstring of that method.
gammapy/time/models.py
Outdated
normalization factor for the phase using circular interpolation. | ||
The required data for interpolation is given as an astropy table | ||
|
||
# TODO: 1. Checking table values if the phases are in increasing order |
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.
Can you resolve the TODOs? Or explain what the problem is? Is it needed?
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.
Actually, we don't need these TODOs. This was for some checks. Now I feel that it is not correct to put these checks. Hence, I remove TODOs from the docstring
gammapy/time/models.py
Outdated
'PhaseCurve', | ||
] | ||
|
||
log = logging.getLogger(__name__) |
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.
There's no need to emit log messages from this file. Please remove this getLogger call and the import logging above.
@@ -0,0 +1,109 @@ | |||
from __future__ import absolute_import, division, print_function, unicode_literals |
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.
At the very top of each file in Gammapy we have the license line. Please add it.
gammapy/time/tests/test_models.py
Outdated
@pytest.fixture(scope='session') | ||
def phase_curve(): | ||
filename = make_path('$GAMMAPY_EXTRA/test_datasets/phasecurve_LSI_DC.fits') | ||
print(filename) |
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.
remove print statement
gammapy/time/tests/test_models.py
Outdated
import numpy as np | ||
import pytest | ||
from numpy.testing import assert_allclose | ||
from gammapy.time.models import PhaseCurve |
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.
use relative imports for gammapy, like from all other files.
@labsaha - I've done some cleanup in e0946d3 . I used @labsaha - I would suggest to merge this PR now, and then to re-factor later once we have some "callers" for this code, i.e. start to work with these models and get some experience. OK? |
@cdeil The modification you did looks perfect! So we can merge this PR. |
@labsaha - I've done some more edits in fff5ca5, trying to make the evaluate calls more clear and modular / testable. Overall I'm not convinced yet by what we have here, the main question is if / where we should use This will need further thought and discussion by binary / pulsar people. I'm merging this PR now, and then we will change / refactor as we get experience with time models. |
@labsaha - Congratulations on getting your first PR merged into Gammapy! |
@cdeil Thanks a lot for all your help to reach this level!!!!!!! :-) I have also this |
@cdeil Regarding |
@labsaha - Basically at this moment you're the only dev / user of this code, so it's up to you where to use Time objects. If you want to make changes to code or docs or tests that establish behaviour, you can any time send a new pull request, or you can also group changes to this class in your next PR where you add first code to compute phase curves, or at least use times and phase curves in some real application. |
This PR adds
PhaseCurve
class for calculating the phase of a periodic system at a given time. It also calculates the normalization factor at that phase of the system by ring interpolation using a given table ofphase
vsnormalization factor
.