mirar.data.utils package

Utils for data

Submodules

mirar.data.utils.compress module

Module for encoding/decoding numpy 2D images to gziped fits files

mirar.data.utils.compress.decode_img(compressed_bytes: bytes) ndarray[source]

Function to parse a cutout (gziped fits file) into a numpy array

Parameters:

compressed_bytes – Gziped fits file bytes

Returns:

Numpy array of the image

mirar.data.utils.compress.encode_img(image: array)[source]

make bit images of the cutouts for the marshal Args:

image: 2D numpy array

Returns:

compressed bytes

mirar.data.utils.coords module

Functions to get image coordinates from WCS

mirar.data.utils.coords.check_coords_within_image(ra: float | list[float], dec: float | list[float], header: Header) list[bool][source]

Check that the coordinates are within the image Args:

param ra:

RA in decimal degrees

param dec:

Dec in decimal degrees

param header:

Image header with WCS info.

Returns:
return:

True if within image, False if not

mirar.data.utils.coords.get_corners_ra_dec_from_header(header: Header) [tuple[float, float], tuple[float, float], tuple[float, float], tuple[float, float]][source]

Function to get corner RA/Dec of the image from the header Args:

header:

Returns:

mirar.data.utils.coords.get_image_center_wcs_coords(image: Image, origin: int = 0)[source]

Get RA/Dec of an image Args:

origin: 0 or 1, depending on whether you want it in DS9 coordinates image: Image

Returns:

mirar.data.utils.coords.get_image_dims_from_header(header: ~astropy.io.fits.header.Header) -> (<class 'astropy.units.quantity.Quantity'>, <class 'astropy.units.quantity.Quantity'>)[source]

Get image dimensions from the header Args:

header:

Returns:

mirar.data.utils.coords.get_xy_from_wcs(ra_deg: float, dec_deg: float, header: ~astropy.io.fits.header.Header, origin: int = 0) -> (<class 'float'>, <class 'float'>)[source]

Get image x-y coordinates of a given ra/dec Args:

ra_deg: RA in decimal degrees dec_deg: Dec in decimal degrees header: image header, requires WCS keywords origin: 0 or 1, depending on whether you want it in DS9 coordinates

Returns:

x: x coordinate y: y coordinate

mirar.data.utils.coords.write_regions_file(regions_path: str | Path, x_coords: list[float], y_coords: list[float], system: str = 'image', region_radius: float = 5, text: list | None = None)[source]

Function to write a regions file Args:

regions_path: str, path to regions file x_coords: list, x-coordinates or RA y_coords: list, y-coordinates or Dec system: str, image or wcs region_radius: float, radius of circle text: list, text to accompany the regions file

Returns:

mirar.data.utils.plot_image module

Utilities for working with data

mirar.data.utils.plot_image.plot_fits_image(image: Image, savedir: str | Path, regions_wcs_coords: List[Tuple[float, float]] | None = None, plot_format: str = 'png', title_fields: List[str] | None = None, fig: Figure | None = None)[source]

Plot the fits image with the specified regions Args:

param image:

Image to plot

param savedir:

Directory to save to.

:param regions_wcs_coords:If you want to mark specific coordinates on the image, provide a list of tuples of RA, Dec :param plot_format: pdf or png :param title_fields: Image header fields to annotate the plot with :param fig: If you want to plot on an existing figure, provide it here