tkp.accessors API reference

tkp.accessors – Base data accessor utilities

Data accessors.

These can be used to populate ImageData objects based on some data source (FITS file, array in memory... etc).

tkp.accessors.dbimage_from_accessor(dataset, dataccessor, extraction_radius)[source]

Create an entry in the database image table from an image ‘accessor’

Parameters:
  • dataset (-) – DataSet for the image. Also provides the database connection.
  • image (-) – FITS/AIPS/HDF5 image available through an accessor
Returns:

a dataset.Image instance.

Return type:

(dataset.Image)

tkp.accessors.open(path, *args, **kwargs)[source]

Returns an accessor object (if available) for the file or directory ‘path’.

We try all the possible accessors in order from most specific to least specific. That is, if possible, we prefer an accessor providing LofarAccessor to one providing DataAccessor, but we accept the latter if that’s the only possible match.

Will raise an exception if something went wrong or no matching accessor class is found.

tkp.accessors.sourcefinder_image_from_accessor(image, **args)[source]

Create a source finder ImageData object from an image ‘accessor’

Parameters:image (-) – FITS/AIPS/HDF5 image available through an accessor.
Returns:a source finder image.
Return type:(sourcefinder.ImageData)
tkp.accessors.writefits(data, filename, header={})[source]

Dump a NumPy array to a FITS file.

Key/value pairs for the FITS header can be supplied in the optional header argument as a dictionary.

tkp.accessors.common – Common accessor parsing functions

Parsing functions used by multiple DataAccessor sub-classes

tkp.accessors.common.arcsec2degrees(bmaj, bmin, bpa)[source]

Converts beam parameters from arcsec to degrees. For example CASAtable beam parameters are in arcsec.

Parameters:
  • bmaj (-) – Beam semi-major axis in arcsec
  • bmin (-) – Beam semi-minor axis in arcsec
  • bpa (-) – Beam position angle in arbitrary units
Returns:

  • tuple of (semi-major in degrees, semi-minor in degrees, bpa as above)

tkp.accessors.common.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.

Parameters:
  • bmaj (-) – Beam semi-major axis in degrees
  • bmin (-) – Beam semi-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
Returns:

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

Return type:

  • semimaj

tkp.accessors.common.parse_pixelsize(wcs)[source]
Parameters:wcs (-) – A tkp.coordinates.wcs.WCS object
Returns:pixel size along the x axis in degrees - deltay: pixel size along the x axis in degrees
Return type:
  • deltax
tkp.accessors.common.unique_column_values(table, column_name)[source]

Find all the unique values in a particular column of a CASA table.

Parameters:
  • table (-) – pyrap.tables.table
  • column_name (-) – str
Returns:

  • numpy.ndarray containing unique values in column.

tkp.accessors.detection – File type detection

class tkp.accessors.detection.FitsTest(accessor, test)
__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

__repr__()

Return a nicely formatted representation string

accessor

Alias for field number 0

test

Alias for field number 1

tkp.accessors.detection.casa_detect(filename)[source]

Detect which telescope produced CASA data, return corresponding accessor.

Checks for known CASA table types where we expect additional metadata. If the telescope is unknown we return nothing.

tkp.accessors.detection.detect(filename)[source]

returns the accessor class that should be used to process filename

tkp.accessors.detection.fits_detect(filename)[source]

Detect which telescope produced FITS data, return corresponding accessor.

Checks for known FITS image types where we expect additional metadata. If the telescope is unknown we default to a regular FitsImage.

tkp.accessors.detection.iscasa(filename)[source]

returns True if filename is a lofar casa directory

tkp.accessors.detection.isfits(filename)[source]

returns True if filename is a fits file

tkp.accessors.detection.islofarhdf5(filename)[source]

returns True if filename is a hdf5 container