argosim.metrics_utils module#

Metrics utils.

This module contains utility functions to compute metrics between images.

Authors:

Ezequiel Centofanti <ezequiel.centofanti@cea.fr>

argosim.metrics_utils.compute_beam_metrics(beam)[source]#

Compute beam metrics.

Compute main beam metrics: SLL, FWHM, and eccentricity.

Parameters:

beam (np.ndarray) – The beam image (2D).

Returns:

Dictionary containing SLL (dB), FWHM (x, y), and eccentricity.

Return type:

dict

argosim.metrics_utils.compute_eccentricity(beam, fit_result=None)[source]#

Compute eccentricity.

Compute the eccentricity of the beam main lobe.

Parameters:
  • beam (np.ndarray) – The beam image (2D).

  • fit_result (dict) – Dictionary containing the ellipse parameters (center, width, height, angle_deg, eccentricity). If None, it is computed from the beam.

Returns:

Eccentricity of the beam. Ranges from 0 to 1, where 0 indicates a perfectly circular beam and 1 a completely degenerated beam.

Return type:

float

argosim.metrics_utils.compute_fwhm(beam, fit_result=None)[source]#

Compute fwhm.

Compute FWHM from beam.

Parameters:
  • beam (np.ndarray) – The beam image (2D).

  • fit_result (dict) – Dictionary containing the ellipse parameters (center, width, height, angle_deg, eccentricity). If None, it is computed from the beam.

Returns:

FWHM along the semi-major and semi-minor axis of the beam.

Return type:

tuple

argosim.metrics_utils.compute_metrics(img1, img2)[source]#

Compute metrics.

Function to compute the metrics between two images.

Parameters:
  • img1 (np.ndarray) – The first image.

  • img2 (np.ndarray) – The second image.

Returns:

metrics – The metrics between the two images.

Return type:

dict

argosim.metrics_utils.compute_sll(beam, fit_result=None, scale=3.0)[source]#

Compute sll.

Compute the Side-lobe level (SLL) of a beam using an elliptical mask.

Parameters:
  • beam (np.ndarray) – The beam image (2D).

  • fit_result (dict) – Dictionary containing the ellipse parameters (center, width, height, angle_deg, eccentricity). If None, it is computed from the beam.

  • scale (float) – Scale factor for the elliptical mask.

Returns:

sll_db – Side-lobe level in dB.

Return type:

float

argosim.metrics_utils.fit_elliptical_beam(beam, threshold_ratio=0.5)[source]#

Fit elliptical beam.

Fit an ellipse to the main lobe of the dirty beam using intensity thresholding.

Parameters:
  • beam (np.ndarray) – 2D beam image.

  • threshold_ratio (float) – Threshold fraction of the maximum intensity to define the bright region.

Returns:

dict – Ellipse parameters: center, width, height, angle_deg, eccentricity.

Return type:

dictionary

argosim.metrics_utils.mask_main_lobe_elliptical(beam, fit_result, scale=3.0)[source]#

Mask main lobe elliptical.

Apply an elliptical mask to suppress the main lobe from a beam image.

Parameters:
  • beam (np.ndarray) – 2D beam image.

  • fit_result (dict) – Dictionary containing the ellipse parameters (center, width, height, angle_deg, eccentricity).

  • scale (float) – Scale factor to enlarge or shrink the elliptical mask (default is 3).

Returns:

beam_masked – Beam image with the main lobe masked (set to 0).

Return type:

np.ndarray

argosim.metrics_utils.mse(img1, img2)[source]#

Mean squared error.

Function to compute the mean squared error between two images.

Parameters:
  • img1 (np.ndarray) – The first image.

  • img2 (np.ndarray) – The second image.

Returns:

mse – The mean squared error between the two images.

Return type:

float

argosim.metrics_utils.residuals(img1, img2, absolute=True)[source]#

Residuals.

Function to compute the residuals between two images.

Parameters:
  • img1 (np.ndarray) – The first image.

  • img2 (np.ndarray) – The second image.

Returns:

residual – The residuals between the two images.

Return type:

np.ndarray