-
Notifications
You must be signed in to change notification settings - Fork 1
/
clocktec-prep.py
executable file
·58 lines (42 loc) · 1.22 KB
/
clocktec-prep.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
#!/usr/bin/python
# clock-tec preparation: collate the data and assemble the file of solutions
import sys
import config
import os.path
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')
cfg=config.LocalConfigParser()
cfg.read(filename)
croot=cfg.get('files','calibrator')
processedpath=cfg.get('paths','processed')
os.chdir(processedpath)
run=config.runner(cfg.getoption('control','dryrun',False)).run
report('Making the globaldb')
if os.path.isdir('globaldb'):
run('rm -r globaldb')
run('mkdir globaldb')
os.chdir('globaldb')
sb=0
while sb<366:
sbs='%03i' % sb
dir='../'+croot+'_SB'+sbs+'_uv.filter.MS'
if os.path.isdir(dir):
break
sb+=1
else:
die("Can't find any calibrator files!")
for table in ['ANTENNA','FIELD','sky','OBSERVATION']:
run('cp -r '+dir+'/'+table+' .')
for i in range(366):
sbn='%03i' % i
msname='../'+croot+'_SB'+sbn+'_uv.filter.MS/instrument'
os.system('ln -s '+msname+' instrument-'+sbn)
report('Importing to hdf5')
os.chdir('..')
run('/home/mjh/git/losoto/tools/H5parm_importer.py -v cal.h5 globaldb')