File-format-agnostic loading of astronomical images (pwkit.astimage)

pwkit.astimage – generic loading of (radio) astronomical images

Use open (path, mode) to open an astronomical image, regardless of its file format.

The emphasis of this module is on getting 90%-good-enough semantics and a really, genuinely, uniform interface. This can be tough to achieve.

exception pwkit.astimage.UnsupportedError(fmt, *args)[source]
class pwkit.astimage.AstroImage(path, mode)[source]

An astronomical image.

path
The filesystem path of the image.
mode
Its access mode: ‘r’ for read, ‘rw’ for read/write.
shape
The data shape, like numpy.ndarray.shape.
bmaj
If not None, the restoring beam FWHM major axis in radians.
bmin
If not None, the restoring beam FWHM minor axis in radians.
bpa
If not None, the restoring beam position angle (east from celestial north) in radians.
units
Lower-case string describing image units (e.g., jy/beam, jy/pixel). Not standardized between formats.
pclat
Latitude (usually dec) of the pointing center in radians.
pclon
Longitude (usually RA) of the pointing center in radians.
charfreq
Characteristic observing frequency of the image in GHz.
mjd
Mean MJD of the observations.
axdescs
If not None, list of strings describing the axis types. Not standardized.
size
The number of pixels in the image (=shape.prod ()).

Methods:

close
Close the image.
read
Read all of the data.
write
Rewrite all of the data.
toworld
Convert pixel coordinates to world coordinates.
topixel
Convert world coordinates to pixel coordinates.
simple
Convert to a 2D lat/lon image.
subimage
Extract a sub-cube of the image.
save_copy
Save a copy of the image.
save_as_fits
Save a copy of the image in FITS format.
delete
Delete the on-disk image.
axdescs = None

If not None, list of strings describing the axis types; no standard format.

bmaj = None

If not None, the restoring beam FWHM major axis in radians

bmin = None

If not None, the restoring beam FWHM minor axis in radians

bpa = None

If not None, the restoring beam position angle (east from celestial north) in radians

charfreq = None

Characteristic observing frequency of the image in GHz

mjd = None

Mean MJD of the observations

pclat = None

Latitude of the pointing center in radians

pclon = None

Longitude of the pointing center in radians

shape = None

An integer ndarray of the image shape

subimage(pixofs, shape)[source]

Extract a sub-cube of this image.

Both pixofs and shape should be integer arrays with as many elements as this image has axes. Thinking of this operation as taking a Python slice of an N-dimensional cube, the i’th axis of the sub-image is slices from pixofs[i] to pixofs[i] + shape[i].

units = None

Lower-case string describing image units (e.g., jy/beam, jy/pixel)

class pwkit.astimage.MIRIADImage(path, mode)[source]

A MIRIAD format image. Requires the mirtask module from miriad-python.

class pwkit.astimage.PyrapImage(path, mode)[source]

A CASA-format image loaded with the ‘pyrap’ Python module.

class pwkit.astimage.FITSImage(path, mode)[source]

A FITS format image.

class pwkit.astimage.SimpleImage(parent)[source]

A 2D, latitude/longitude image, referenced to a parent image.