Image2D

class sofia_redux.scan.source_models.maps.image_2d.Image2D(x_size=None, y_size=None, dtype=<class 'float'>, data=None, blanking_value=nan, unit=None)[source]

Bases: Image

Create an Image2D instance.

The Image2D is an extension of the Image class that restricts the number of image dimensions to 2. Generally, the two dimensions will be referred to as x and y where x refers to data columns, and y refers to data rows.

Parameters:
x_sizeint, optional

The number of pixels for the image in the x-direction. Will only be applied if data is None and y_size is also set to an integer.

y_sizeint, optional

The number of pixels for the image in the y-direction. Will only be applied if data is None and x_size is also set to an integer.

dtypetype, optional

The data type of the data array.

datanumpy.ndarray, optional

Data to initialize the flagged array with. If supplied, sets the shape of the array. Note that the data type will be set to that defined by the dtype parameter.

blanking_valueint or float, optional

The blanking value defines invalid values in the data array. This is the equivalent of defining a NaN value.

unitstr or units.Unit or units.Quantity, optional

The data unit.

Attributes Summary

core

Return the core data.

ndim

Return the number of dimensions in the map image data.

Methods Summary

add_proprietary_unit()

Add proprietary units to the local units.

copy([with_contents])

Return a copy of the Image2D.

get_image([dtype, blanking_value])

Return an image copy, optionally changing type and blanking value.

new_image()

Return a new image.

numpy_to_fits(coordinates)

Convert numpy based (x, y) coordinates/indices to FITS coordinates.

read_hdul(hdul, hdu_index)

Read a specific HDU image from an HDU list, and return an image.

set_data(data[, change_type])

Set the image data array.

set_data_size(x_size, y_size)

Set the data shape.

size_x()

Return the size of the image in the x-direction.

size_y()

Return the size of the image in the y-direction.

Attributes Documentation

core

Return the core data.

Returns:
numpy.ndarray or None
ndim

Return the number of dimensions in the map image data.

Returns:
int

Methods Documentation

add_proprietary_unit()[source]

Add proprietary units to the local units.

Returns:
None
copy(with_contents=True)[source]

Return a copy of the Image2D.

Parameters:
with_contentsbool, optional

If True, copy the image data to the output image. Otherwise, the new copy will be of the same shape, but contain zeroed values.

Returns:
imageImage2D
get_image(dtype=None, blanking_value=None)[source]

Return an image copy, optionally changing type and blanking value.

Parameters:
dtypetype, optional

The image data type.

blanking_valueint or float, optional

The new image blanking value.

Returns:
imageImage2D
new_image()[source]

Return a new image.

Returns:
imageImage2D
classmethod numpy_to_fits(coordinates)[source]

Convert numpy based (x, y) coordinates/indices to FITS coordinates.

Parameters:
coordinatesnumpy.ndarray
Returns:
Coordinate2D
classmethod read_hdul(hdul, hdu_index)[source]

Read a specific HDU image from an HDU list, and return an image.

Parameters:
hdulastropy.io.fits.hdu.hdulist.HDUList

The HDU list to read.

hdu_indexint

The index of the HDU in the provided hdul to read.

Returns:
imageImage2D
set_data(data, change_type=False)[source]

Set the image data array.

Parameters:
datanumpy.ndarray

A 2-dimensional image array.

change_typebool, optional

If True, change the data type to that of the data.

Returns:
None
set_data_size(x_size, y_size)[source]

Set the data shape.

Parameters:
x_sizeint
y_sizeint
Returns:
None
size_x()[source]

Return the size of the image in the x-direction.

Returns:
int
size_y()[source]

Return the size of the image in the y-direction.

Returns:
int