Utils Module

astrodonut.utils.calculate_intensity(dist, width)[source]

Calculates the intensity value based on distance from the center.

Parameters:
  • dist (float) – Distance from the center of the ellipse.

  • width (int) – Total width of the donut image (used for scaling intensity).

Returns:

Intensity value at the given distance.

Return type:

float

astrodonut.utils.create_ring(a1, b1, ecc, inc, ring_ratio, width, height)[source]

Creates a 2D numpy array representing a ring (donut) shape with elliptical geometry.

Parameters:
  • a1 (float) – Semi-major axis of the outer ellipse.

  • b1 (float) – Semi-minor axis of the outer ellipse.

  • ecc (float) – Eccentricity of the ellipse.

  • inc (float) – Inclination angle in degrees (rotation).

  • ring_ratio (float) – Ratio of inner to outer ellipse (controls thickness of the ring).

  • width (int) – Width of the resulting image.

  • height (int) – Height of the resulting image.

Returns:

2D array of shape (height, width) containing intensity values of the donut ring.

Return type:

numpy.ndarray

astrodonut.utils.transform(x, y, x0, y0, cos_inc, sin_inc)[source]

Applies a rotation and translation transformation to the coordinates.

Parameters:
  • x (float) – Original coordinates.

  • y (float) – Original coordinates.

  • x0 (float) – Center coordinates (to translate to origin).

  • y0 (float) – Center coordinates (to translate to origin).

  • cos_inc (float) – Cosine of the inclination angle (rotation).

  • sin_inc (float) – Sine of the inclination angle (rotation).

Returns:

Transformed (x, y) coordinates.

Return type:

tuple of float

astrodonut.utils.validate_parameters(a1, b1, ecc)[source]

Validates the input parameters for a donut shape.

Parameters:
  • a1 (float) – Semi-major axis of the outer ellipse.

  • b1 (float) – Semi-minor axis of the outer ellipse.

  • ecc (float) – Eccentricity of the ellipse. Must be between 0 (circular) and 1 (parabolic).

Raises:

ValueError – If eccentricity is not in the range [0, 1), or if axes are non-positive.