Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Refactor gammapy.maps methods for calculating index and coordinate arrays #1190
This PR is a rewrite of the
The new implementation returns a multi-dimensional array for each coordinate with the same shape as the data member. Pixels outside the geometry are set to NaN (for coords) or -1 (for indices). I believe this implementation will be more intuitive for users as it means there will be a one-to-one mapping of the data array to the arrays returned by these methods. This will also facilitate implementing slice-based operations on the data. Both methods can still return flattened/masked arrays by calling with
Note that I plan to make a follow-up PR that updates all set/get methods to gracefully handle NaN inputs.
cdeil left a comment
@woodmd - Thanks!
Is this ready to be merged from your side?
I didn't review the implementation here, but a quick suggestion: introduce a constant (e.g. module level? or attached to base class?) for the magic value of -1 and make it appear in the docs somehow? (module-level constants that are listed in
@woodmd - I'm merging this in now.
Just one thought for the future: in xarray and partly also
So in the future, implementing that for