-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_webbpsf.py
64 lines (51 loc) · 1.75 KB
/
test_webbpsf.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
import argparse
from astropy.io import fits
import matplotlib.pyplot as plt
from poppy import radial_profile
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"],
# fmt: on
)
parser.add_argument("--png", help="save figure as a png file", action="store_true")
parser.add_argument("--pdf", help="save figure as a pdf file", action="store_true")
args = parser.parse_args()
# make plot
fontsize = 14
font = {"size": fontsize}
plt.rc("font", **font)
plt.rc("lines", linewidth=2)
plt.rc("axes", linewidth=2)
plt.rc("xtick.major", width=2)
plt.rc("ytick.major", width=2)
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 6))
cfilter = args.filter
psf_fname = f"PSFs/miri_{cfilter}_psf.fits"
psf = fits.open(psf_fname)
ee2 = webbpsf.measure_ee(psf, ext=3)
ee1 = webbpsf.measure_ee(psf)
radius, profile, ee = radial_profile(psf, ee=True, ext=0)
radius2, profile2, ee2 = radial_profile(psf, ee=True, ext=3)
ax.plot(radius * 0.11 * 4, ee, label="optical only")
ax.plot(radius2 * 0.11 * 4, ee2, label="w/ detector")
ax.set_xlim(0.0, 3.5)
#webbpsf.display_ee(psf)
#webbpsf.display_ee(psf, ext=3, overplot=True, ax=ax)
psf.close()
ax.legend()
plt.tight_layout()
fname = f"Figs/{filter}_webbpsf_ee_comp"
if args.png:
fig.savefig(f"{fname}.png")
elif args.pdf:
fig.savefig(f"{fname}.pdf")
else:
plt.show()