Data Accessor Variants

Basic data accessors

class tkp.accessors.dataaccessor.DataAccessor[source]

Base class for accessors used with tkp.sourcefinder.image.ImageData.

Data accessors provide a uniform way for the ImageData class (ie, generic image representation) to access the various ways in which images may be stored (FITS files, arrays in memory, potentially HDF5, etc).

This class cannot be instantiated directly, but should be subclassed and the abstract properties provided. Note that all abstract properties are required to provide a valid accessor.

Additional properties may also be provided by subclasses. However, TraP components are required to degrade gracefully in the absence of this optional properties.

The required attributes are as follows:


tuple – Restoring beam. Tuple of three floats: semi-major axis (in pixels), semi-minor axis (pixels) and position angle (radians).


float – Right ascension at the central pixel of the image. Units of J2000 decimal degrees.


float – Declination at the central pixel of the image. Units of J2000 decimal degrees.


numpy.ndarray – Two dimensional numpy.ndarray of floating point pixel values. (TODO: Definitive statement on orientation/transposing.)


float – The frequency bandwidth of this image in Hz.


float – Effective frequency of the image in Hz. That is, the mean frequency of all the visibility data which comprises this image.


tuple – (x, y) tuple representing the size of a pixel along each axis in units of degrees.


float – Total time on sky in seconds.


float – Timestamp of the first integration which constitutes part of this image. MJD in seconds.


string – A (string) URL representing the location of the image at time of processing.


tkp.utility.coordinates.WCS – An instance of tkp.utility.coordinates.WCS, describing the mapping from data pixels to sky-coordinates.

The class also provides some common functionality: static methods used for parsing datafiles, and an ‘extract_metadata’ function which provides key info in a simple dict format.

static degrees2pixels(bmaj, bmin, bpa, deltax, deltay)[source]

Convert beam in degrees to beam in pixels and radians. For example Fits beam parameters are in degrees.

  • bmaj (-) – Beam major axis in degrees
  • bmin (-) – Beam minor axis in degrees
  • bpa (-) – Beam position angle in degrees
  • deltax (-) – Pixel size along the x axis in degrees
  • deltay (-) – Pixel size along the y axis in degrees

Beam semi-major axis in pixels - semimin: Beam semi-minor axis in pixels - theta: Beam position angle in radians

Return type:

  • semimaj


Massage the class attributes into a flat dictionary with database-friendly values.

While rather tedious, this is easy to serialize and store separately to the actual image data.

May be extended by subclasses to return additional data.

Returns:pixel size along the x axis in degrees - deltay: pixel size along the x axis in degrees
Return type:
  • deltax

The following acessors are derived from the basic DataAccessor class:

class tkp.accessors.fitsimage.FitsImage

Generic FITS data access.

class tkp.accessors.casaimage.CasaImage

Generic CASA image access.

class tkp.accessors.kat7casaimage.Kat7CasaImage

KAT-7 specific CASA image access.

LOFAR-specific data accessors

class tkp.accessors.lofaraccessor.LofarAccessor[source]

The following accessors are derived from the generic LofarAccessor:

class tkp.accessors.lofarfitsimage.LofarFitsImage

LOFAR FITS access.

class tkp.accessors.lofarcasaimage.LofarCasaImage

LOFAR CASA image access.