import pipeline.infrastructure as infrastructure
import pipeline.infrastructure.basetask as basetask
import pipeline.infrastructure.callibrary as callibrary
import pipeline.infrastructure.vdp as vdp
from pipeline.h.heuristics import caltable as caltable_heuristic
from pipeline.infrastructure import casa_tasks
from pipeline.infrastructure import casa_tools
from . import resultobjects
LOG = infrastructure.get_logger(__name__)
[docs]class Swpowcal(basetask.StandardTaskTemplate):
Inputs = SwpowcalInputs
[docs] def prepare(self):
inputs = self.inputs
with casa_tools.MSReader(inputs.vis) as ms:
ms_summary = ms.summary()
startdate = ms_summary['BeginTime']
# Note from the original scripted pipeline:
# Lastly, make switched power table. This is not used in the
# pipeline, but may be used for QA and for flagging, especially at
# S-band for fields near the geostationary satellite belt. Only
# relevant for data taken on 24-Feb-2011 or later.
callist = []
if startdate >= 55616.6:
gencal_args = inputs.to_casa_args()
# CAS-10216
# spw argument in gencal should be spw='', inputs specified and passed to priorcals is for plotting only
gencal_args['spw'] = ''
gencal_job = casa_tasks.gencal(**gencal_args)
self._executor.execute(gencal_job)
calto = callibrary.CalTo(vis=inputs.vis)
calfrom = callibrary.CalFrom(gencal_args['caltable'], caltype='swpow', interp='', calwt=False)
calapp = callibrary.CalApplication(calto, calfrom)
callist.append(calapp)
return resultobjects.SwpowcalResults(pool=callist, spw=inputs.spw)
[docs] def analyse(self, result):
# With no best caltable to find, our task is simply to set the one
# caltable as the best result
# double-check that the caltable was actually generated
on_disk = [ca for ca in result.pool
if ca.exists() or self._executor._dry_run]
result.final[:] = on_disk
missing = [ca for ca in result.pool
if ca not in on_disk and not self._executor._dry_run]
result.error.clear()
result.error.update(missing)
return result