Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add map geom pixel solid angle computation #1357
@registerrier - Please add at least one test (e.g. with 3x2 pix) case that exercises the new code, to show that it's working. Ideally there would even be a second test case where you have an energy or some extra axis, to show if the code still works and if it then returns a 2D or 3D array in that case (add an assert on shape of return value).
Probably http://docs.gammapy.org/dev/_modules/gammapy/image/core.html#SkyImage.solid_angle already has such a test case that you could copy and adapt here.
I'm not sure if it's useful to have the stub in the base class, I think you could also remove it there, as you like.
For all docstrings, you should give a one-line description so that it shows up nicely in the API summary lists. For cases like this one I'd suggestion to put a single line instead of a Returns section as explained here:
I see that the current
mode='edge' and that
_get_pix_coords is non-ideal. Here's what we had in the old class:
@registerrier - Presumably you don't want to improve the functionality to generate coordinate grids in this PR? If so, please change the comments in your implementation a bit to make it clearer that there's a TODO and what should be done. I'd suggest this:
# TODO: the following lines should be improved to be more clean and efficient. # E.g. we could expose `mode='edge'` directly on `WcsGeom.get_coord`
Efficiency is not really a concern, because coordinate and solid angle arrays are only computed rarely. But IMO we should avoid re-implementing things, so I'm -1 on your proposal in the current code to call
self._wcs.all_pix2world directly from
@registerrier - I've done a second round of review.
To significant suggestions:
- return a 2D array only
- change test case to AITOFF with large pixels, and check that something sensible happens for a pixel that is outside or partially outside the image.