coolest.template.classes.grid#

Classes#

Grid

Generic class that represents a grid of coordinates and values.

PixelatedRegularGrid

Class that represents a grid of values defined on a regular, Cartesian grid.

IrregularGrid

Class that represents an irregular set of values and their coordinates.

Module Contents#

class Grid(fits_path: str, check_fits_file: bool = False, fits_file_dir: str = None)[source]#

Generic class that represents a grid of coordinates and values.

Parameters:
  • fits_path (str) – Path to the FITS file in which the values (and perhaps the coordinates) are stored. If meant to be stored within a COOLEST template file, this should just be the name of the FITS file, placed in the same directory as the template.

  • check_fits_file (bool, optional) – If True, creating the object will check that the FITS file exists, by default False

  • fits_file_dir (str, optional) – Absolute path of the directory containing the FITS file, by default None

fits_file[source]#
set_grid(fits_path, check_fits_file)[source]#

Set / replace the FitsFile object associated with the Grid. This is useful to set associate the FITS file after the Grid instance has been created.

Parameters:
  • fits_path (str) – Path to the FITS file

  • check_fits_file (_type_) – If True, check the existence of the FITS file at fits_path.

class PixelatedRegularGrid(fits_path: str = None, field_of_view_x: Tuple[float] = (0, 0), field_of_view_y: Tuple[float] = (0, 0), num_pix_x: int = 0, num_pix_y: int = 0, **kwargs_file)[source]#

Class that represents a grid of values defined on a regular, Cartesian grid.

Parameters:
  • fits_path (str) – Path to the FITS file in which the values (and perhaps the coordinates) are stored. This should be relative to the final COOLEST template file.

  • field_of_view_x (Tuple[float], optional) – 2-tuple holding the extremal coordinates of the coordinates grid along the x direction (i.e., left side of the leftmost pixel and rightside of the rightmost pixel), by default (0, 0)

  • field_of_view_y (Tuple[float], optional) – 2-tuple holding the extremal coordinates of the coordinates grid along the y direction (i.e., bottom side of the lower pixel and top side of the upper pixel), by default (0, 0)

  • num_pix_x (int, optional) – Number of pixels along the x direction, by default 0

  • num_pix_y (int, optional) – Number of pixels along the y direction, by default 0

  • **kwargs_file (dic, optional) – Any remaining keyword arguments for FitsFile

property shape[source]#
property pixel_size[source]#
set_grid(fits_path, field_of_view_x, field_of_view_y, num_pix_x=0, num_pix_y=0, check_fits_file=True)[source]#

Set / replace the FitsFile object associated with the Grid. This is useful to set the FITS file after the Grid instance has been created.

See class constructor for parameter descriptions.

read_fits()[source]#

Read the content of the FITS file and extract the necessary Grid attributes.

Returns:

Number of pixels along each axis.

Return type:

(num_pix_x, num_pix_y)

get_pixels(directory=None)[source]#

Get the pixel (z) values of the regular grid from the FITS file. If the attribute FITS path is a relative one, it needs the absolute directory to read the FITS file.

Parameters:

directory (str, optional) – Absolute directory of the FITS file, by default None

Returns:

2D array of pixel values associated to the regular grid.

Return type:

ndarray

class IrregularGrid(fits_path: str = None, field_of_view_x: Tuple[float] = (0, 0), field_of_view_y: Tuple[float] = (0, 0), num_pix: int = 0, **kwargs_file)[source]#

Class that represents an irregular set of values and their coordinates.

Parameters:
  • fits_path (str) – Path to the FITS file in which the values (and perhaps the coordinates) are stored. This should be relative to the final COOLEST template file.

  • field_of_view_x (Tuple[float], optional) – 2-tuple holding the minimum and maximum values of the x coordinates vector, by default (0, 0)

  • field_of_view_y (Tuple[float], optional) – 2-tuple holding the minimum and maximum values of the y coordinates vector, by default (0, 0)

  • num_pix (int, optional) – Number of coordinates points, by default 0

  • **kwargs_file (dic, optional) – Any remaining keyword arguments for FitsFile

set_grid(fits_path, field_of_view_x=(0, 0), field_of_view_y=(0, 0), num_pix=0, check_fits_file=True)[source]#

Set / replace the FitsFile object associated with the Grid. This is useful to set associate the FITS file after the Grid instance has been created.

See class constructor for parameter descriptions.

read_fits()[source]#

Read the content of the FITS file and extract the necessary Grid attributes.

Returns:

Field of view and number of pxiels.

Return type:

field_of_view_x, field_of_view_y, num_pix

get_xyz(directory=None)[source]#

Get the x, y, z values of the irregular grid from the FITS file. If the attribute FITS path is a relative one, it needs the absolute directory to read the FITS file.

Parameters:

directory (str, optional) – Absolute directory of the FITS file, by default None

Returns:

x, y and z arrays

Return type:

ndarray, ndarray, ndarray