-
Notifications
You must be signed in to change notification settings - Fork 10
Default pupil masks and psfs for wcu modes #291
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d785d70
start with psf by pupil mask name
oczoske 30e8fb5
Script to reformat METIS psfs
oczoske 3a94e13
Pupil masks/psfs for wcu modes
oczoske e66f1b8
Define psf_name for all modes
oczoske 09b0302
demo notebook for psfs
oczoske cb769be
notebook was in the wrong directory
oczoske File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| """Reformat RvB's PSF cubes for use in scopesim | ||
|
|
||
| - scopesim uses multiextension fits files with a single PSF image per extension | ||
| - CUNIT3 "micrometer" replaced by "um" | ||
|
|
||
| Author: Oliver Czoske | ||
| Date: 2025-11-24 | ||
| """ | ||
| import sys | ||
| from pathlib import Path | ||
| import numpy as np | ||
| from astropy.io import fits | ||
| from astropy.wcs import WCS | ||
|
|
||
| def reformat_file(infile): | ||
| """Convert the file `infile`""" | ||
| with fits.open(infile) as hdul: | ||
| nwave = hdul[0].data.shape[0] | ||
| crval = hdul[0].header["CRVAL3"] | ||
| cdelt = hdul[0].header["CDELT3"] | ||
| # Fix some header keywords | ||
| if hdul[0].header["CUNIT3"] == "micrometer": | ||
| hdul[0].header["CUNIT3"] = "um" | ||
| else: | ||
| print("What?", hdul[0].header["CUNIT3"]) | ||
| if "CTYPE1" not in hdul[0].header or hdul[0].header["CTYPE1"] == "": | ||
| hdul[0].header["CTYPE1"] = "LINEAR" | ||
| hdul[0].header["CTYPE2"] = "LINEAR" | ||
|
|
||
| wavelengths = np.exp(crval + cdelt * np.arange(1, nwave+1)) | ||
|
|
||
| wcs = WCS(hdul[0].header).sub(2) | ||
| phdu = fits.PrimaryHDU() | ||
| phdu.header["FILETYPE"] = "Point Spread Functions" | ||
| phdu.header["AUTHOR"] = "Roy van Boekel, Oliver Czoske" | ||
| phdu.header["DATE"] = "2025-11-24" | ||
| phdu.header["ORIGDATE"] = "2025-10-30" | ||
| phdu.header["ORIGFILE"] = (Path(infile).name, "original file name") | ||
| phdu.header["COLDSTOP"] = (hdul[0].header["COLDSTOP"], "name cold pupil mask") | ||
| if "WCU" in infile: | ||
| phdu.header["ELTMASK"] = False | ||
| wcustr = "_WCU" | ||
| else: | ||
| phdu.header["ELTMASK"] = True | ||
| wcustr = "" | ||
| phdu.header["PUPILPS"] = (hdul[0].header["PUPILPS"], "[mm] pupil model pixel size") | ||
| phdu.header["NPIXFFT"] = (hdul[0].header["NPIXFFT"], "number of pixels used in FFT") | ||
| phdu.header["PUPILPS"] = (hdul[0].header["OSAMP"], "over-sampling factor") | ||
| phdu.header["PSIZEPUP"] = (hdul[0].header["PSIZEPUP"], "[mm] pixel size in pupil image") | ||
| outhdul = fits.HDUList([phdu]) | ||
| if "IMG" in infile: | ||
| substr = "IMG" | ||
| elif "LMS" in infile: | ||
| substr = "LMS" | ||
| else: | ||
| raise ValueError("Unknown subsystem") | ||
| outfile = f"psfs/PSF_{substr}_{phdu.header['COLDSTOP']}{wcustr}.fits" | ||
| for i in range(nwave): | ||
| psfimg = hdul[0].data[i,] | ||
| hdr = wcs.to_header() | ||
| hdr['WAVELENG'] = (wavelengths[i], "[um] Wavelength of PSF image") | ||
| hdr['WAVEUNIT'] = 'um' | ||
| hdr['EXTNAME'] = f"PSF_{wavelengths[i]:.2f}um" | ||
|
|
||
| hdu = fits.ImageHDU(data=psfimg, header=hdr) | ||
| outhdul.append(hdu) | ||
| outhdul.writeto(outfile, overwrite=True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| infilelist = sys.argv[1:] | ||
|
|
||
| for thefile in infilelist: | ||
| reformat_file(thefile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be used as the default PSF now? Previously, it was
PSF_SCAO_9mag_06seeing.fits, but now I don't see any actual filename as a default. Just to make sure a default METIS simulation now still uses a PSF at all.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sky modes all have a
psf_file(indefault.yaml). I'll check whether that still works.