-
Notifications
You must be signed in to change notification settings - Fork 6
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
Astropy commentary cards not handled by munch #31
Comments
Hi @vandalt |
Hi @neutrinoceros, |
As long as there is a long-term issue opened here to keep track of it, and allow us to easily get rid of the hack once it stops being necessary, I think it's the right thing to do indeed. |
@neutrinoceros The fix I have right now is implemented directly in If you confirm this is OK, I can change it and still mark it as "HACK" with some comments. Otherwise I would still put the fix in |
Indeed @vandalt, the if statement was a work around for SPHERE, with the idea to fix it properly latter. My idea, for now, is to check if the header of the instrument (no matter which it is) is compliant with munch. If I remember correctly, the problem with _HeaderCommentaryCards appeared during the "munchify" formatting (using the alias dict2class in the code). So the Astropy issue is another problem and we need to fix it. So, for me, you can just implement your solution, compatible with both SPHERE and NIRISS, and it's ok. |
Sounds good. Indeed the issue appears in I'll send a PR with the fix I currently have. |
Now that #45 is merged, I will keep an eye on the upstream issue with Astropy. Regarding my last comment, do you think it is worth opening an issue with munch as well ? In the meantime, as @neutrinoceros mentioned in #45, this issue should probably stay open to track things upstream and remove the hack currently in use when it becomes possible. |
I don't think there's anything wrong with munch itself, unless I've missed something ? |
Not really, but adding a check with |
So I dug up the conversation on Astropy that you started @vandalt: |
This issue is still open? We have to wait for Astropy team right @neutrinoceros? |
Actually Astropy 4.0.6 was released 9 days ago and may have the fix. I'll try reversing the temp fix now |
As I mentioned in #59, the Astropy change that fixes this is not included in the latest release. It is in the main branch and has been included in the Astropy 5.0 milestone, as @neutrinoceros pointed out. But I confirm that the upstream changes remove the need for the hack currently used in AMICAL (removing commentary cards before giving the header to munch). |
When reading a fits file that has
_HeaderCommentaryCards
keys, munch seems to interpret them as mappings and looks for a.keys
. This causesamical.extract_bs
to crash with the error message below.Click to see the error message
Maybe this is an issue with how the
_HeaderCommentaryCards
class is defined in astropy (see here) ? The solution could be to file an issue upstream with astropy to see if this could be handled there. Otherwise, this could be handled by AMICAL if you are OK with simply removing the COMMENT and HISTORY keys when creating the oifits files. I implemented the latter fix locally and it works fine. There might also be a better solution. I'm not an expert with astropy fits handling or with munch.Let me know what you think @DrSoulain. I can then either send a PR or fill an issue on the astropy github (or both, if you want to use the PR as a temporary fix).
The text was updated successfully, but these errors were encountered: