Skip to content
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

Save / serialize solved ePSFs? #1779

Open
keflavich opened this issue Jun 16, 2024 · 1 comment
Open

Save / serialize solved ePSFs? #1779

keflavich opened this issue Jun 16, 2024 · 1 comment

Comments

@keflavich
Copy link
Contributor

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?

@keflavich
Copy link
Contributor Author

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants