-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_lofasm.py
118 lines (111 loc) · 3.08 KB
/
read_lofasm.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
108
109
110
111
112
113
114
115
116
117
118
from lofasm.bbx import bbx
import re
from bbx_2_scint import BbxReader, Bbx2Scint, BbxStreamReader
from incohr_dedisps import IncoherentDedisperse
from subband import SubBand
import astropy.units as u
import matplotlib.pyplot as plt
from scintillometry.dm import DispersionMeasure
#a = re.compile(r'.*?\((.*?)\)')
#r = a.search("asef (sefes)")
#print(r.group(0))
dm = DispersionMeasure(20)
f = ['20190401_001216_AA.bbx', '20190401_001720_AA.bbx', '20190401_002223_AA.bbx']
#f = Bbx2Scint("20190401_001216_AA.bbx")
bsr = BbxStreamReader(f)
print(bsr.shape)
data = bsr.read(1)
print(data.max(), data.min())
bsr.seek(3)
data = bsr.read(1)
print(data.max(), data.min())
bsr.seek(0)
data = bsr.read(1)
print(data.max(), data.min())
#data = bsr.fh.read(3615)
#print(data.shape)
#print(bsr.fh.size)
#print(bsr._file_offsets)
#print(bsr.file_nr)
#print(bsr.tell())
#print(bsr.seek(3615))
#print(bsr.tell())
#print(bsr.file_nr)
#print(bsr.fh.tell())
#print("File time offset:", bsr.fh.tell(unit='time').mjd)
#print("Stream time offset:", bsr.tell(unit='time').mjd)
#print(bsr.tell(unit=u.s))
#f0 = bsr.opener(f[0], mode='rb')
#f1 = bsr.opener(f[1], mode='rb')
#f2 = bsr.opener(f[2], mode='rb')
#print("F0 START:", f0.start_time.mjd)
#print("F0 STOP:", f0.stop_time.mjd)
#print("F1 START:", f1.start_time.mjd)
#bsr.seek(0)
#dd = bsr.read(3700)
#print(bsr.tell())
#print(dd.shape)
#br = BbxReader(f[0])
#print(br.stop_time.mjd)
#bsr.seek(br.shape[0])
#print(bsr.tell(unit='time').mjd)
#bsr.seek(br.shape[0]+1)
#print(bsr.tell(unit='time').mjd)
#print(BbxReader(f[1]).start_time.mjd)
#print(f.shape)
#print(f.start_time.isot)
#print(f.frequency)
#print(f.sample_rate)
#print(1/f.sample_rate)
#br = BbxReader(f)
#print(br.shape)
#print(br.tell())
sb = SubBand(bsr, 1, 20 * u.MHz, 50 * u.MHz)
#print((bsr.frequency.max() - bsr.frequency.min()) / (len(bsr.frequency)-1))
#print((sb.frequency.max() - sb.frequency.min()) / (len(sb.frequency)-1))
#print(sb.frequency.max(), sb.frequency[-1])
#print(sb.frequency.min(), sb.frequency[0])
#print(sb.frequency[2] - sb.frequency[1])
#print(len(sb.frequency))
#time_d = dm.time_delay(sb.frequency, sb.frequency[-1])
#print(sb.sample_rate)
#print((time_d * sb.sample_rate).decompose())
#sbd = sb.read(4000)
#print(sbd.shape)
#print(sb.frequency)
#print(sbd.shape)
#print(sb.samples_per_frame)
id = IncoherentDedisperse(sb, 20)
print("pad start", id.pad_start)
print("pad end", id.pad_end)
#print("samples_pre_frame", id.samples_per_frame)
#id.seek(3614)
data = id.read(1)
#data2 = id.read(1)
#print("Frame number", data.shape)
print(id.delay_high_index)
print(id.delay_low_index)
#isb
#print(dir(id))
#print(id._pad_slice)
#print(id.start_time)
#print(id._sample_offset)
#print(id.shape)
#print(bsr.shape)
#print(id._padded_samples_per_frame)
#id.seek(1)
#data = id.read(1)
#print("offset", id.offset)
#date = id.read(1)
#for i in range(3):
# print(id.ih.tell())
# data = id.read(1)
# print(data.shape)
#print(data.shape)
#print(id.delay_low_index)
#print(id.delay_high_index)
#print(id.samples_per_frame)
#print(sb.samples_per_frame)
#print(br.tell())
#print(br.tell(unit='time'))
#print(br.frequency)