mirage.photo package#

Submodules#

mirage.photo.astrometry module#

mirage.photo.astrometry.get_astrometry_solver()#
mirage.photo.astrometry.look_and_up_from_wcs(telescope: Telescope, wcs: WCS) tuple[ndarray, ndarray]#
mirage.photo.astrometry.wcs_from_contours(info: dict, contours: DataFrame)#
mirage.photo.astrometry.wcs_from_pixels(ra_mid_rad: float, dec_mid_rad: float, pixel_coords: ndarray, pixel_scale_hint_range: tuple[float, float] = (0.72, 0.73), search_radius_deg: float = 1.5) WCS#

mirage.photo.exceptions module#

exception mirage.photo.exceptions.AstrometryError(message: str = None)#

Bases: Exception

exception mirage.photo.exceptions.BadFitsError(message: str = None)#

Bases: Exception

exception mirage.photo.exceptions.NoMatchesError(message: str = None)#

Bases: Exception

exception mirage.photo.exceptions.NoSourcesError(message: str = None)#

Bases: Exception

exception mirage.photo.exceptions.NoStreaksError(message: str = None)#

Bases: Exception

mirage.photo.io module#

mirage.photo.io.load_fits(fits_path: str, verbose: bool = False) Tuple[dict, ndarray]#

Loads the data and header from a FITS file

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

  • verbose (bool, optional) – Whether to print the header key/value pairs as they are loaded, defaults to False

Returns:

Header and data array [ADU]

Return type:

Tuple[dict, np.ndarray]

mirage.photo.io.save_light_curve(station: Station, int_des: str, df: DataFrame, exp_time_s: float, save_dir: str = None) None#

mirage.photo.photometry module#

mirage.photo.photometry.background_subtract(ccd_adu: ndarray, reduction_factor: int = 8, box_size: int = 50, filter_size: int = 3, sigma: float = 3.0) Tuple[ndarray, ndarray, ndarray, ndarray]#

Computes a local background for the image and subtracts it

Parameters:
  • ccd_adu (np.ndarray) – CCD signal in counts (ADU)

  • reduction_factor (int, optional) – Factor to downscale image by before subtraction, upscaled again before return, defaults to 8

  • box_size (int, optional) – Size of the background boxes in pixels, defaults to 50

  • filter_size (int, optional) – Size of the background filter in pixels, defaults to 3

  • sigma (float, optional) – Standard deviations above the background, counts all values below this threshold as background pixels, defaults to 3.0

Returns:

Image with background subtracted, background map, background mask, standard deviation of the background

Return type:

Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]

mirage.photo.photometry.compute_contours(obj_mask: ndarray, reduction_factor: int = 2) DataFrame#
mirage.photo.photometry.crop_around_centroid(ccd_adu: ndarray, mask: ndarray = None, half_width: int = 15) ndarray#

Crops an image about its approximate weighted centroid, using an optional mask to exclude (or further weight) pixels

Parameters:
  • ccd_adu (np.ndarray) – Image, with the background subtracted for lower error

  • mask (np.ndarray, optional) – Binary mask to control pixel contributions to the centroid, defaults to None

  • half_width (int, optional) – Half width of the cropped box, defaults to 15

Returns:

Cropped image

Return type:

np.ndarray

mirage.photo.photometry.crop_at(ccd_adu: ndarray, crop_location: ndarray, half_width: int = 15) ndarray#

Crops an image at a given location to a given square size

Parameters:
  • ccd_adu (np.ndarray) – Input image

  • crop_location (np.ndarray) – Pixel location in the image to crop at

  • half_width (int, optional) – Half-width of the cropping square, defaults to 15

Returns:

Cropped image

Return type:

np.ndarray

mirage.photo.photometry.draw_contours_on_image(im: ndarray, contours: DataFrame, col=(255, 0, 0)) ndarray#
mirage.photo.photometry.fill_contours_on_image(im: ndarray, contours: DataFrame, col=(255, 0, 0)) ndarray#
mirage.photo.photometry.filter_contours(contours: DataFrame, constraints: list[Dict[str, tuple]])#
mirage.photo.photometry.get_shape_factor(x, y)#

Return values related to the shape based on x and y.

Parameters#

xarray_like

An array of x coordinates.

yarray_like

An array of y coordinates.

Returns#

areafloat

Area of the border.

perimeterfloat

Perimeter of the border.

x_centerfloat

X center coordinate.

y_centerfloat

Y center coordinate.

distancesnumpy.ndarray

Distances from the center to each border element.

mirage.photo.photometry.image_centroid(ccd_adu: ndarray, mode: Literal['weighted', 'max'] = 'max') ndarray#

Computes the centroid of a background-subtracted image

Parameters:

ccd_adu (np.ndarray) – Background-subtracted image

Returns:

Centroid in first and second axes

Return type:

np.ndarray

mirage.photo.photometry.object_mask(image_sub: ndarray, background_std: float, br_threshold: float = 1.9, open_size: int = 3, close_size: int = 15) ndarray#
mirage.photo.photometry.process_subframes(dates: ndarray[datetime], data: ndarray, file_names: list[str] = None, stride: int = 1, crop_half_width: int = 15, signal_mask_threshold: float = 2.5, background_mask_threshold: float = 2.0, background_reduction_factor: int = 8, saturation_limit_adu: int = 4095, sub_crop_dist_limit: float = 3.0, plot_mask: bool = False, plot_full: bool = False, plot_crop: bool = False) DataFrame#
mirage.photo.photometry.source_flux_from_subframe(image_sub_subframe: ndarray, signal_mask_threshold: float = 2.0) Tuple[float, ndarray]#

Computes the source flux in a small subframe of the overall image – it is assumed that the object signal is the only signal above the background

Parameters:
  • image_sub_subframe (np.ndarray) – Small subframe of the image, after background subtraction

  • signal_mask_threshold (float, optional) – Threshold for initial selection of source pixels, defaults to 2.0 * image median

Returns:

Calibrated flux

Return type:

Tuple[float, np.ndarray]

mirage.photo.vis module#

mirage.photo.vis.animate_subframes(data: ndarray, n_frames: int = 100, fps: int = 10, out_path: str = None) None#
mirage.photo.vis.plot_fits(ccd_adu: ndarray, norm=None) None#

Plots a CCD image, applying a log colormap to make it easier to see detail across scales

Parameters:

ccd_adu (np.ndarray) – CCD image in ADU (counts)

Module contents#