Software Implementation

Modules, Class Hierarchy, Functional Flow through Python and C++.

--CASA Developer--

 

C++ Functional Blocks

 

 

 

2.1 ImageStore

A container class for all Image objects passed around between modules.

  1. PSF,sumwt, residual, model, image, pb, weight.
  2. Reference sub imagestores on ra/dec for facets and on chans/pols for operations per channel or stokes plane or groups of them.
  3. Holds a coordinate system that all the images use.
  4. Can generate itself (with validation checks and error reporting) from a collection of images with the correct naming conventions on disk.
  5. Images are created (and memory allocated) only on demand.
  6. Common numerical operations such as normalizations and divisions are implemented here.
  7. Operations such as restoration of the model image are done here.

In the code
The SIImageStore lass and its derivative SIImageStoreMultiTerm implement these containers for standard imaging and multi-term imaging. The Multi-term ImageStore holds lists of image references and all operations loop over terms, with all normalizations using only the zeroth term's normalizing factors.

 

2.2 Imager

The Imager module implements the major cycle. It manages iterations through the data using the Visibility Iterator classes, and works with a list of ImageStore/FTMachine pairs to grid/degrid data from each visbuffer.

2.2.1 Gridders(FTMachines)

The FTMachine classes implement the gridding and degridding. They are initialized with ImageInterface objects to use for the input, output and intermediate grids, and are supplied one Visbuffer at a time to do the gridding/degridding of the current section of data. Each FTMachine applies to one image region (in ra/dec) and can have multiple channel and stokes planes.

2.2.2 Mappers/MapperCollections

A Mapper is a container class that connects one ImageStore to a pair of FTMachines (one for the forward and one for the reverse transform). It sets up the FTMachines with the appropriate input/output images from the ImageStore.

A MapperCollection contains a list of Mappers, one for each image field being imaged. Each VisBuffer is sent to all Mappers one after another. Multi-field (outlier field) and facetted imaging is implemented this way.

In the code:
The SIMapper class implements the basic Mapper. The SIMapperImageMosaic class implements a Mapper that includes image domain applications of Primary beams to form a weighted average of images per pointing, as they are gridded and FT'd. The main operational difference from SIMapper is that for each visbuffer it has to check whether a pointing has changed. If so, it updates primary beam models, does an iFT and applies the PB correction.

 

2.3 Normalizer

2.3.1 Gather/Scatter

2.4 Deconvolver

2.5 Iteration/Interaction controller

2.5.1 Interactive GUI

2.6 Other features

2.6.1 Error handling and exceptions

2.6.2 Parameter handling and verification

 These slides from 2013 CASA Developer Meeting contain an outline of the required use cases, the modules being built in the refactored Imager classes and how they connect together for serial and parallel runs.

 

3.2.1 C++ Classes

 

  1. Image Sets : ImageStore is a C++ class that holds the residual, model, psf, restored, mask, weight(pb) images for one field. This is the image unit that is constructed and passed around between other classes that operate on it. For now, all transfers of images between modules (and across compute nodes for a parallel run) is done via disk, with each module constructing its own reference to the set of images on disk.

     

  2. Major cycle : SynthesisImager is the C++ interface layer that controls data selection from one or more MeasurementSets, and the definition and creation of images. It maintains one or more mappings of gridding methods to images (single/multi-field). Gridding methods are implemented with FTMachines. SIMapper is a wrapper that maps one or more FTMachines to one SIImageStore, and SIMapperCollection is a list of such mappers used for multiple fields. The SynthesisImager contains one or more MeasurementSets, MSSelections, and one VisibilityIterator for data access, and passes only VisBuffers to the Mappers.

     

  3. Minor Cycle : SynthesisDeconvolver is the C++ interface layer that controls deconvolution algorithm definition and execution, for one field. The SDAlgorithmBase class implements loops through channels and stokes planes, calls virtual methods for actual iteration steps, and checks a common iteration controller (SIMinorCycleController) for stopping criteria. Derived SDAlgorithmXXX classes implement the numerical deconvolution algorithms, and through their base class, get identical iteration and channel/stokes plane controls.

     

  4. Iteration control : SIIterBot is the C++ interface layer to iteration and interaction control. Thresholds, iteration counts and major-cycle triggers are implemented here in one place, for all minor cycle algorithms to use. The SynthesisDeconvolver takes in a subset of the SIIterbot, the SIMinorCycleController, and reads and updates its iteration control and imaging summary parameters. The SIIterBot is synchronized at major/minor cycle boundaries and all deconvolvers see synchronized parameters.

     

  5. Normalizations : SynthesisParSync is the C++ interface layer to a class that handles pre-deconvolution and pre-degridding normalizations of images by weight images. In the simplest case, this is simply a division by sum of weights before deconvolution. For wide-field imaging, it controls flat-sky vs flat-noise normalizations in both directions. For parallel runs, it allows for a gather step before normalization.

     

  6. Tool interfaces : One-to-one mappings were provided between the C++ interface layers and python, with no extra functionality implemented at the cmpt level. The tools created are synthesisimager, synthesisdeconvolver, synthesisparsync, synthesisimstore and synthesisiterbot.

     

  7. Error Handling and Exception messages : Exception try/catch clauses at all major levels, with messages pre-pended to the exception message at each level to help identify sources of exceptions in the future.

     

Descriptions to be added when implemented : Mask handling, Runtime Interaction.

 

3.2.2 Python Classes

The SynthesisImager contains a SIMapperCollection to map one set of data to multiple image fields. The SynthesisDeconvolver operates on one field. The connection between the two is maintained one level above these classes, currently in Python through the individual tool interfaces. Note however, that all python functionality can be duplicated within C++ if later desired. The current choice of Python was driven by the requirement that all parallelization be done via python.

 

  1. Wrapper Class : PySynthesisImager is a base class that strings together all relevant tools to implement broad functions such as initializeImagers/Deconvolvers/ParallelSync/terationControl, makePSF, runMajorCycle, runMinorCycle, runMajorMinorLoops, getSummary, and deleteTools. This class can hold one synthesisimager, and one or more synthesisdeconvolvers (for multi-field imaging) and synchronizes their iteration parameters via a common synthesisiterbot. By choosing the appropriate function calls, major cycles, psf generation, and minor cycles can be triggered in isolation.

     

  2. Parameter Handling : ImagerParameters is a class that does parameter verification and type-checking for each functional block (data selection, image definition, gridding option, deconvolution options, iteration options) before passing it into C++. All allowed and forbidden combinations (as functionality is internally added) are controlled here. Several old and new field-specific imaging and deconvolution parameters can be specified in an input outlier file.

     

 

3.2.3 Parallelization

All parallelization is currently done at the python level. The basic wrapper modules have been adapted to run parallel major or minor cycles or both.

  1. Cluster management : PyParallelImagerHelper is a class that manages a compute cluster (via simple_cluster) and provides interfaces to start it up, send commands to casapy shells on remote nodes, check for job completion, and shut it down. It also implements very basic heuristics for data and image partitioning.

  2. Parallel major cycles : PyParallelConSynthesisImager is a derivative of PySynthesisImager which parallelizes the major cycle. Instead of holding a single synthesisimager tool, it creates multiple synthesisimager tools, one on each available node. Calls to the tool methods are sent via PyParallelImagerHelper.

  3. Parallel minor cycles : PyParallelDeconvolver is a derivative of PySynthesisImager which parallelizes the minor cycle on image fields. Instead of holding one or more synthesisdeconvolvers, it creates one tool on each available node. This is a simplified form of parallelization that may not be very useful.

  4. Cube parallelization : PyParallelCubeSynthesisImager is a class that uses PyParallelImagerHelper to deploy multiple instances of PySynthesisImager, one on each available node. This does independent imaging and deconvolution on each frequency chunk, with no interaction between the chunks for iteration control. There is currently no concatenation of the image cube at the end.

    An alternate approach to parallel cube imaging can be implemented as a combination of PyParallelContSynthesisImager and PyParallelDeconvolver, where the major and minor cycles are separately parallelized and iteration control is synchronized across the frequency chunks via a common synthesisiterbot.

Continuum and Cube Parallelization

ID softwareimplementation-an-parallelization

 

 some diagrams to use - if needed....

They show the functional blocks as implemented, and how the ImageStore (currently on disk) is the thing that carries data between modules.

IS : ImageStore

FT : FTMachine/gridders

IC : Iteration Controller

DA : Deconvolution algorithm.

 

Single process imaging :

 

Continuum Parallelization

 

 

Cube Parallelization - current

 

 

Cube Parallelization (Future, when sync'd with channel chunking - it will get sync'd iteration control across all chunks)