-
Notifications
You must be signed in to change notification settings - Fork 0
/
calc_webbpsfs.py
82 lines (73 loc) · 2.42 KB
/
calc_webbpsfs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import argparse
import webbpsf
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--filter",
help="filter to process",
default="F770W",
# fmt: off
choices=["F560W", "F770W", "F1000W",
"F1130W", "F1280W", "F1500W", "F1800W", "F2100W", "F2550W",
"F1065C", "F1140C", "F1550C", "F2300C", "FND"],
# fmt: on
)
args = parser.parse_args()
cfilter = args.filter
# in 0.11 arcsec pixels
filter_fwhm = {
"F560W": 1.636,
"F770W": 2.187,
"F1000W": 2.888,
"F1065C": 2.910,
"F1130W": 3.318,
"F1140C": 3.270,
"F1280W": 3.713,
"F1500W": 4.354,
"F1550C": 4.360,
"F1800W": 5.224,
"F2100W": 5.989,
"F2300C": 6.090,
"F2550W": 7.312,
"FND": 3.7,
}
# Set input parameters:
samp = 4 # psf oversample factor
parity = "even" # set psf model parity to 'odd' or 'even'
fov = 200 * 0.11 * filter_fwhm[cfilter] # fov for the PSF model in arcsec
print(fov)
# Create a MIRI instance and calculate PSF
miri = webbpsf.MIRI()
miri.options["parity"] = parity
miri.filter = cfilter
shiftx = 74.0
shifty = 72.0
if cfilter in ["F1065C", "F1140C", "F1550C", "F2300C"]:
miri.options["parity"] = "odd"
miri.options["source_offset_x"] = shiftx * 0.11
miri.options["source_offset_y"] = -shifty * 0.11
if cfilter in ["F1065C", "F1140C", "F1550C"]:
miri.pupil_mask = "MASKFQPM"
miri.image_mask = f"FQPM{cfilter[1:-1]}"
elif cfilter == "F2300C":
miri.pupil_mask = "MASKLYOT"
miri.image_mask = "LYOT2300"
psf = miri.calc_psf(
fov_pixels=300,
oversample=samp,
# add_distortion=False,
normalize="exit_pupil",
)
else:
psf = miri.calc_psf(fov_arcsec=fov, oversample=samp) # , add_distortion=False)
psf.writeto(f"PSFs/miri_{cfilter}_psf.fits", overwrite=True)
# Calculate encircled energy as a function of distance for the PSF
# ee = webbpsf.measure_ee(psf)
# aradii = np.arange(1.0, 10.0, 0.5)
# ee_frac = ee(aradii)
# print(ee_frac)
# from 1.13.0 docs
#miri = webbpsf.MIRI()
#psf = miri.calc_psf()
#webbpsf.display_psf(psf, ext=3)
#result = psf['DET_DIST'].data # This is the PSF with the cross artifact model included