-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_subtrans_allobs.py
82 lines (64 loc) · 2.99 KB
/
plot_subtrans_allobs.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 numpy as np
import matplotlib.pyplot as plt
from astropy.table import QTable
from calc_calfactors import get_calfactors
if __name__ == "__main__":
parser = argparse.ArgumentParser()
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 = 20
font = {"size": fontsize}
plt.rc("font", **font)
plt.rc("lines", linewidth=3)
plt.rc("axes", linewidth=3)
plt.rc("xtick.major", width=3)
plt.rc("ytick.major", width=3)
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 7))
# subarrs = np.array(["FULL", "BRIGHTSKY", "SUB256", "SUB128", "SUB64"])
delt = 0.05
subarrs = {"FULL": 0.0,
"BRIGHTSKY": 1.0,
"SUB256": 2.0,
"SUB128": 3.0,
"SUB64": 4.0}
adopted_vals = np.array([1.02, 1.025, 1.0, 1.02, 0.985])
ax.plot(list(subarrs.keys()), adopted_vals, "*", markersize=20, label="Adopted")
for cave, csub in zip(adopted_vals / adopted_vals[0], list(subarrs.keys())):
print(f"{csub} & {cave:.3f} \\\\")
atab = QTable.read("CalFacs/subarray_transfer_F770W.dat",
format="ascii.commented_header")
xvals = np.array([subarrs[csub] for csub in atab["name"].data])
ax.plot(xvals + delt, atab["FracChange"] / atab["FracChange"][2], "ks", alpha=0.7, label="dedicated F770W")
atab = QTable.read("CalFacs/subarray_transfer_F1280W.dat",
format="ascii.commented_header")
xvals = np.array([subarrs[csub] for csub in atab["name"].data])
ax.plot(xvals + 2 * delt, atab["FracChange"] / atab["FracChange"][2], "ko", alpha=0.7, label="dedicated F1280W")
# add in measurements from each of the bands
filters = ["F560W", "F770W", "F1000W", "F1130W", "F1280W",
"F1500W", "F1800W", "F2100W", "F2550W"]
syms = ["v", "^", ">", "<", "p", "X", "D", "P", "d"]
subarrs_vals = np.array((list(subarrs.values())))
for k, cfilter in enumerate(filters):
tab = QTable.read(f"CalFacs/miri_calfactors_grieke_timecor_{cfilter}_subarr.dat",
format="ascii.commented_header")
# relative to SUB256 as it is the one always present
relvals = (tab["calfacs"][2] / tab["calfacs"]) # * atab["FracChange"][2]
relvals_unc = relvals * (tab["calfacs_uncmean"] / tab["calfacs"])
gvals = relvals > 0.0
ax.errorbar(subarrs_vals[gvals] + (k+3)*delt, relvals[gvals],
yerr=relvals_unc[gvals],
fmt=syms[k], label=cfilter, alpha=0.5)
ax.set_ylabel("Flux Density relative to SUB256")
ax.set_ylim(0.92, 1.06)
ax.legend(ncol=3, fontsize=0.7*fontsize)
plt.tight_layout()
fname = f"subtrans_allobs"
if args.png:
fig.savefig(f"Figs/{fname}.png")
elif args.pdf:
fig.savefig(f"Figs/{fname}.pdf")
else:
plt.show()