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 function to plot Fermi catalog light curves #286

Merged
merged 29 commits into from Jun 29, 2015

Conversation

Projects
None yet
2 participants
@JonathanDHarris
Contributor

JonathanDHarris commented Jun 13, 2015

@cdeil
Here's a first version for review. I'm not that familiar with Python, so don't be afraid to be pedantic about:
-naming conventions,
-how / where I import things
-comment styles
-etc

At the moment the tool plots Fermi MET as the x-axis. I don't know if there is a package default to use MJD or something else, in which case I can change it. I'm also just showing the plot when you call the function, if you want an object returned then let me know, I might need an example of the format.

@cdeil cdeil added the feature label Jun 13, 2015

@cdeil cdeil added this to the 0.3 milestone Jun 13, 2015

@cdeil cdeil self-assigned this Jun 13, 2015

Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 13, 2015

Member

@JonathanDHarris - I've left inline comments. Please ask if it's unclear what I mean or what should be done. I'll probably have some more style comments later, so please be patient ... review of the first few pull requests for new contributors usually takes a while with any project. For now the important thing is to have a working example in the docstring and, if you want to take this on, have a correct time axis with years and months.

Member

cdeil commented Jun 13, 2015

@JonathanDHarris - I've left inline comments. Please ask if it's unclear what I mean or what should be done. I'll probably have some more style comments later, so please be patient ... review of the first few pull requests for new contributors usually takes a while with any project. For now the important thing is to have a working example in the docstring and, if you want to take this on, have a correct time axis with years and months.

@cdeil cdeil changed the title from First version of a Fermi light curve tool to Add function to plot Fermi catalog light curves Jun 13, 2015

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 13, 2015

Member

One more thing: you can drag & drop PNG images into the Github comment field.
Could you please do this for this PR?

Member

cdeil commented Jun 13, 2015

One more thing: you can drag & drop PNG images into the Github comment field.
Could you please do this for this PR?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 13, 2015

Member

@JonathanDHarris - I think plotting functions should take an axes object as input and also return it.
See astropy/astroplan#7 (comment)
Once the discussion there is settled, we'll document this pattern here.

It's quite a bit of boilerplate code, but it means a lot of flexibility for the caller, e.g. users could easily plot several light curves in panels (example).

Member

cdeil commented Jun 13, 2015

@JonathanDHarris - I think plotting functions should take an axes object as input and also return it.
See astropy/astroplan#7 (comment)
Once the discussion there is settled, we'll document this pattern here.

It's quite a bit of boilerplate code, but it means a lot of flexibility for the caller, e.g. users could easily plot several light curves in panels (example).

@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

JonathanDHarris Jun 14, 2015

Contributor

@cdeil
I think I've taken into account all of your comments. I do need to go back through and double check. I'm on holiday this week so I might be out of touch for a little while.

python setup.py test -P time shows 4 tests passed for me now.

I had trouble pulling from origin master earlier, but I don't think it has effected this work.

Contributor

JonathanDHarris commented Jun 14, 2015

@cdeil
I think I've taken into account all of your comments. I do need to go back through and double check. I'm on holiday this week so I might be out of touch for a little while.

python setup.py test -P time shows 4 tests passed for me now.

I had trouble pulling from origin master earlier, but I don't think it has effected this work.

@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris
Contributor

JonathanDHarris commented Jun 14, 2015

exampleplot

Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris
Contributor

JonathanDHarris commented Jun 19, 2015

exampleplot

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 19, 2015

Member

There's still this issue on travis-ci:
https://travis-ci.org/gammapy/gammapy/jobs/67544898#L1856

@JonathanDHarris – Are you seeing the same locally?

I'll try it out locally now.

Member

cdeil commented Jun 19, 2015

There's still this issue on travis-ci:
https://travis-ci.org/gammapy/gammapy/jobs/67544898#L1856

@JonathanDHarris – Are you seeing the same locally?

I'll try it out locally now.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 19, 2015

Member

I don't know why I didn't think about this before, but now I think it would be better to refactor this code into a LightCurve class that sub-classes Table and has a plot method. Then this could be re-used for other light curves, e.g. from HESS or X-ray or whatever.
However I'm not suggesting you try to do this here ... creating the LightCurve class will take thought and discussion and more work (e.g. for FITS / CSV I/O) ... just wanted to mention it here because I thought of it just now that this will have to be done in the future.

Member

cdeil commented Jun 19, 2015

I don't know why I didn't think about this before, but now I think it would be better to refactor this code into a LightCurve class that sub-classes Table and has a plot method. Then this could be re-used for other light curves, e.g. from HESS or X-ray or whatever.
However I'm not suggesting you try to do this here ... creating the LightCurve class will take thought and discussion and more work (e.g. for FITS / CSV I/O) ... just wanted to mention it here because I thought of it just now that this will have to be done in the future.

Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
Show outdated Hide outdated gammapy/time/plot.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 22, 2015

Member

I can't reproduce the Sphinx errors TypeError: 'AxesSubplot' object is not callable locally:
https://travis-ci.org/gammapy/gammapy/jobs/67544898#L1855
It's unrelated to this PR ... if it doesn't go away with the next travis-ci run here I'll investigate.

This PR is almost ready.

One thing that would be nice is if you squash the 24 commits here down into a single commit "Add function to plot Fermi 3FGL light curves". I've usually used git rebase -i master as described here, but in this case it might also make sense to do this non-interactively as described here.
If you decide to do this, please make a backup copy of your repo before you do. If you don't want to, that's fine, too, a clean git commit history of Gammapy is not terribly important.

Member

cdeil commented Jun 22, 2015

I can't reproduce the Sphinx errors TypeError: 'AxesSubplot' object is not callable locally:
https://travis-ci.org/gammapy/gammapy/jobs/67544898#L1855
It's unrelated to this PR ... if it doesn't go away with the next travis-ci run here I'll investigate.

This PR is almost ready.

One thing that would be nice is if you squash the 24 commits here down into a single commit "Add function to plot Fermi 3FGL light curves". I've usually used git rebase -i master as described here, but in this case it might also make sense to do this non-interactively as described here.
If you decide to do this, please make a backup copy of your repo before you do. If you don't want to, that's fine, too, a clean git commit history of Gammapy is not terribly important.

@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

JonathanDHarris Jun 26, 2015

Contributor

@cdeil
It's very odd that the arrow direction on the limit is the other way around for you. This is what I see. Any idea why that might be?

exampleplot

Contributor

JonathanDHarris commented Jun 26, 2015

@cdeil
It's very odd that the arrow direction on the limit is the other way around for you. This is what I see. Any idea why that might be?

exampleplot

@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

JonathanDHarris Jun 26, 2015

Contributor

I'm changing the style to match the one you suggested, because the pyplot upperlimits are always fiddly. But if you know why we saw them point in opposite directions I'd be interested to know for future reference.

exampleplot

Contributor

JonathanDHarris commented Jun 26, 2015

I'm changing the style to match the one you suggested, because the pyplot upperlimits are always fiddly. But if you know why we saw them point in opposite directions I'd be interested to know for future reference.

exampleplot

plt.show()
"""
from ..datasets import fetch_fermi_catalog
from ..time.utils import TIME_REF_FERMI

This comment has been minimized.

@cdeil

cdeil Jun 27, 2015

Member

Can you move the TIME_REF_FERMI import to the top of the file?
That should be the default, and only if that doesn't work for some reason (circular import, optional dependency), then it's moved into functions / methods.

@cdeil

cdeil Jun 27, 2015

Member

Can you move the TIME_REF_FERMI import to the top of the file?
That should be the default, and only if that doesn't work for some reason (circular import, optional dependency), then it's moved into functions / methods.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 27, 2015

Member

@JonathanDHarris – Now there's a merge conflict (probably in the changelog and easy to resolve), which is the reason travis-ci isn't running. Can you please rebase on master?

Member

cdeil commented Jun 27, 2015

@JonathanDHarris – Now there's a merge conflict (probably in the changelog and easy to resolve), which is the reason travis-ci isn't running. Can you please rebase on master?

@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

JonathanDHarris Jun 28, 2015

Contributor

Hm. Travis fails again. This is causing hard to trouble shoot because if I run python setup.py build_sphinx the build fails, but if I run exactly the same command again it will then pass.

Contributor

JonathanDHarris commented Jun 28, 2015

Hm. Travis fails again. This is causing hard to trouble shoot because if I run python setup.py build_sphinx the build fails, but if I run exactly the same command again it will then pass.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 28, 2015

Member

@JonathanDHarris – The reason for the travis-ci fails is: astropy/astroplan#15

Could you please uncomment this line?
https://github.com/gammapy/gammapy/blob/master/gammapy/conftest.py#L35
Then they should pass and we can merge this.

For the future ... you should have rebased on master, not merged master into your branch:
https://github.com/gammapy/gammapy/network
That way Gammapy will have a simple, linear history.
For this time, it doesn't matter ... leave as is.

Member

cdeil commented Jun 28, 2015

@JonathanDHarris – The reason for the travis-ci fails is: astropy/astroplan#15

Could you please uncomment this line?
https://github.com/gammapy/gammapy/blob/master/gammapy/conftest.py#L35
Then they should pass and we can merge this.

For the future ... you should have rebased on master, not merged master into your branch:
https://github.com/gammapy/gammapy/network
That way Gammapy will have a simple, linear history.
For this time, it doesn't matter ... leave as is.

Show outdated Hide outdated gammapy/time/plot.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 28, 2015

Member

This now looks good to me and locally this works for me also.
Let's hope travis-ci passes, then I'll merge tonight.

Member

cdeil commented Jun 28, 2015

This now looks good to me and locally this works for me also.
Let's hope travis-ci passes, then I'll merge tonight.

@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

JonathanDHarris Jun 28, 2015

Contributor

Fingers crossed!

Contributor

JonathanDHarris commented Jun 28, 2015

Fingers crossed!

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 29, 2015

Member

@JonathanDHarris – Another fail came up that's unrelated to this PR:
https://travis-ci.org/gammapy/gammapy/jobs/68707705#L1115
It's a recently-introduced bug in Astropy:
astropy/astropy#3891 (comment)

I'll disable that test for now in Gammapy with a commit directly to master and then re-start the build here. Then it should pass.

Member

cdeil commented Jun 29, 2015

@JonathanDHarris – Another fail came up that's unrelated to this PR:
https://travis-ci.org/gammapy/gammapy/jobs/68707705#L1115
It's a recently-introduced bug in Astropy:
astropy/astropy#3891 (comment)

I'll disable that test for now in Gammapy with a commit directly to master and then re-start the build here. Then it should pass.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 29, 2015

Member

The travis-ci build for master is broken here anyways because of this issue that astroplan downloads a file on import:
https://travis-ci.org/gammapy/gammapy/jobs/68773866#L1135

So I'm merging this now, and if there's some other issue I'll fix it in master.
I don't expect there to be though ... this looks good!

Thanks for the nice contribution and for being patient with code review and dealing with unrelated issues!

Member

cdeil commented Jun 29, 2015

The travis-ci build for master is broken here anyways because of this issue that astroplan downloads a file on import:
https://travis-ci.org/gammapy/gammapy/jobs/68773866#L1135

So I'm merging this now, and if there's some other issue I'll fix it in master.
I don't expect there to be though ... this looks good!

Thanks for the nice contribution and for being patient with code review and dealing with unrelated issues!

cdeil added a commit that referenced this pull request Jun 29, 2015

Merge pull request #286 from JonathanDHarris/FermiLightCurves
Add function to plot Fermi catalog light curves

@cdeil cdeil merged commit 6553d24 into gammapy:master Jun 29, 2015

1 check was pending

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 29, 2015

Member

@JonathanDHarris – I've decided to offer the user the possibility to optionally pass in strings to specify the time to make this simpler ... I just forward those along to the Time constructor: 9c979c5

And I've opened #294 as a TODO for me that we need to set up testing of Figures.

Member

cdeil commented Jun 29, 2015

@JonathanDHarris – I've decided to offer the user the possibility to optionally pass in strings to specify the time to make this simpler ... I just forward those along to the Time constructor: 9c979c5

And I've opened #294 as a TODO for me that we need to set up testing of Figures.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

This comment has been minimized.

Show comment
Hide comment
@JonathanDHarris

JonathanDHarris Jun 29, 2015

Contributor

@cdeil Awesome! Thanks for all your help on this.

Contributor

JonathanDHarris commented Jun 29, 2015

@cdeil Awesome! Thanks for all your help on this.

@JonathanDHarris JonathanDHarris deleted the JonathanDHarris:FermiLightCurves branch Jul 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment