-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefgain2txt.py
executable file
·45 lines (35 loc) · 1.05 KB
/
defgain2txt.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
#!/usr/bin/env python
from pyrap.tables import table
import argparse
import numpy as np
import cmath
import scipy.io
import sys
def gain2matlab(parmdb):
deftable=table(parmdb+"::DEFAULTVALUES",ack=False)
vals=deftable.col('VALUES')
names=deftable.col('NAME')
gains={}
for i in range(names.nrows()):
if names[i].split(':')[0]=='Gain':
antname=names[i].split(':')[-1]
val=vals[i][0][0]
if names[i].split(':')[-2]=='Real':
if antname in gains:
gains[antname]+=val+0j
else:
gains[antname]=val+0j
elif names[i].split(':')[-2]=='Imag':
if antname in gains:
gains[antname]+=val*1j
else:
gains[antname]=val*1j
for ant in gains:
print ant,
print abs(gains[ant]),
print gains[ant]
if __name__ == '__main__':
parser = argparse.ArgumentParser(description = "Extract default gains from an instrument file")
parser.add_argument("instrumentfile", help="Name of instrument table")
args = parser.parse_args()
gain2matlab(args.instrumentfile)