coronalyze.core.geometry#

Geometric utilities for coronagraphic image analysis.

Functions for coordinate transforms, distance calculations, and generating aperture positions with static array shapes for JAX compatibility.

Functions#

get_center(shape)

Get the center coordinates of an image (0-indexed geometric center).

radial_distance(shape[, center])

Calculate radial distance from center for each pixel.

calculate_n_apertures(radius, fwhm[, exclusion_buffer])

Calculate the number of reference apertures at a given radius.

generate_aperture_coords(center, radius, planet_angle, ...)

Generate coordinates for reference apertures at a given radius.

Module Contents#

coronalyze.core.geometry.get_center(shape)[source]#

Get the center coordinates of an image (0-indexed geometric center).

For an image of size N, the geometric center is at (N-1)/2. This matches the convention used in modeling.py for planet injection.

Args:

shape: Image shape (ny, nx).

Returns:

Center coordinates (cy, cx).

Parameters:

shape (tuple[int, int])

Return type:

tuple[float, float]

coronalyze.core.geometry.radial_distance(shape, center=None)[source]#

Calculate radial distance from center for each pixel.

Args:

shape: Image shape (ny, nx). center: Center coordinates (cy, cx). If None, uses image center.

Returns:

2D array of radial distances in pixels.

Parameters:
  • shape (tuple[int, int])

  • center (tuple[float, float] | None)

Return type:

jax.numpy.ndarray

coronalyze.core.geometry.calculate_n_apertures(radius, fwhm, exclusion_buffer=0.5)[source]#

Calculate the number of reference apertures at a given radius.

Uses the Mawet et al. (2014) formula with exclusion buffer correction to ensure no overlap with the planet aperture on either side.

This function provides the canonical calculation used by the SNR module, ensuring consistency between visualization and computation.

Args:

radius: Radial distance from center in pixels. fwhm: Full width at half maximum in pixels. exclusion_buffer: Gap between planet and first/last reference aperture

in units of angular step (default 0.5). Creates a gap on both sides.

Returns:

Number of valid reference apertures.

Example:

from coronalyze.core.geometry import calculate_n_apertures
n = calculate_n_apertures(radius=20, fwhm=5.0)
print(f"{n} reference apertures at r=20px")
Parameters:
  • radius (float)

  • fwhm (float)

  • exclusion_buffer (float)

Return type:

int

coronalyze.core.geometry.generate_aperture_coords(center, radius, planet_angle, n_apertures, max_apertures=200, fwhm=None, exclusion_buffer=0.5)[source]#

Generate coordinates for reference apertures at a given radius.

Uses a fixed-size array with masking for JAX compatibility (static shapes). Apertures are distributed evenly around the annulus, excluding the planet position.

Matches VIP’s clockwise rotation and angle formula from planet position.

Args:

center: Image center (cy, cx) in pixels. radius: Radial distance from center in pixels. planet_angle: Angle of the planet position in radians. n_apertures: Actual number of valid apertures to use. max_apertures: Maximum buffer size for static array shape. fwhm: Full width half maximum for VIP-style angle calculation. If None,

uses uniform distribution.

exclusion_buffer: Gap between test and first reference aperture in

units of angular step (default 0.0). Prevents PSF wing leakage.

Returns:
Tuple of (y_coords, x_coords, mask) where:
  • y_coords: Y coordinates of aperture centers (size max_apertures)

  • x_coords: X coordinates of aperture centers (size max_apertures)

  • mask: Boolean mask indicating valid apertures

Parameters:
  • center (tuple[float, float])

  • radius (float)

  • planet_angle (float)

  • n_apertures (int)

  • max_apertures (int)

  • fwhm (float | None)

  • exclusion_buffer (float)

Return type:

tuple[jax.numpy.ndarray, jax.numpy.ndarray, jax.numpy.ndarray]