IntervalCalLibrary

class IntervalCalLibrary(context: Context)[source]

Bases: object

IntervalCalLibrary is the root object for the pipeline calibration state.

This implementation of the CalLibrary is based on the interval tree data structure.

Attributes Summary

active

CalState holding CalApplications to be (pre-)applied to the MS.

applied

CalState holding CalApplications that have been applied to the MS via the pipeline applycal task.

Methods Summary

add(calto, calfroms)

clear()

Clear all active and applied calibrations.

export([filename])

Export the pre-apply calibration state to disk.

export_applied([filename])

Export the applied calibration state to disk.

get_calstate(calto[, ignore])

Get the active calibration state for a target data selection.

import_state([filename, append])

mark_as_applied(calto, calfrom)

unregister_calibrations(predicate_fn)

Delete active calibrations that match the input predicate function.

Attributes Documentation

active

CalState holding CalApplications to be (pre-)applied to the MS.

applied

CalState holding CalApplications that have been applied to the MS via the pipeline applycal task.

Methods Documentation

add(calto, calfroms)[source]
clear() None[source]

Clear all active and applied calibrations.

export(filename: str | None = None) None[source]

Export the pre-apply calibration state to disk.

The pre-apply calibrations held in the 'active' CalState will be written to disk as a set of equivalent applycal calls.

Parameters:

filename -- Name for saved calibration state file.

export_applied(filename: str | None = None) None[source]

Export the applied calibration state to disk.

The calibrations held in the 'applied' CalState will be written to disk as a set of equivalent applycal calls.

Parameters:

filename -- Name for saved calibration state file.

get_calstate(calto, ignore: list | None = None) IntervalCalState[source]

Get the active calibration state for a target data selection.

Parameters:
  • calto -- The data selection to retrieve active calibration state for.

  • ignore -- CalFrom properties to ignore.

Returns:

New IntervalCalState object representing active calibration state for a target data selection.

import_state(filename=None, append=False)[source]
mark_as_applied(calto, calfrom)[source]
unregister_calibrations(predicate_fn: Callable[[CalToArgs, CalFrom], bool]) None[source]

Delete active calibrations that match the input predicate function.

Context

Previously, calibration had to be removed by calling private callibrary functions, e.g.:

calto = callibrary.CalTo(self.inputs.vis)
calfrom = callibrary.CalFrom(gaintable=ktypecaltable, interp='', calwt=False)
context.callibrary._remove(calto, calfrom, context.callibrary._active)

This function makes calibration removal a first-class public function of the callibrary, and requires less knowledge of the calibration to remove.

Example usage

The predicate function passed in by the caller defines which calibrations should be unregistered. For example, Tsys caltable removal can be achieved with the code below:

def match_tsys(calto, calfrom):
    return calfrom.type == 'tsys'
callibrary.unregister_calibrations(match_tsys)

The pipeline inserts the task name into the caltable filename, which can be used to unregister caltables generated by that task. For example:

def match_task_caltable(calto, calfrom):
    return 'hifa_bandpass' in calfrom.gaintable
context.callibrary.unregister_calibrations(match_task_caltable)

If you wanted to match calwt, interp, vis, etc. then that could be done in the matcher function too, but if it's not necessary to identify the caltable then it doesn't need to be tested in the predicate function.