Source
xxxxxxxxxx
import inspect
from types import CodeType
import numpy
from casatasks import casalog
from casatools import quanta
from . import sdutil
qa = quanta()
sdtask_decorator .
def sdtimeaverage(
infile,
datacolumn,
field,
spw,
timerange,
scan,
antenna,
timebin,
timespan,
outfile):
# When 'all'(default) or '' is specified, make timebin to cover all the data.
if timebin.upper() in ['ALL', '']:
timebin = set_timebin_all() + 's'
# Switch Alternative Column if needed.
active_datacolumn = use_alternative_column(infile, datacolumn)
# Antenna ID (add extra &&& if needed) This is Single Dish specific.
if (len(antenna) != 0) and (not('&' in antenna)):
antenna = antenna + '&&&'
# 'scan,state' Warning
# (unexpected result warning)
if ('scan' in timespan) and ('state' in timespan):
# WARN msg, to explain NRO specific issue.
msg = '\n'.join(
["Explicitly both 'scan' and 'state' were specified in 'timespan'.",
" If 'state' distinguishes OBSERVE_TARGET#ON_SOURCE / OBSERVE_TARGET#OFF_SOURCE,",
" these two states are mixed, and unexpectedly averaged results might be generated.",
"(Suggestion) Please specify timespan = 'scan'",
" to separate OBSERVE_TARGET#ON_SOURCE and OBSERVE_TARGET#OFF_SOURCE."])
casalog.post(msg, 'WARN')
# (Note) When timespan='' is specified.
# timespan will be directly posted to mstransform.
# Convert to check timebin
tbin = qa.convert(qa.quantity(timebin), 's')['value']
# Time average, once Enable.
do_timeaverage = True
# Check timebin
if tbin < 0: # Error, raise Exception.
raise ValueError(
"Parameter timebin must be >= '0s' to do time averaging")
elif tbin == 0: # No averaging, when tbin == 0
msg = 'Parameter timebin equals zero. No averaging will be performed.'