coronalyze.core.image_transforms#
Image transformation utilities using high-precision cubic splines.
Provides sub-pixel image shifts and flux-conserving resampling for coronagraphic image analysis. All functions are JIT-compilable and differentiable.
Functions#
|
Return the counter-clockwise rotation matrix for a given angle. |
|
Shift an image with sub-pixel precision using cubic splines. |
|
Resample an image onto a new grid while conserving total flux. |
Module Contents#
- coronalyze.core.image_transforms.ccw_rotation_matrix(rotation_deg)[source]#
Return the counter-clockwise rotation matrix for a given angle.
- Args:
rotation_deg: Rotation angle in degrees. Positive = counter-clockwise.
- Returns:
2x2 rotation matrix as a JAX array.
- Parameters:
rotation_deg (float)
- Return type:
jax.Array
- coronalyze.core.image_transforms.shift_image(image, shift_y, shift_x, order=3, mode='constant', cval=0.0)[source]#
Shift an image with sub-pixel precision using cubic splines.
Essential for planet injection where source positions are sub-pixel aligned. Uses inverse mapping: to shift content by (+dy, +dx), sample from (y-dy, x-dx).
- Args:
image: 2D input image. shift_y: Shift in Y direction (pixels). Positive = Down. shift_x: Shift in X direction (pixels). Positive = Right. order: Interpolation order (3 = cubic splines, recommended for HCI). mode: Boundary handling mode (‘constant’, ‘nearest’, ‘wrap’, ‘mirror’, ‘reflect’). cval: Value to use for ‘constant’ mode outside boundaries.
- Returns:
Shifted image with same shape as input.
- Parameters:
image (jax.Array)
shift_y (float)
shift_x (float)
order (int)
mode (str)
cval (float)
- Return type:
jax.Array
- coronalyze.core.image_transforms.resample_flux(f_src, pixscale_src, pixscale_tgt, shape_tgt, rotation_deg=0.0)[source]#
Resample an image onto a new grid while conserving total flux.
Performs an affine transformation (rotation and scaling) to map the source image onto a target grid. Converts to surface brightness, interpolates, then converts back to integrated flux per pixel.
- Args:
- f_src:
The source image (2D array) containing integrated flux values per pixel. Shape: (ny_src, nx_src).
- pixscale_src:
The pixel scale of the source image (e.g., arcsec/pixel or lambda/D). Must be in the same units as pixscale_tgt.
- pixscale_tgt:
The pixel scale of the target image. Must be in the same units as pixscale_src.
- shape_tgt:
The shape of the target image (ny_tgt, nx_tgt).
- rotation_deg:
Rotation angle in degrees. Due to inverse mapping, this rotates the image content clockwise in the output. This matches coronagraphoto’s convention exactly.
Note: Rolling a telescope CCW produces a CW rotation in the image, so this convention aligns with physical telescope roll angles.
- Returns:
The resampled image on the target grid with total flux conserved. Shape: (ny_tgt, nx_tgt).
- Parameters:
f_src (jax.Array)
pixscale_src (float)
pixscale_tgt (float)
shape_tgt (tuple[int, int])
rotation_deg (float)
- Return type:
jax.Array