Source code for pipeline.hifv.tasks.selfcal.display

import os

import pipeline.infrastructure as infrastructure
import pipeline.infrastructure.renderer.logger as logger
import pipeline.infrastructure.casa_tasks as casa_tasks

LOG = infrastructure.get_logger(__name__)


[docs]class selfcalphaseGainPerAntennaChart(object): def __init__(self, context, result): self.context = context self.result = result self.ms = context.observing_run.get_ms(result.inputs['vis']) self.basevis = os.path.basename(result.inputs['vis']) self.json = {} self.json_filename = os.path.join(context.report_dir, 'stage%s' % result.stage_number, 'selfcalphasegain-%s.json' % self.ms)
[docs] def plot(self): context = self.context result = self.result m = context.observing_run.measurement_sets[0] nplots = len(m.antennas) plots = [] LOG.info("Plotting phase vs. time after running hifv_selfcal") for ii in range(nplots): filename = 'selfcalgainphase' + str(ii) + '.png' antPlot = str(ii) stage = 'stage%s' % result.stage_number stage_dir = os.path.join(context.report_dir, stage) # construct the relative filename, eg. 'stageX/testdelay0.png' figfile = os.path.join(stage_dir, filename) if not os.path.exists(figfile): try: # Get antenna name antName = antPlot if antPlot != '': domain_antennas = self.ms.get_antenna(antPlot) idents = [a.name if a.name else a.id for a in domain_antennas] antName = ','.join(idents) LOG.debug("Plotting phase vs. time... {!s}".format(antName)) job = casa_tasks.plotms(vis=result.caltable, xaxis='time', yaxis='phase', field='', antenna=antPlot, spw='', timerange='', coloraxis='', plotrange=[0, 0, -180, 180], symbolshape='circle', title='G table: {!s} Antenna: {!s}'.format(result.caltable, antName), titlefont=8, xaxisfont=7, yaxisfont=7, showgui=False, plotfile=figfile, xconnector='line') job.execute(dry_run=False) except Exception as ex: LOG.warn("Unable to plot " + filename + str(ex)) else: LOG.debug('Using existing ' + filename + ' plot.') try: plot = logger.Plot(figfile, x_axis='Time', y_axis='Phase', field='', parameters={'spw': '', 'pol': '', 'ant': antName, 'type': 'selfcalphasegain', 'file': os.path.basename(figfile)}) plots.append(plot) except Exception as ex: LOG.warn("Unable to add plot to stack. " + str(ex)) plots.append(None) return [p for p in plots if p is not None]