RomanDatamodelImage

class snappl.image.RomanDatamodelImage(*args, **kwargs)[source]

Bases: Image

An image read from a roman datamodel ASDF file.

See Issue #46 for concerns about performance/memory and imlementation of this object.

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

data

The image data, a 2d numpy array.

dm

This property should usually not be used outside of this class.

flags

An integer 2d numpy array of pixel masks / flags TBD

noise

The 1σ pixel noise, a 2d numpy array.

Methods Summary

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

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

get_data([which, always_reload, cache])

Read the data from disk and return one or more 2d numpy arrays of data.

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

See Image.get_ra_dec_cutout

get_wcs([wcsclass])

Get image WCS.

Attributes Documentation

data
dm

This property should usually not be used outside of this class.

flags
noise

Methods Documentation

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

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

Inputs

return_FITS: bool, default True

If True, the cutout will be returned as a snappl.image.FITSImage. If False, the cutout will be returned as a snappl.image.RomanDatamodelImage.

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

Read the data from disk and return one or more 2d numpy arrays of data.

See Image.get_data for definition of parameters.

Subclass-specific wrinkle:

get_data will return actual 2d numpy arrays, which means that the memory will always be copied from what is stored from the open roman_datamodels file. We may revisit this later as we think about memory implications. (Issue #46.)

Once you get the data, it will always be cached, even if you pass cache=False. (This is because we keep the roman_datamodels file open, and currently there’s no way to free the data without closing and reopening the file.) So, cache=False does not save any memory, alas. (Again, Issue #46.)

As such, always_reload and cache are ignored for this class. This is not great, because always_reload ought to get a fresh copy of the data even if it’s been modified. To really behave that way, though, we’d have to reimplement the class to not hold open the roman_datamodels image.

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