-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapply-clocktec.py
executable file
·48 lines (35 loc) · 1.22 KB
/
apply-clocktec.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
#!/usr/bin/python
# Apply the clock-TEC separation from Reinout's method
# This is instead of gain transfer on a per-subband basis as in calib.py
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 sub-band number')
band=int(sys.argv[2])
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
sbs='%03i' % band
ms=troot+'_SB'+sbs+'_uv.filter.MS'
if not(os.path.isdir(ms)):
die('MS does not exist')
globaldbname = 'cal.h5' # input h5 parm file
t = pt.table('globaldb/OBSERVATION', readonly=True, ack=False)
calsource=t[0]['LOFAR_TARGET'][0]
report('Generating clock-tec parmdb')
run('python /home/mjh/lofar/surveys-pipeline/transfer_amplitudes+clock+offset.py '+ms+' '+ms+'/instrument . '+calsource)
report('Applying clock-tec/gain')
run('calibrate-stand-alone '+ms+' /home/mjh/lofar/text/apply-calibration-nb.txt')