astrophot.utils.initialize package#

Submodules#

astrophot.utils.initialize.PA module#

astrophot.utils.initialize.PA.R(theta)[source]#
astrophot.utils.initialize.PA.polar_decomposition(A)[source]#

astrophot.utils.initialize.center module#

astrophot.utils.initialize.center.center_of_mass(image)[source]#

Determines the light weighted center of mass

astrophot.utils.initialize.center.recursive_center_of_mass(image, max_iter=10, tol=0.1)[source]#

Determines the light weighted center of mass in a progressively smaller window each time centered on the previous center.

astrophot.utils.initialize.construct_psf module#

astrophot.utils.initialize.construct_psf.gaussian_psf(sigma, img_width, pixelscale, upsample=4, normalize=True)[source]#

create a gaussian point spread function (PSF) image.

Args: - sigma: Standard deviation of the Gaussian in arcseconds. - img_width: Width of the PSF image in pixels. - pixelscale: Pixel scale in arcseconds per pixel. - upsample: Upsampling factor to more accurately create the PSF (the outputted PSF is not upsampled). - normalize: Whether to normalize the PSF so that the sum of all pixels equals 1. If False, the PSF will not be normalized.

astrophot.utils.initialize.construct_psf.moffat_psf(n, Rd, img_width, pixelscale, upsample=4, normalize=True)[source]#

Create a Moffat point spread function (PSF) image.

Args: - n: Moffat index (power-law index). - Rd: Scale radius of the Moffat profile in arcseconds. - img_width: Width of the PSF image in pixels. - pixelscale: Pixel scale in arcseconds per pixel. - upsample: Upsampling factor to more accurately create the PSF (the outputted PSF is not upsampled). - normalize: Whether to normalize the PSF so that the sum of all pixels equals 1. If False, the PSF will not be normalized.

astrophot.utils.initialize.segmentation_map module#

astrophot.utils.initialize.segmentation_map.PA_from_segmentation_map(seg_map: ndarray | str, image: Image, centroids=None, sky_level: float | None = None, hdul_index_seg: int = 0, skip_index: tuple = (0,), softening: float = 0.001)[source]#
astrophot.utils.initialize.segmentation_map.centroids_from_segmentation_map(seg_map: ndarray | str, image: Image, sky_level: float | None = None, hdul_index_seg: int = 0, skip_index: tuple = (0,))[source]#

identify centroid centers for all segments in a segmentation map

For each segment in the map, computes a flux weighted centroid in pixel space. A dictionary of pixel centers is produced where the keys of the dictionary correspond to the segment id’s.

Args: - seg_map (Union[np.ndarray, str]): A segmentation map which gives the object identity for each pixel - image (Union[np.ndarray, str]): An Image which will be used in the light weighted center of mass calculation - sky_level (float): The sky level to subtract from the image data before calculating centroids. Default: None, which uses the median of the image data. - hdul_index_seg (int): If reading from a fits file this is the hdu list index at which the map is found. Default: 0 - skip_index (tuple): Lists which identities (if any) in the segmentation map should be ignored. Default (0,)

astrophot.utils.initialize.segmentation_map.filter_windows(windows, min_size: float | None = None, max_size: float | None = None, min_area: float | None = None, max_area: float | None = None, min_flux: float | None = None, max_flux: float | None = None, image: Image = None)[source]#

Filter a set of windows based on a set of criteria.

Args: - windows: A dictionary of windows to filter. Each window is formatted as a list of lists with: window = [[xmin,ymin],[xmax,ymax]] - min_size: minimum size of the window in pixels - max_size: maximum size of the window in pixels - min_area: minimum area of the window in pixels - max_area: maximum area of the window in pixels - min_flux: minimum flux of the window in ADU - max_flux: maximum flux of the window in ADU - image: the image from which the flux is calculated for min_flux and max_flux

astrophot.utils.initialize.segmentation_map.q_from_segmentation_map(seg_map: ndarray | str, image: Image, centroids=None, sky_level: float | None = None, hdul_index_seg: int = 0, skip_index: tuple = (0,), softening: float = 0.001)[source]#
astrophot.utils.initialize.segmentation_map.scale_windows(windows, image: Image = None, expand_scale=1.0, expand_border=0.0)[source]#
astrophot.utils.initialize.segmentation_map.transfer_windows(windows, base_image, new_image)[source]#

Convert a set of windows from one image object to another. This will account for the relative adjustments in origin, pixelscale, and rotation between the two images.

Args: - windows: A dictionary of windows to be transferred. Each window is formatted as a list of lists with: window = [[xmin,ymin],[xmax,ymax]] - base_image: The image object from which the windows are being transferred. - new_image: The image object to which the windows are being transferred.

astrophot.utils.initialize.segmentation_map.windows_from_segmentation_map(seg_map, hdul_index=0, skip_index=(0,))[source]#

Convert a segmentation map into boinding boxes

Takes a segmentation map as input and uses the segmentation ids to determine bounding boxes for every object. Scales the bounding boxes according to given factors and returns the coordinates.

each window is formatted as a list of lists with: window = [[xmin,ymin],[xmax,ymax]]

expand_scale changes the base window by the given factor. expand_border is added afterwards on all sides (so an expand border of 1 will add 2 to the total width of the window.

astrophot.utils.initialize.variance module#

astrophot.utils.initialize.variance.auto_variance(data, mask=None)[source]#

Module contents#

astrophot.utils.initialize.PA_from_segmentation_map(seg_map: ndarray | str, image: Image, centroids=None, sky_level: float | None = None, hdul_index_seg: int = 0, skip_index: tuple = (0,), softening: float = 0.001)[source]#
astrophot.utils.initialize.R(theta)[source]#
astrophot.utils.initialize.auto_variance(data, mask=None)[source]#
astrophot.utils.initialize.center_of_mass(image)[source]#

Determines the light weighted center of mass

astrophot.utils.initialize.centroids_from_segmentation_map(seg_map: ndarray | str, image: Image, sky_level: float | None = None, hdul_index_seg: int = 0, skip_index: tuple = (0,))[source]#

identify centroid centers for all segments in a segmentation map

For each segment in the map, computes a flux weighted centroid in pixel space. A dictionary of pixel centers is produced where the keys of the dictionary correspond to the segment id’s.

Args: - seg_map (Union[np.ndarray, str]): A segmentation map which gives the object identity for each pixel - image (Union[np.ndarray, str]): An Image which will be used in the light weighted center of mass calculation - sky_level (float): The sky level to subtract from the image data before calculating centroids. Default: None, which uses the median of the image data. - hdul_index_seg (int): If reading from a fits file this is the hdu list index at which the map is found. Default: 0 - skip_index (tuple): Lists which identities (if any) in the segmentation map should be ignored. Default (0,)

astrophot.utils.initialize.filter_windows(windows, min_size: float | None = None, max_size: float | None = None, min_area: float | None = None, max_area: float | None = None, min_flux: float | None = None, max_flux: float | None = None, image: Image = None)[source]#

Filter a set of windows based on a set of criteria.

Args: - windows: A dictionary of windows to filter. Each window is formatted as a list of lists with: window = [[xmin,ymin],[xmax,ymax]] - min_size: minimum size of the window in pixels - max_size: maximum size of the window in pixels - min_area: minimum area of the window in pixels - max_area: maximum area of the window in pixels - min_flux: minimum flux of the window in ADU - max_flux: maximum flux of the window in ADU - image: the image from which the flux is calculated for min_flux and max_flux

astrophot.utils.initialize.gaussian_psf(sigma, img_width, pixelscale, upsample=4, normalize=True)[source]#

create a gaussian point spread function (PSF) image.

Args: - sigma: Standard deviation of the Gaussian in arcseconds. - img_width: Width of the PSF image in pixels. - pixelscale: Pixel scale in arcseconds per pixel. - upsample: Upsampling factor to more accurately create the PSF (the outputted PSF is not upsampled). - normalize: Whether to normalize the PSF so that the sum of all pixels equals 1. If False, the PSF will not be normalized.

astrophot.utils.initialize.moffat_psf(n, Rd, img_width, pixelscale, upsample=4, normalize=True)[source]#

Create a Moffat point spread function (PSF) image.

Args: - n: Moffat index (power-law index). - Rd: Scale radius of the Moffat profile in arcseconds. - img_width: Width of the PSF image in pixels. - pixelscale: Pixel scale in arcseconds per pixel. - upsample: Upsampling factor to more accurately create the PSF (the outputted PSF is not upsampled). - normalize: Whether to normalize the PSF so that the sum of all pixels equals 1. If False, the PSF will not be normalized.

astrophot.utils.initialize.polar_decomposition(A)[source]#
astrophot.utils.initialize.q_from_segmentation_map(seg_map: ndarray | str, image: Image, centroids=None, sky_level: float | None = None, hdul_index_seg: int = 0, skip_index: tuple = (0,), softening: float = 0.001)[source]#
astrophot.utils.initialize.recursive_center_of_mass(image, max_iter=10, tol=0.1)[source]#

Determines the light weighted center of mass in a progressively smaller window each time centered on the previous center.

astrophot.utils.initialize.scale_windows(windows, image: Image = None, expand_scale=1.0, expand_border=0.0)[source]#
astrophot.utils.initialize.transfer_windows(windows, base_image, new_image)[source]#

Convert a set of windows from one image object to another. This will account for the relative adjustments in origin, pixelscale, and rotation between the two images.

Args: - windows: A dictionary of windows to be transferred. Each window is formatted as a list of lists with: window = [[xmin,ymin],[xmax,ymax]] - base_image: The image object from which the windows are being transferred. - new_image: The image object to which the windows are being transferred.

astrophot.utils.initialize.windows_from_segmentation_map(seg_map, hdul_index=0, skip_index=(0,))[source]#

Convert a segmentation map into boinding boxes

Takes a segmentation map as input and uses the segmentation ids to determine bounding boxes for every object. Scales the bounding boxes according to given factors and returns the coordinates.

each window is formatted as a list of lists with: window = [[xmin,ymin],[xmax,ymax]]

expand_scale changes the base window by the given factor. expand_border is added afterwards on all sides (so an expand border of 1 will add 2 to the total width of the window.