-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakeband.py
executable file
·64 lines (53 loc) · 1.47 KB
/
makeband.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
#!/usr/bin/python
import sys
import config
import os.path
import pyrap.tables as pt
die=config.die
report=config.report
warn=config.warn
if len(sys.argv)<2:
die('Need a filename for config file')
filename=sys.argv[1]
if not(os.path.isfile(filename)):
die('Config file does not exist')
if len(sys.argv)<3:
die('Need a band number')
bb=int(sys.argv[2])
if len(sys.argv)==4:
be=int(sys.argv[3])
else:
be=bb
cfg=config.LocalConfigParser()
cfg.read(filename)
troot=cfg.get('files','target')
processedpath=cfg.get('paths','processed')
os.chdir(processedpath)
run=config.runner(cfg.getoption('control','dryrun',False)).run
try:
bad_sblist=eval(cfg.get('calibration','badsblist'))
except:
bad_sblist=[]
# Now make the bands in the specified range
for band in range(bb,be+1):
print 'Band',band
bs='%02i' % band
sbst=band*10
sbend=sbst+10
if sbend>366:
sbend=366
flist=''
for sb in range(sbst,sbend):
sbs='%03i' % sb
infile=troot+'_SB'+sbs+'_uv.filter.MS'
if os.path.isdir(infile) and sb not in bad_sblist:
flist+='"'+infile+'",'
else:
flist+='"",'
report('Concatenating band')
outfile=troot+'_B'+bs+'_concat.MS'
filename='NDPPP-concat-'+bs+'.in'
file=open(filename,'w')
file.write('msin=['+flist[:-1]+']\nmsin.datacolumn = CORRECTED_DATA\nmsout = '+outfile+'\nsteps = []\nmsin.orderms = False\nmsin.missingdata = True\n')
file.close()
run('NDPPP '+filename)