Open keflavich opened 2 weeks ago
Example of what this might look like:
def save_epsf(epsf, filename, overwrite=True):
header = {}
header['OVERSAMP'] = list(epsf.oversampling)
hdu = fits.PrimaryHDU(data=epsf.data, header=header)
hdu.writeto(filename, overwrite=overwrite)
def read_epsf(filename):
fh = fits.open(filename)
hdu = fh[0]
return EPSFModel(data=hdu.data, oversampling=hdu.header['OVERSAMP'])
Seems really simple, and there are other parameters one should include, but maybe it's fine?
I'd also like to fit and save gridded EPSFs...
Is there an established mechanism for saving/serializing fitted epsfs?
webbpsf has some mechanisms for writing/reading their models: https://github.com/spacetelescope/webbpsf/blob/7c74ffbcd777f01a9046ff5b61711fb4de6ade86/webbpsf/gridded_library.py#L497 https://github.com/spacetelescope/webbpsf/blob/7c74ffbcd777f01a9046ff5b61711fb4de6ade86/webbpsf/utils.py#L870
It would be really useful to do the same in photutils. Maybe this already exists, though, and I've failed to search the documentation?