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 code to make model images from a source catalog #160

Merged
merged 6 commits into from Aug 22, 2014

Conversation

Projects
None yet
2 participants
@ellisowen
Contributor

ellisowen commented Aug 4, 2014

Incomplete, work in progress - I made a pull request to allow discussion about the structure & implementation.

Note that some functions also use stuff used in npred_cube2 pull request (which is why I rebased against it in this PR).

To do (Ellis):

  • Check output type & format looks sensible
  • Ensure output values are sensible (Flux normalization)
  • Write unit tests
  • Add doc strings
  • Add short tutorial
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 4, 2014

Member

Let's try and finish #151 first ... reviewing a PR that contains commits from another PR is difficult, because the diff is large and it's not clear what should be reviewed in this PR.

One thing you can do now is make format the task list above as described here so that you can tick the items off as you complete them.

Member

cdeil commented Aug 4, 2014

Let's try and finish #151 first ... reviewing a PR that contains commits from another PR is difficult, because the diff is large and it's not clear what should be reviewed in this PR.

One thing you can do now is make format the task list above as described here so that you can tick the items off as you complete them.

Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 4, 2014

Member

Yes, adding this to the existing npred tutorial or making a new one that creates npred images for the Fermi catalog sources would be nice (and show that this actually works)

Member

cdeil commented Aug 4, 2014

Yes, adding this to the existing npred tutorial or making a new one that creates npred images for the Fermi catalog sources would be nice (and show that this actually works)

@ellisowen

This comment has been minimized.

Show comment
Hide comment
@ellisowen

ellisowen Aug 7, 2014

Contributor

Positioning and generating images works OK, but flux normalization is off by about 30 orders of magnitude between the point sources and diffuse sources... I still need to understand why.

Contributor

ellisowen commented Aug 7, 2014

Positioning and generating images works OK, but flux normalization is off by about 30 orders of magnitude between the point sources and diffuse sources... I still need to understand why.

@ellisowen

This comment has been minimized.

Show comment
Hide comment
@ellisowen

ellisowen Aug 7, 2014

Contributor

To save time, would it be OK if I just implement the point source stuff for one energy band? This is all that's needed for the proceeding, and I think figuring out what the problem is with the flux of the extended sources, and extending the code to work with cubes would be a lot of work...

Contributor

ellisowen commented Aug 7, 2014

To save time, would it be OK if I just implement the point source stuff for one energy band? This is all that's needed for the proceeding, and I think figuring out what the problem is with the flux of the extended sources, and extending the code to work with cubes would be a lot of work...

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 7, 2014

Member

Yes, one energy band is OK.

I've been thinking lately that probably using lists of 2D images as much as possible could be better than using 3D cubes. Then one could simply concatenate lists to e.g. work on Fermi and HESS data simultaneously.

Member

cdeil commented Aug 7, 2014

Yes, one energy band is OK.

I've been thinking lately that probably using lists of 2D images as much as possible could be better than using 3D cubes. Then one could simply concatenate lists to e.g. work on Fermi and HESS data simultaneously.

@ellisowen

This comment has been minimized.

Show comment
Hide comment
@ellisowen

ellisowen Aug 9, 2014

Contributor

This now works + tests + tutorial added.

The Travis CI build should pass once npred_cube2 and vela_corrections pull requests have been merged (at which point I will also be able to clear up the commit history here).

There are a few semi-implemented options and functions included which might be useful to implement in the future but would take too long to do now. I left these with 'NotImplementedErrors' for now and TODO comments.

Contributor

ellisowen commented Aug 9, 2014

This now works + tests + tutorial added.

The Travis CI build should pass once npred_cube2 and vela_corrections pull requests have been merged (at which point I will also be able to clear up the commit history here).

There are a few semi-implemented options and functions included which might be useful to implement in the future but would take too long to do now. I left these with 'NotImplementedErrors' for now and TODO comments.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 20, 2014

Member

Now that #151 is merged into master, could you please rebase this PR?

Member

cdeil commented Aug 20, 2014

Now that #151 is merged into master, could you please rebase this PR?

@ellisowen

This comment has been minimized.

Show comment
Hide comment
@ellisowen

ellisowen Aug 20, 2014

Contributor

OK, rebased & ready for review... although I see there is new functionality catalog to cube in gammapy.astro.population - I'm not sure if this duplicates what I implement here?

Contributor

ellisowen commented Aug 20, 2014

OK, rebased & ready for review... although I see there is new functionality catalog to cube in gammapy.astro.population - I'm not sure if this duplicates what I implement here?

image = catalog_image(reference, psf, catalog='simulation', source_type='point',
total_flux=True, sim_table=table)
# Plot

This comment has been minimized.

@cdeil

cdeil Aug 21, 2014

Member

Please change the plotting for sky images to use alpy so that the images have coordinate axes.

Here's an example that works in this case:

# Plot
from aplpy import FITSFigure
fig = FITSFigure(image.to_fits()[0])
fig.show_grayscale(stretch='sqrt', interpolation='none')
fig.add_colorbar()
@cdeil

cdeil Aug 21, 2014

Member

Please change the plotting for sky images to use alpy so that the images have coordinate axes.

Here's an example that works in this case:

# Plot
from aplpy import FITSFigure
fig = FITSFigure(image.to_fits()[0])
fig.show_grayscale(stretch='sqrt', interpolation='none')
fig.add_colorbar()
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 21, 2014

Member

You have to add

from .catalog import *

to gammapy/image/__init__.py.
Then please check that the API docs look OK by running python setup.py build_sphinx.

Member

cdeil commented Aug 21, 2014

You have to add

from .catalog import *

to gammapy/image/__init__.py.
Then please check that the API docs look OK by running python setup.py build_sphinx.

@ellisowen

This comment has been minimized.

Show comment
Hide comment
@ellisowen

ellisowen Aug 21, 2014

Contributor

I wasn't able to check the aplpy images because of the issues I mentioned before, but I guess if they didn't work Travis CI would fail?

Otherwise, this should now address your comments.

Contributor

ellisowen commented Aug 21, 2014

I wasn't able to check the aplpy images because of the issues I mentioned before, but I guess if they didn't work Travis CI would fail?

Otherwise, this should now address your comments.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 21, 2014

Member

I've built the html docs locally and put the online for discussion / reference.
The tutorial is here and the two functions added here are catalog_image and catalog_table.

For the tutorial, could you maybe make a 300 x 100 pix image so that one sees more of the Galactic plane?
I don't remember what aplpy issue you had, but you need to resolve that anyways to make nice plots for your report and the proceeding, no? Email me if you can't get it to work.

I'll leave some inline comments ... one more round of code review.

Member

cdeil commented Aug 21, 2014

I've built the html docs locally and put the online for discussion / reference.
The tutorial is here and the two functions added here are catalog_image and catalog_table.

For the tutorial, could you maybe make a 300 x 100 pix image so that one sees more of the Galactic plane?
I don't remember what aplpy issue you had, but you need to resolve that anyways to make nice plots for your report and the proceeding, no? Email me if you can't get it to work.

I'll leave some inline comments ... one more round of code review.

Show outdated Hide outdated gammapy/image/catalog.py Outdated
source_spec_cube = GammaSpectralCube(data=Quantity(np.array([source.data]), ''),
wcs=source_wcs, energy=energy)
new_source_cube = source_spec_cube.reproject_to(reference_cube)
# TODO: Fix this hack

This comment has been minimized.

@cdeil

cdeil Aug 21, 2014

Member

Can you resolve this TODO?
(or explain what it's about and I'll try to help)

@cdeil

cdeil Aug 21, 2014

Member

Can you resolve this TODO?
(or explain what it's about and I'll try to help)

This comment has been minimized.

@ellisowen

ellisowen Aug 21, 2014

Contributor

The flux values are about 30 orders of magnitude larger than I expected for the extended image, and I don't know why...
However, I don't need this function anymore so I don't think there's any point in implementing it now - shall I put a not implemented error or just remove the code?

@ellisowen

ellisowen Aug 21, 2014

Contributor

The flux values are about 30 orders of magnitude larger than I expected for the extended image, and I don't know why...
However, I don't need this function anymore so I don't think there's any point in implementing it now - shall I put a not implemented error or just remove the code?

This comment has been minimized.

@cdeil

cdeil Aug 22, 2014

Member

At some point we do want to add the extended sources ... so let's leave this as-is and figure it out later.

@cdeil

cdeil Aug 22, 2014

Member

At some point we do want to add the extended sources ... so let's leave this as-is and figure it out later.

Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
Show outdated Hide outdated gammapy/image/catalog.py Outdated
@ellisowen

This comment has been minimized.

Show comment
Hide comment
@ellisowen

ellisowen Aug 21, 2014

Contributor

OK, I think I got all your comments.
I left one or two questions in line.

The Travis CI failures don't currently make sense to me; the errors are quite cryptic (& don't occur when I run setup.py locally)

(Oh, and I've got aplpy to work on my laptop, so I'll probably make a PR in the next day or so to change the npred cube tutorial images to use it)

Contributor

ellisowen commented Aug 21, 2014

OK, I think I got all your comments.
I left one or two questions in line.

The Travis CI failures don't currently make sense to me; the errors are quite cryptic (& don't occur when I run setup.py locally)

(Oh, and I've got aplpy to work on my laptop, so I'll probably make a PR in the next day or so to change the npred cube tutorial images to use it)

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 22, 2014

Member

I also don't know what this travis-ci failure is about:
https://travis-ci.org/gammapy/gammapy/jobs/33231332
I've re-started all travis-ci builds for this repo ... lets' see if the issue disappears.

Member

cdeil commented Aug 22, 2014

I also don't know what this travis-ci failure is about:
https://travis-ci.org/gammapy/gammapy/jobs/33231332
I've re-started all travis-ci builds for this repo ... lets' see if the issue disappears.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 22, 2014

Member

Travis-ci passed ... merging this now.

Thanks!

Member

cdeil commented Aug 22, 2014

Travis-ci passed ... merging this now.

Thanks!

cdeil added a commit that referenced this pull request Aug 22, 2014

@cdeil cdeil merged commit c4b48ed into gammapy:master Aug 22, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

@cdeil cdeil changed the title from Image from catalog to Add code to make model images from a source catalog Apr 8, 2015

@cdeil cdeil added the feature label Apr 8, 2015

@cdeil cdeil added this to the 0.1 milestone Apr 8, 2015

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