-
Notifications
You must be signed in to change notification settings - Fork 16
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
Problem updating FITS header using pyfits 3.4 #44
Comments
Thanks @dgroenewald ! Yes, the syntax will need to be updated. One other update that we should consider making is switching from pyfits to astropy as pyfits is no longer in active development as well. Once you have confirmed this is the problem, this would be a great thing for you to fix @dgroenewald to learn how to submit an update and bug report, so I'm assigning you to it. |
I’m glad to see there are others now using polsalt. I have been switching to astropy as I go, but I see specpolwavmap is still on old pyfits. Steve, am I right that switching to astropy would not have fixed the problem seen here, and it is still necessary to update the syntax in all uses of header.update? So, like in this case it should have been: (with the extra parens)? Ken From: Steve Crawford [mailto:[email protected]] Thanks @dgroenewaldhttps://github.com/dgroenewald ! Yes, the syntax will need to be updated. One other update that we should consider making is switching from pyfits to astropy as pyfits is no longer in active development as well. Once you have confirmed this is the problem, this would be a great thing for you to fix @dgroenewaldhttps://github.com/dgroenewald to learn how to submit an update and bug report, so I'm assigning you to it. — |
Correct--adding the extra parenthesis would be the necessary fix (there is one other spot in the code that needs to be fixed as well). |
Actually, this seems to be related to deprecation warnings I get whenever we are using astropy, like in specpolfinalstokes: WARNING: AstropyDeprecationWarning: The use of header.update() to add new keywords to a header is If I use their advice, and change all uses of update in this way, it works fine and the warning goes away. So I would propose to do this in all cases where update is used (there are a lot of them). Ken From: Steve Crawford [mailto:[email protected]] Correct--adding the extra parenthesis would be the necessary fix (there is one other spot in the code that needs to be fixed as well). — |
I’ve uploaded a new version, knnov16_2, which fixes this issue in all the routines used in specpolreduce, and upgrades pyfits to astropy where it wasn’t. Also, I uploaded a new version of polsalt/data/wppaterns.txt, which I noticed was still the old version on github. Ken From: Steve Crawford [mailto:[email protected]] Correct--adding the extra parenthesis would be the necessary fix (there is one other spot in the code that needs to be fixed as well). — |
To check whether the above-mentioned error was caused by using the latest version of pyfits, I first downgraded pyfits to version 3.3 and ran the script again. It compiled successfully, however I also received a deprecation warning (see below)
Secondly, the warning was solved by updating the header.update syntax to be compatible with pyfits 3.4. I did this in 3 places in the specpolwavmap.py script. Just as Ken suggested above, the fix is implemented by adding an extra parenthesis, however the extra parenthesis should be "{}" and not round brackets. With these changes made, I ran the code again (using pyfits 3.4) and it compiled successfully. |
Hi Daniel-
Um, the latest polsalt merge (knnov16_2) should have accomplished all these things. I got rid of all header.update references, going to direct substitution, as advised by the deprecation notice below, and went to astropy for all the pyfits.
Ken
From: Danièl Groenewald [mailto:[email protected]]
Sent: Thursday, November 24, 2016 3:16 AM
To: saltastro/polsalt
Cc: KENNETH H NORDSIECK; Comment
Subject: Re: [saltastro/polsalt] Problem updating FITS header using pyfits 3.4 (#44)
To check whether the above-mentioned error was caused by using the latest version of pyfits, I first downgraded pyfits to version 3.3 and ran the script again. It compiled successfully, however I also received a deprecation warning (see below)
/home/dviljoen/.conda/envs/iraf27/lib/python2.7/site-packages/pyfits/header.py:1108: PyfitsDeprecationWarning: The use of header.update() to add new keywords to a header is deprecated. Instead, use either header.set() or simplyheader[keyword] = valueorheader[keyword] = (value, comment). header.set() is only necessary to use if you also want to use the before/after keyword arguments. "keyword arguments.", PyfitsDeprecationWarning)
Secondly, the warning was solved by updating the header.update syntax to be compatible with pyfits 3.4. I did this in 3 places in the specpolwavmap.py script. Just as Ken suggested above, the fix is implemented by adding an extra parenthesis, however the extra parenthesis should be "{}" and not round brackets.
For example, in the case of pyfits 3.3 the command to update the header will be:
for f in ('SCI','VAR','BPM','WAV'): hdu[f].header.update('CTYPE3','O,E')
and in pyfits 3.4 it is:
for f in ('SCI','VAR','BPM','WAV'): hdu[f].header.update({'CTYPE3': 'O,E'})
With these changes made, I ran the code again (using pyfits 3.4) and it compiled successfully.
I am still working towards updating the code using astropy (instead of pyfits).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<#44 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ADRf7U9EWpQ6_FtmLsSytORRpd_VoSM4ks5rBVWzgaJpZM4K2Ukq>.
|
Ran reducepoldata.py using pyfits 3.4.
Got the following error.
Cause: syntax used in script to update header of FITS is based on pyfits 3.3 and has since been deprecated.
The above syntax in the script should be updated for the latest pyfits version (v3.4).
The text was updated successfully, but these errors were encountered: