stacked_seds.stacking

This module provides functions for creating and stacking galaxy image cutouts.

Functions

get_galaxy_pixel_coords(image_path, region_path)

Reads a FITS image header and a region file to get galaxy pixel coordinates.

create_stamps(image_data, wcs_obj, pixel_coords)

Creates cutout stamps for each coordinate in the pixel coordinate array.

stack_images(stamps[, trim_fraction])

Stacks a set of image stamps using a trimmed mean and calculates the error.

save_stacked_fits(filename, data, error_map, ...)

Saves the stacked data and error map to a new FITS file.

Detailed API

stacked_seds.stacking.get_galaxy_pixel_coords(image_path, region_path)[source]

Reads a FITS image header and a region file to get galaxy pixel coordinates.

Parameters:
  • image_path (str) – Path to the FITS image file.

  • region_path (str) – Path to the .reg file containing galaxy world coordinates.

Returns:

An array of (x, y) pixel coordinates for each galaxy.

Return type:

np.ndarray

stacked_seds.stacking.create_stamps(image_data, wcs_obj, pixel_coords, stamp_size=51)[source]

Creates cutout stamps for each coordinate in the pixel coordinate array.

Parameters:
  • image_data (np.ndarray) – The 2D FITS image data.

  • wcs_obj (wcs.WCS) – The World Coordinate System object from the FITS header.

  • pixel_coords (np.ndarray) – Array of (x, y) pixel coordinates.

  • stamp_size (int) – The edge length of the square stamp in pixels.

Returns:

A 3D array of all valid (correctly sized) stamps.

Return type:

np.ndarray

stacked_seds.stacking.stack_images(stamps, trim_fraction=0.1)[source]

Stacks a set of image stamps using a trimmed mean and calculates the error.

Parameters:
  • stamps (np.ndarray) – A 3D array of stamps to stack.

  • trim_fraction (float) – The fractional part of data to trim from each end.

Returns:

A tuple containing:
  • np.ndarray: The final stacked 2D image.

  • np.ndarray: The 2D error map (standard error of the mean).

Return type:

tuple

stacked_seds.stacking.save_stacked_fits(filename, data, error_map, original_header, zeropoint)[source]

Saves the stacked data and error map to a new FITS file.

Parameters:
  • filename (str) – The output path for the new FITS file.

  • data (np.ndarray) – The 2D stacked image data.

  • error_map (np.ndarray) – The 2D standard error map.

  • original_header (fits.Header) – The header from the original image.

  • zeropoint (float) – The magnitude zeropoint for this band.