forked from hughbg/leda_analysis_2016
-
Notifications
You must be signed in to change notification settings - Fork 0
/
12_skymodel_compare.py
executable file
·90 lines (67 loc) · 2.13 KB
/
12_skymodel_compare.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
83
84
85
86
87
88
89
90
#!/usr/bin/env python
"""
# 12_skymodel_compare.py
Compare calibrated spectra against skymodel
"""
import matplotlib as mpl
import seaborn as sns
import tables as tb
from leda_cal.leda_cal import *
from leda_cal.skymodel import *
from leda_cal.useful import *
from leda_cal.dpflgr import *
sns.set_style('ticks')
sns.set_context("paper",font_scale=1.5)
def quicklook(filename):
h5 = tb.open_file(filename)
T_ant = apply_calibration(h5)
f_leda = T_ant['f']
lst = T_ant['lst']
print T_ant.keys()
ant_ids = ['252A']
print("Plotting...")
fig, ax = plt.subplots(figsize=(8, 6))
mid = closest(lst, 11)
print T_ant['lst'][mid]
sl = 20
T_flagged = rfi_flag(T_ant[ant_ids[0]], freqs=f_leda)
sl = 250
plt.subplot2grid((3, 1), (0, 0), rowspan=2)
plt.plot(f_leda, T_flagged[mid-sl:mid+sl].mean(axis=0), c='#009933')
import hickle as hkl
gsm = hkl.load("cal_data/gsm-spec-lst11.hkl")
plt.plot(gsm["f"], gsm["T_ew"], c='#333333', ls='dashed')
d = T_flagged[mid-sl:mid+sl].mean(axis=0)
f_t, d_t = trim(f_leda, d, 40, 80)
T_ew = np.interp(f_t, gsm["f"], gsm["T_ew"])
scale_offset = np.mean(T_ew / d_t)
print scale_offset
#plt.plot(f_)
plt.xlim(40, 80)
plt.ylim(500, 8000)
plt.minorticks_on()
plt.ylabel("Temperature [K]")
plt.legend(["252A", "GSM"])
plt.subplot2grid((3, 1), (2, 0), rowspan=1)
plt.plot(rebin(f_t, 8), rebin(d_t / T_ew, 8), c='#333333')
plt.plot(rebin(f_t, 8), rebin(scale_offset * d_t / T_ew, 8), c='#333333')
plt.xlabel("Frequency [MHz]")
#plt.yticks([0.85, 0.87, 0.89, 0.91, 0.93])
# plt.ylim(0.85, 0.93)
plt.ylabel("data / model")
plt.tight_layout()
plt.minorticks_on()
plt.savefig("figures/skymodel-compare.pdf")
plt.show()
resid = d_t - T_ew
resid -= fit_poly(f_t, resid, 5)
plt.plot(f_t, resid)
plt.show()
if __name__ == "__main__":
import sys
try:
filename = sys.argv[1]
except:
print "USAGE: ./quicklook.py filename_of_hdf5_observation"
exit()
quicklook(filename)