Source
140
140
'NAME': 'StandardStMan',
141
141
'SEQNR': 0,
142
142
'SPEC': {'BUCKETSIZE': 1920,
143
143
'IndexLength': 142,
144
144
'MaxCacheSize': 2,
145
145
'PERSCACHESIZE': 2},
146
146
'TYPE': 'StandardStMan'}}
147
147
148
148
#################################################################################################
149
149
# Main task
150
-
def appendantab(vis=None, outvis=None, antab=None, overwrite=False):
150
+
def appendantab(vis=None, outvis=None, antab=None,
151
+
overwrite=False, append_tsys=True, append_gc=True):
151
152
152
153
# get info from vis
153
154
msmd.open(vis)
154
155
ant_names = msmd.antennastations()
155
156
n_band = len(msmd.bandwidths())
156
157
spws = msmd.spwfordatadesc()
157
158
158
159
# is gc_begin even needed?
159
160
gc_begin = msmd.timerangeforobs(0)['begin']['m0']['value'] * 86400
160
161
gc_end = msmd.timerangeforobs(0)['end']['m0']['value'] * 86400
461
462
tm_hour = int(ts.split(':')[0])
462
463
tm_min = int(ts.split(':')[1])
463
464
tm_sec = int(ts.split(':')[2])
464
465
elif re.match(r"[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+", ts):
465
466
# hh:mm:ss.ss
466
467
tm_hour = int(ts.split(':')[0])
467
468
tm_min = int(ts.split(':')[1])
468
469
tm_sec = float(ts.split(':')[2])
469
470
return tm_hour, tm_min, tm_sec
470
471
471
-
def process(infp, keys, pols, data, n_band, spws, first_time, last_time, ant_names):
472
+
def process_tsys(infp, keys, pols, data, n_band, spws, first_time, last_time, ant_names):
472
473
# Get the antenna name
473
474
antenna_name = find_antenna(keys[0], ['SRC/SYS'])
474
475
# Skip if no antenna name found
475
476
if not antenna_name:
476
477
print('ANTENNA missing from TSYS group')
477
478
skip_values(infp)
478
479
return
479
480
try:
480
481
antenna = get_antenna_index(antenna_name, ant_names)
481
482
except:
629
630
if line.startswith('!'):
630
631
continue
631
632
keys.write(line)
632
633
if line.strip().endswith('/'):
633
634
keys.seek(0)
634
635
try:
635
636
tsys = read_keyfile(keys)
636
637
except RuntimeError:
637
638
pass
638
639
if tsys and tsys[0] and tsys[0][0][0] == 'TSYS':
639
-
process(fp, tsys, pols, data, n_band, spws, first_time, last_time, ant_names)
640
+
process_tsys(fp, tsys, pols, data, n_band, spws, first_time, last_time, ant_names)
640
641
pass
641
642
elif tsys and tsys[0] and tsys[0][0][0] == 'GAIN':
642
643
process_gc(fp, tsys, pols, data_gc, ant_names)
643
644
keys = StringIO()
644
645
continue
645
646
continue
646
647
647
-
# Create the subtable for syscal
648
-
create_syscal_subtable(data, outvis, spws)
649
-
create_gaincurve_subtable(data_gc, outvis, spws, gc_interval, gc_time)
648
+
# Create the subtable for syscal if selected in params
649
+
if append_tsys: create_syscal_subtable(data, outvis, spws)
650
+
if append_gc: create_gaincurve_subtable(data_gc, outvis, spws, gc_interval, gc_time)
650
651
651
652
def create_gaincurve_subtable(data, outvis, spws, gc_interval, gc_time):
652
653
# Create the subtable for gain curve
653
654
tb.create(f'{outvis}/GAIN_CURVE', desc_gc, dminfo=dminfo_gc)
654
655
tb.putkeyword('GAIN_CURVE', f'Table: {outvis}/GAIN_CURVE')
655
656
656
657
# assemble columns
657
658
ANTENNA_ID = []
658
659
FEED_ID = []
659
660
SPECTRAL_WINDOW_ID = []