API

Contexts

Contexts are objects supplying information to implementers of Providers.

class InitialisationContext

Initialisation Context object passed to Providers.

It provides initialisation information to a Provider, allowing Providers to perform setup based on configuration.

class CustomSourceProvider(SourceProvider):
    def init(self, init_context):
        config = context.cfg()
        ...
cfg

Configuration

class StartContext

Start Context object passed to Providers.

It provides information to the user implementing a data source about the extents of the data tile that should be provided.

# uvw varies by time and baseline and has 3 coordinate components
cube.register_array("uvw", ("ntime", "nbl", 3), np.float64)

...

class CustomSourceProvider(SourceProvider):
    def start(self, start_context):
        # Query dimensions directly
        (lt, ut), (lb, ub) = context.dim_extents("ntime", "nbl")
        ...

Public methods of a HyperCube are proxied on this object. Other useful information, such as the configuration, iteration space arguments are also present on this object.

cfg

Configuration

class StopContext

Stop Context object passed to Providers.

It provides information to the user implementing a data source about the extents of the data tile that should be provided.

# uvw varies by time and baseline and has 3 coordinate components
cube.register_array("uvw", ("ntime", "nbl", 3), np.float64)

...

class CustomSourceProvider(SourceProvider):
    def stop(self, stop_context):
        # Query dimensions directly
        (lt, ut), (lb, ub) = context.dim_extents("ntime", "nbl")
        ...

Public methods of a HyperCube are proxied on this object. Other useful information, such as the configuration, iteration space arguments are also present on this object.

cfg

Configuration

class SinkContext

Context object passed to data sinks.

Primarily, it exists to provide a tile of output data to the user.

class MySinkProvider(SinkProvider):
    vis_queue = Queue(10)

    ...
    def model_vis(self, context):
        print context.help(display_cube=True)
        # Consume data
        vis_queue.put(context.data)

Public methods of a HyperCube are proxied on this object. Other useful information, such as the configuration, iteration space arguments and the abstract array schema are also present on this object.

array_schema

The array schema of the array associated with this data source. For instance if model_vis is registered on a hypercube as follows:

# Register model_vis array_schema on hypercube
cube.register_array("model_vis",
    ("ntime", "nbl", "nchan", "ncorr"),
    np.complex128)

...
# Create a source context for model_vis data source
context = SourceContext("model_vis", ...)
...
# Obtain the array schema
context.array_schema == ("ntime", "nbl", "nchan", "ncorr")
cfg

Configuration

data

The data tile available for consumption by the associated sink

help(display_cube=False)

Get help associated with this context

Parameters:display_cube (bool) – Add hypercube description to the output
Returns:A help string associated with this context
Return type:str
input

The dictionary of inputs used to produce data. For example, if one wished to find the antenna pair used to produce a particular model visibility, one could do the following:

def model_vis(self, context):
    ant1 = context.input["antenna1"]
    ant2 = context.input["antenna2"]
    model_vis = context.data
iter_args

Iteration arguments that describe the tile sizes over which iteration is performed. In the following example, iteration is occuring in tiles of 100 Timesteps, 64 Channels and 50 Point Sources.

context.iter_args == [("ntime", 100),
        ("nchan", 64), ("npsrc", 50)]
name

The name of the data sink of this context.

Abstract Provider Classes

This is the Abstract Base Class that all Source Providers must inherit from. Alternatively, the SourceProvider class inherits from AbstractSourceProvider and provides some useful concrete implementations.

This is the Abstract Base Class that all Sink Providers must inherit from. Alternatively, the SinkProvider class inherits from AbstractSinkProvider and provides some useful concrete implementations.

class AbstractSinkProvider
clear_cache()

Clears any caches associated with the sink

close()

Perform any required cleanup

init(init_context)

Called when initialising Providers

name()

Returns this data sink’s name

sinks()

Returns a dictionary of sink methods, keyed on sink name

start(start_context)

Called at the start of any solution

stop(stop_context)

Called at the end of any solution

Source Provider Implementations

Sink Provider Implementations

class MSSinkProvider

Sink Provider that receives model visibilities produced by montblanc

__init__(manager, vis_column=None)

Constructs an MSSinkProvider object

Parameters:
  • manager (MeasurementSetManager) – The MeasurementSetManager used to access the Measurement Set.
  • vis_column (str) – Column to which model visibilities will be read
model_vis(context)

model visibility data sink

name()

Returns this data sink’s name