FITSImage

class snappl.image.FITSImage(*args, noisepath=None, flagspath=None, imagehdu=0, noisehdu=0, flagshdu=0, header=None, wcs=None, std_imagenames=False, **kwargs)[source]

Bases: Numpy2DImage

Base class for classes that read FITS images and uses an AstropyWCS wcs.

Properties imagepath, noisepath, and flagspath are full paths to where those files actually live on disk. Generally, they should only be used internally.

Instantiate an image. You probably don’t want to do that.

This is an abstract base class that has limited functionality. You probably want to instantiate a subclass if you’re creating a new image.

If you’re trying to pull an image out of the database, then probably what you really want is to use the Image.get_image or Image.find_images class methods.

If you’re working with non-database images and are trying to get a pre-existing image, then probably what you really want to do is call the get_image() method of an ImageCollection object.

Parameters:
  • filepath (str or Path, default None) – Path of the image relative to the base path for images, unless less no_base_path is True, in which case this is the full absolute path to the image. For datbase images, you do not want to create a path yourself, but leave it at None and let the class create the filepath. See PathedObject.

  • full_filepath (str or Path, default None) – The full path to the image. If you’re using an Image subclass to deal with an image that’s not in the database, you probably want to set this to the absolute path of the image, and you probably want to set no_base_path to True, but you might also set base_path yourself and leave no_base_path at False.

  • base_path (str or Path, default None) – Always leave this at None for images associated with database, and the default will be used. Otherwise, the absolute path of the image is base_path / filepath (which should be exactly the same as full_filepath). Must be None if no_base_path is True.

  • base_dir (str or Path, default None) – Synonym for base_path

  • no_base_path (bool, default False) – For images associated with the database, leave this at False, and make filepath relative to the base path (which may be system dependent). For images that aren’t associated with the database, you can make this True and set filepath to be just the path to the image.

  • id (UUID or str that can be converted to UUID, default None) – Database ID of the image. This is only relevant if the image is in the l2image table of the Roman SNPIT internal database (but is required in that case).

  • provenance_id (UUID or str that can be converted to UUID, default NOne) – The id of the provenance of the image. Only relevant if the image is in the l2image table of the Roman SNPIT internal database (but is required in that case).

  • width (int, default None) – The width and height of the image in pixels if known.

  • height (int, default None) – The width and height of the image in pixels if known.

  • format (int, default -1) – Index into the table Image._format_def at the bottom of this file.

  • observation_id (str)

  • sca (int, default None)

  • ra (float, default None)

  • dec (float, default None)

  • (ra|dec)_corner_(00|01|10|11) (float, default None)

  • band (str, default None)

  • mjd (float, default None)

  • position_angle (float, default None)

  • exptime (float, default None)

  • sky_level (float, default None)

  • zeropoint (float, default None) – All of these are the values that should be set for these properties (see Image class docstring). If they are None, how they get populated depends on the image subclass. In many cases, they will be lazy-loaded from the header.

Attributes Summary

flagspath

imagepath

noisepath

path

Methods Summary

get_cutout(x, y, xsize[, ysize, mode, ...])

See Image.get_cutout

get_data([which, always_reload, cache])

As a side effect, also loads the image header if image data is loaded if cache is True.

get_fits_header()

Get the header of the image.

get_ra_dec_cutout(ra, dec, xsize[, ysize, ...])

See Image.get_ra_dec_cutout

get_wcs([wcsclass])

Get image WCS.

save([which, path, imagepath, noisepath, ...])

Write image to its path.

set_fits_header(hdr)

Attributes Documentation

flagspath
imagepath
noisepath
path

Methods Documentation

get_cutout(x, y, xsize, ysize=None, mode='strict', fill_value=nan)[source]

See Image.get_cutout

The mode and fill_value parameters are passed directly to astropy.nddata.Cutout2D for FITSImage.

get_data(which='all', always_reload=False, cache=False)[source]

As a side effect, also loads the image header if image data is loaded if cache is True.

get_fits_header()[source]

Get the header of the image.

Note that FITSImage and subclasses set self._header here, inside get_fits_header.

get_ra_dec_cutout(ra, dec, xsize, ysize=None, mode='strict', fill_value=nan)[source]

See Image.get_ra_dec_cutout

The mode and fill_value parameters are passed directly to astropy.nddata.Cutout2D for FITSImage.

get_wcs(wcsclass=None)[source]

Get image WCS. Will be an object of type BaseWCS (from wcs.py) (really likely a subclass).

Parameters:

wcsclass (str or None) – By default, the subclass of BaseWCS you get back will be defined by the Image subclass of the object you call this on. If you want a specific subclass of BaseWCS, you can put the name of that class here. It may not always work; not all types of images are able to return all types of wcses.

Return type:

object of a subclass of snappl.wcs.BaseWCS

save(which='all', path=None, imagepath=None, noisepath=None, flagspath=None, imagehdu=None, noisehdu=None, flagshdu=None, overwrite=False)[source]

Write image to its path. See Image.save

Has the side-effect of loading self._header if it is None, and if replacing WCS keywords in self._header with keywords from the current image WCS.

Currently does not support saving multi-HDU files. (It will throw an exception if any of imagehdu, noisehdu, or flagshdu aren’t 0.)

set_fits_header(hdr)[source]