-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathoverview_plots.py
107 lines (92 loc) · 2.78 KB
/
overview_plots.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
import numpy as n
import glob
import matplotlib.pyplot as plt
import h5py
import time
import reanalyze_ionogram as rean
import stuffr
import iono_config
def overview_plots(t0, t1, max_r=500, gc=20):
fl=glob.glob("results/*/ionogram*.h5")
fl.sort()
t=[]
v1f=[]
dtt=[]
for f in fl:
try:
with h5py.File(f, "r") as h:
if "ionogram_version" in h.keys() and h["ionogram_version"].value == 1:
if (h["t0"].value > t0) and (h["t0"].value < t1):
# print("t0 %d t1 %d t %d"%(t0,t1,h["t0"].value))
# print(h["t0"].value)
t.append(n.copy(h["t0"].value))
v1f.append(f)
except Exception as e:
print("bad file %s" % (f))
# print(len(v1f))
if len(v1f)== 0:
print("no data")
return
with h5py.File(v1f[0], "r") as h:
n_f=len(h["I_fvec"].value)
freq=n.copy(h["I_fvec"].value)
n_t=len(v1f)
n_r=max_r
OR=n.zeros([n_t, n_r])
OF=n.zeros([n_t, n_f])
t=n.array(t)
idx=n.argsort(t)
rvec=n.arange(n_r)*1.5
for fi, f in enumerate(idx):
f=v1f[idx[fi]]
print(f)
with h5py.File(f, "r") as h:
I=n.copy(h["I"].value)
dtt.append(stuffr.unix2date(t[idx[fi]]))
for freq_i in range(I.shape[0]):
I[freq_i, :]=I[freq_i, :]/n.median(n.abs(I[freq_i, :]))
# plt.pcolormesh(I)
# plt.colorbar()
# plt.show()
# plt.pcolormesh(I)
# plt.show()
# print(I.shape)
OR[fi, :]=n.max(I[:, 0:max_r], axis=0)
OF[fi, :]=n.max(I[:, gc:max_r], axis=1)
dBOR=10.0*n.log10(OR)
dBOF=10.0*n.log10(OF)
dBOF[n.isinf(dBOF)]=n.nan
dBOR=dBOR-n.nanmedian(dBOR)
dBOF=dBOF-n.nanmedian(dBOF)
dBOF[n.isnan(dBOF)]=-3
t=n.array(t)
plt.figure(figsize=(1.5*8, 1.5*6))
# 30 km range shift
plt.pcolormesh(dtt, rvec-iono_config.range_shift*1.5, n.transpose(dBOR), vmin=0, vmax=10)
plt.colorbar()
plt.xlabel("Time (UTC)")
plt.ylabel("Virtual range (km)")
plt.tight_layout()
print("saving overview_rt.png")
plt.savefig("overview_rt.png")
plt.close()
plt.clf()
# plt.show()
plt.figure(figsize=(1.5*8, 1.5*6))
plt.pcolormesh(dtt, 0.5*(freq[:, 0]+freq[:, 1]), n.transpose(dBOF), vmin=0, vmax=10)
plt.colorbar()
plt.xlabel("Time (UTC)")
plt.ylabel("Frequency (MHz)")
plt.tight_layout()
print("saving overview_ft.png")
plt.savefig("overview_ft.png")
plt.close()
plt.clf()
# plt.show()
if __name__ == "__main__":
#stuffr.date2unix(2020,5,25,0,0,0)
#stuffr.date2unix(2020,5,27,0,0,0)
tnow=time.time()
overview_plots(t0=tnow-48*3600,
t1=tnow)