-
Notifications
You must be signed in to change notification settings - Fork 10
/
split_ms_by_time.py
executable file
·65 lines (47 loc) · 2.11 KB
/
split_ms_by_time.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
#!/usr/bin/python
import pyrap.tables as pt
# on the offline cluster if you are in c ot tcsh type:
# use Casa; use Pythonlibs; use LofIm; use Casacore
# Run this program as python split_ms_by_time.py
# or Run it as ./split_ms_by_time.py if the script is executable
# Pandey:v0.0:May2010 contact: [email protected]
####### START USER ENTRY #########
# Enter the correct input and output table names below
tablename = 'L215949_SB030_uv.dppp.MS-untouched'
outputname = 'L215949_SB030_uv_1h.dppp.MS-untouched'
# Please Enter the start and end times in hours for the output measrement set
# relative to the start of input measurement set
# for example start = 1.0 means output measurement set will start, 1 hour from
# the start of input MS
# end = 3.0 will mean that output MS will stop 3 hours from the start of
# INPUT MS
# So output MS will have 2 hours of data in such a case
start_out = 4.0
end_out = 5.0
####### END USER ENTRY #########
print('###############################################')
t = pt.table(tablename)
starttime = t[0]['TIME']
endtime = t[t.nrows()-1]['TIME']
print('=====================')
print('Input Measurement Set is '+tablename)
print('Start time (sec) = '+str(starttime))
print('End time (sec) = '+str(endtime))
print('Total time duration (hrs) = '+str((endtime-starttime)/3600))
print('=====================')
print('Output Measurement Set is '+outputname)
print('Start time (relative to input ms start) = '+str(start_out))
print('End time (relative to input ms start) = '+str(end_out))
print('Total time duration (hrs) = '+str(end_out-start_out))
print('=====================')
print('Now going to do the Querry to select the required time range')
t1 = t.query('TIME > ' + str(starttime+start_out*3600) + ' && \
TIME < ' + str(starttime+end_out*3600), sortlist='TIME,ANTENNA1,ANTENNA2')
print('Total rows in Input MS = '+str(t.nrows()))
print('Total rows in Output MS = '+str(t1.nrows()))
print('Now Writing the output MS')
t1.copy(outputname, True)
t1.close()
t.close()
print('Copying Completed... Thanks for using the script ')
print('###############################################')