coronalyze.core.modeling#

Forward modeling tools for injecting synthetic sources.

Provides utilities for fake planet injection and simple disk generation for throughput estimation and contrast curve calculations.

Functions#

inject_planet(image, psf_template, flux, pos[, order])

Inject a fake planet into an image using cubic spline shifts.

make_simple_disk(shape, radius, inclination_deg, width)

Generate a simple, optically thin Gaussian ring/disk.

subtract_star(science, star_model[, scale])

Subtract stellar PSF model from observation.

subtract_disk(residual, disk_model[, scale])

Subtract disk model from residual image.

Module Contents#

coronalyze.core.modeling.inject_planet(image, psf_template, flux, pos, order=3)[source]#

Inject a fake planet into an image using cubic spline shifts.

The PSF template is shifted from the image center to the target position with sub-pixel precision, scaled by the flux, and added to the image.

Args:

image: 2D image to inject into, shape (ny, nx). psf_template: 2D PSF template centered at image center, same shape as image. flux: Flux scaling factor for the injected planet. pos: Target position (y, x) in pixels. order: Interpolation order for sub-pixel shifting (default: 3 = cubic).

Returns:

Image with injected planet, same shape as input.

Parameters:
  • image (jax.numpy.ndarray)

  • psf_template (jax.numpy.ndarray)

  • flux (float)

  • pos (tuple[float, float])

  • order (int)

Return type:

jax.numpy.ndarray

coronalyze.core.modeling.make_simple_disk(shape, radius, inclination_deg, width, flux=1.0, pa_deg=0.0)[source]#

Generate a simple, optically thin Gaussian ring/disk.

Analytically projects the disk to avoid interpolation artifacts. Flux is normalized so the total integrated flux equals the specified value.

Args:

shape: Output image shape (ny, nx). radius: Ring radius in pixels. inclination_deg: Disk inclination (0 = face-on, 90 = edge-on). width: Gaussian width (sigma) of the ring in pixels. flux: Total integrated flux of the disk. Default 1.0. pa_deg: Position angle of major axis, measured East of North (degrees).

Returns:

2D disk image with total flux normalized to the specified value.

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

  • radius (float)

  • inclination_deg (float)

  • width (float)

  • flux (float)

  • pa_deg (float)

Return type:

jax.numpy.ndarray

coronalyze.core.modeling.subtract_star(science, star_model, scale=1.0)[source]#

Subtract stellar PSF model from observation.

This is the fundamental operation for “perfect” RDI when you have a noiseless stellar PSF expectation (e.g., from coronagraphoto).

Args:

science: Observed image (electrons). star_model: Noiseless stellar PSF expectation (electrons). scale: Multiplicative scaling factor for the model before subtraction.

Use values != 1.0 when the reference brightness differs from the science image (e.g., different exposure times or stellar flux).

Returns:

Residual image containing noise + planet signal.

Example:

residual = subtract_star(observation, star_expectation)
# With scaling for brightness mismatch:
residual = subtract_star(observation, star_expectation, scale=0.95)
Parameters:
  • science (jax.numpy.ndarray)

  • star_model (jax.numpy.ndarray)

  • scale (float)

Return type:

jax.numpy.ndarray

coronalyze.core.modeling.subtract_disk(residual, disk_model, scale=1.0)[source]#

Subtract disk model from residual image.

Disk subtraction is typically a separate modeling task from stellar speckle subtraction. Call this after subtract_star when analyzing systems with circumstellar disks.

Args:

residual: Image after stellar subtraction (from subtract_star). disk_model: Disk model expectation (electrons). scale: Multiplicative scaling factor for the disk model.

Adjust when disk model brightness doesn’t match observation.

Returns:

Residual image with disk contribution removed.

Example:

# Two-step subtraction
residual = subtract_star(observation, star_model)
residual = subtract_disk(residual, disk_model)
Parameters:
  • residual (jax.numpy.ndarray)

  • disk_model (jax.numpy.ndarray)

  • scale (float)

Return type:

jax.numpy.ndarray