Attention @shanosborne. There appear to be some FITS header keywords that need to be set for extension keywords. I'm seeing the following problem when trying to save PSFs. This is on astropy 3.0.2 in case that makes any difference.
I think you may need to avoid the deepcopy of the header after appending the new HDU, in your changes to calc_psf. The HDUList.append() function is supposed to handle the necessary keywords for an Image extension HDU, but right now that's getting overwritten with a copy of the 0th extension primary HDU header. When you make the new Image HDU, use both the data and the header in that call. Then append that onto the PSF HDUList. Try that and see if the files will write to disk after that, please.
---------------------------------------------------------------------------
VerifyError Traceback (most recent call last)
<ipython-input-3-d45cf959f106> in <module>()
1 nrc = webbpsf.NIRCam()
2 psf = nrc.calc_psf(nlambda=1)
----> 3 psf.writeto('test.fits')
~/software/miniconda3/envs/astroconda/lib/python3.6/site-packages/astropy/utils/decorators.py in wrapper(*args, **kwargs)
486 # one with the name of the new argument to the function
487 kwargs[new_name[i]] = value
--> 488 return function(*args, **kwargs)
489
490 return wrapper
~/software/miniconda3/envs/astroconda/lib/python3.6/site-packages/astropy/io/fits/hdu/hdulist.py in writeto(self, fileobj, output_verify, overwrite, checksum)
851 return
852
--> 853 self.verify(option=output_verify)
854
855 # make sure the EXTEND keyword is there if there is extension
~/software/miniconda3/envs/astroconda/lib/python3.6/site-packages/astropy/io/fits/verify.py in verify(self, option)
117 warnings.warn(line, VerifyWarning)
118 else:
--> 119 raise VerifyError('\n' + '\n'.join(messages))
120
121
VerifyError:
Verification reported errors:
HDU 2:
'XTENSION' card does not exist.
'PCOUNT' card does not exist.
'GCOUNT' card does not exist.
'PCOUNT' card does not exist.
Attention @shanosborne. There appear to be some FITS header keywords that need to be set for extension keywords. I'm seeing the following problem when trying to save PSFs. This is on astropy 3.0.2 in case that makes any difference.
I think you may need to avoid the
deepcopy
of the header after appending the new HDU, in your changes tocalc_psf
. TheHDUList.append()
function is supposed to handle the necessary keywords for an Image extension HDU, but right now that's getting overwritten with a copy of the 0th extension primary HDU header. When you make the new Image HDU, use both the data and the header in that call. Then append that onto the PSF HDUList. Try that and see if the files will write to disk after that, please.