Source
import datetime
import inspect
import os
import shutil
from types import CodeType
from casatasks import casalog
from casatools import quanta
from . import sdutil
"""
The following code is based on the mstransform code, with
task name and some task parameters modified.
To minimise code modification, the parameters used by
mstransform but not by nrobeamaverage are kept as much as
possible, and the default values for mstransform are given
to them.
(CAS-12475, 2019/6/7 WK)
"""
sdtask_decorator .
def nrobeamaverage(
infile,
datacolumn,
field,
spw,
timerange,
scan,
beam,
timebin,
outfile):
try:
# set temporary data name
tmpfile = 'tmp-nrobeamaverage-' + os.path.basename(infile.rstrip('/')) + '-' + \
"{0:%Y%m%d%H%M%S.%f}".format(datetime.datetime.now()) + '.ms'
caller: CodeType = inspect.currentframe().f_code
# data selection
sdutil.do_mst(
infile=infile,
datacolumn=datacolumn,
field=field,
spw=spw,
timerange=timerange,
scan=scan,
antenna='',
timebin='0s',
timespan='scan',
outfile=tmpfile,
intent='',
caller=caller,
ext_config={})
# open tmpfile and rewrite antenna column of the ON spectra using beam
idx_on = None
with sdutil.table_manager(os.path.join(tmpfile, 'STATE')) as tb:
ocol = tb.getcol('OBS_MODE')
for i in range(len(ocol)):
if ocol[i] == 'OBSERVE_TARGET#ON_SOURCE':