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
Improve map read method #1246
This PR addresses #1242 by rewriting
I find it slightly simpler - the
MapBase.read doesn't need to concern itself any more with a list of intermediate base classes, having "auto" instead of "None" is a matter of taste - I find uniformity in type helpful, makes documentation and configuration a little easier, even compared to the default of None.
I think the format discovery is a little better because it only reads FITS headers, no data. I'm not sure if the current implementation loaded the data twice (once for format discovery, once in the
from_hdulist call. Probably not, the data is loaded once in format discovery and then stored on the hdulist object and just read again from memory in the
from_hdulist call creating the map?
One more thing I saw: in many places you support two strings, e.g. "wcs" and the classname as a string like "MapWCSND". Suggest to remove the second option. Having two ways to do the same thing will just lead to more work for us (testing, documentation) and confusion for users (some use one string, others the second). @woodmd @registerrier - Thoughts on this point?
Thanks for the suggestions. I agree your approach is cleaner so let's go with that. The current implementation was only reading the data once. My understanding is that
Agreed. I'll amend this PR now to remove the class string options.
This is also my understanding.
Note that you're accessing
I think this could sometimes trigger unnecessary data reads from disk for users, specifically if the primary HDU contains data but is not what they want, e.g. in
A while ago I wrote this with a similar purpose, trying to add some conveniences to
Ah I didn't think of this but I suspect
I don't have any particular attachment to the helper functions in gammapy/maps/utils.py and I wasn't intentionally trying to keep
@woodmd - I came up with this to handle the empty HDU:
I think I looked around the
I'm pretty sure your
I think using
Yes, looks like the
So ready to merge here, no?