forked from tammojan/facet-calibration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
correctzeroproblem.py
41 lines (32 loc) · 1.07 KB
/
correctzeroproblem.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
import numpy
import pyrap.tables as pt
import sys
msname = str(sys.argv[1])
ref_msname = 'L99083_SB200_uv.dppp.MS'
t = pt.table(msname, readonly=False)
t_ref = pt.table(ref_msname, readonly=True)
time = t.getcol('TIME')
time_ref = t_ref.getcol('TIME')
print len(numpy.unique(time))
print len(numpy.unique(time_ref))
timelist = numpy.unique(time)
count = 0
for timeval in timelist:
print count
t1 = t.query('TIME > ' + str(timeval-1e-1)+'&&'+ 'TIME < ' + str(timeval+1e-1), columns='DATA')
data = t1.getcol('DATA')
print numpy.shape(data)
idx = numpy.where(numpy.abs(data) == 0.0)
if len(idx) != 0:
t1_ref = t_ref.query('TIME > ' + str(timeval-1e-1)+'&&'+ 'TIME < ' + str(timeval+1e-1), columns='DATA')
data_ref= t1_ref.getcol('DATA')
if numpy.shape(data) != numpy.shape(data_ref):
print 'Problem detected with data shape'
sys.exit()
data = numpy.copy(data_ref)
t1.putcol('DATA',data)
t1_ref.close()
t1.close()
count = count+1
t_ref.close()
t.close()