autogalaxy.FitEllipse#
- class FitEllipse[source]#
Bases:
FitDatasetA fit to a DatasetInterp dataset, using a model image to represent the observed data and noise-map.
- Parameters:
dataset (
Imaging) – The dataset containing the signal and noise-map that is fitted.ellipse (
Ellipse) – The ellipse profile used to fit the dataset.multipole_list (
Optional[List[EllipseMultipole]]) – Optional list of multipole perturbations applied to the ellipse points.use_jax (
bool) – If True, internal arrays are computed with JAX and downstream reductions return raw JAX arrays. The algorithm is identical to the NumPy path — both use a single perimeter-sampling pass with NaN-marking for masked positions.
Methods
Return the
(N, 2)(y, x) coordinates on the ellipse perimeter where interpolation occurs.Attributes
The sum of the chi-squared-map, which quantifies how well the model data represents the data and noise-map.
Returns the chi-squared-map of the fit, which is the normalized residual-map squared.
dataThe data of the dataset being fitted.
Returns the data values of the dataset that the ellipse fits, which are computed by overlaying the ellipse over the 2D data and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse.
The figure of merit of the fit, which is passed by the Analysis class to the non-linear search to determine the best-fit solution.
gridsThe grids of (y,x) coordinates associated with the dataset, adjusted by any grid_offset and grid_rotation_angle specified in the dataset_model.
A property that is only computed once per instance and then replaces itself with an ordinary attribute.
inversionOverwrite this method so it returns the inversion used to fit the dataset.
log_evidenceReturns the log Bayesian evidence of the inversion's fit to a dataset, which extends the log likelihood by including penalty terms that quantify the complexity of the inversion's reconstruction:
The log likelihood of the fit, which quantifies how well the model data represents the data and noise-map.
log_likelihood_with_regularizationReturns the log likelihood of an inversion's fit to the dataset, including a regularization term which comes from an inversion:
maskThe 2D mask of the dataset being fitted, where False entries are unmasked and included in the fit and True entries are masked and excluded.
Returns the model-data, which is the data values where the ellipse overlaps the data minus the mean value of these data values.
noise_mapThe noise-map of the dataset being fitted, representing the RMS noise in each pixel.
Returns the noise-map values of the dataset that the ellipse fits, which are computed by overlaying the ellipse over the 2D noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse.
The noise normalization term of the log likelihood, which is the sum of the log noise-map values squared.
Returns the normalized residual-map of the fit, which is the residual-map divided by the noise-map.
reduced_chi_squaredThe reduced chi-squared of the model's fit to the dataset, defined as:
residual_flux_fraction_mapReturns the residual flux fraction map, which shows the fraction of signal in each pixel that is not fitted by the model, therefore where:
Returns the residual-map of the fit, which is the data minus the model data and therefore the same as the model data.
signal_to_noise_mapThe signal-to-noise_map of the dataset and noise-map which are fitted.
Returns the signal-to-noise-map of the dataset that the ellipse fits, which is computed by overlaying the ellipse over the 2D data and noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse.
- interp#
A property that is only computed once per instance and then replaces itself with an ordinary attribute. Deleting the attribute resets the property.
Source: https://github.com/bottlepy/bottle/commit/fa7733e075da0d790d809aa3d2f53071897e6f76
- points_from_major_axis_from()[source]#
Return the
(N, 2)(y, x) coordinates on the ellipse perimeter where interpolation occurs.Sampling proceeds in one shot:
N = Ellipse.total_points_from(pixel_scale)perimeter angles are generated.Multipole perturbations (if any) are applied in-place.
The mask interpolator is evaluated at every point; positions that sit on (or partly on) masked pixels are marked as NaN via
xp.where(keep, points, nan).
The output shape is fixed at
(N, 2)regardless of mask geometry — masked rows are NaN, unmasked rows hold their (y, x) coordinates. Downstream reductions (residual_map,chi_squared,noise_normalization) usenanmean/nansumand skip NaN positions correctly.The algorithm is identical for
self.use_jaxFalseandTrue; only the numerics backend (npvsjax.numpy) differs.- Return type:
The
(N, 2)(y, x) coordinates with NaN at masked positions.
- property data_interp: ArrayIrregular#
Returns the data values of the dataset that the ellipse fits, which are computed by overlaying the ellipse over the 2D data and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse.
The (y,x) coordinates on the ellipse where the interpolation occurs are computed in the points_from_major_axis property of the Ellipse class, with the documentation describing how these points are computed.
If the interpolation of an ellipse point uses one or more masked values, this point is not reliable, therefore the value is converted to np.nan and not used by other fitting quantities.
- Returns:
The data values of the ellipse fits, computed via a 2D interpolation of where the ellipse
overlaps the data.
- property noise_map_interp: ArrayIrregular#
Returns the noise-map values of the dataset that the ellipse fits, which are computed by overlaying the ellipse over the 2D noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse.
The (y,x) coordinates on the ellipse where the interpolation occurs are computed in the points_from_major_axis property of the Ellipse class, with the documentation describing how these points are computed.
If the interpolation of an ellipse point uses one or more masked values, this point is not reliable, therefore the value is converted to np.nan and not used by other fitting quantities.
- Returns:
The noise-map values of the ellipse fits, computed via a 2D interpolation of where the ellipse
overlaps the noise-map.
- property signal_to_noise_map_interp: ArrayIrregular#
Returns the signal-to-noise-map of the dataset that the ellipse fits, which is computed by overlaying the ellipse over the 2D data and noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse.
- Returns:
The signal-to-noise-map values of the ellipse fits, computed via a 2D interpolation of where
the ellipse overlaps the data and noise-map.
- property model_data: ArrayIrregular#
Returns the model-data, which is the data values where the ellipse overlaps the data minus the mean value of these data values.
By subtracting the mean of the data values from each data value, the model data quantifies how often there are large variations in the data values over the ellipse.
For example, if every data value subtended by the ellipse are close to one another, the difference between the data values and the mean will be small.
Conversely, if some data values are much higher or lower than the mean, the model data will be large.
- Return type:
The model data values of the ellipse fit, which are the data values minus the mean of the data values.
- property residual_map: ArrayIrregular#
Returns the residual-map of the fit, which is the data minus the model data and therefore the same as the model data.
- Return type:
The residual-map of the fit, which is the data minus the model data and therefore the same as the model data.
- property normalized_residual_map: ArrayIrregular#
Returns the normalized residual-map of the fit, which is the residual-map divided by the noise-map.
The residual map and noise map are computed by overlaying the ellipse over the 2D data and noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse. See the documentation of the residual_map and noise_map properties for more details.
- Return type:
The normalized residual-map of the fit, which is the residual-map divided by the noise-map.
- property chi_squared_map: ArrayIrregular#
Returns the chi-squared-map of the fit, which is the normalized residual-map squared.
The normalized residual map is computed by overlaying the ellipse over the 2D data and noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse. See the documentation of the normalized_residual_map property for more details.
- Return type:
The chi-squared-map of the fit, which is the normalized residual-map squared.
- property chi_squared: float#
The sum of the chi-squared-map, which quantifies how well the model data represents the data and noise-map.
The chi-squared-map is computed by overlaying the ellipse over the 2D data and noise-map and performing a 2D interpolation at discrete (y,x) coordinates on the ellipse. See the documentation of the chi_squared_map property for more details.
- Return type:
The chi-squared of the fit.
- property noise_normalization#
The noise normalization term of the log likelihood, which is the sum of the log noise-map values squared.
- Return type:
The noise normalization term of the log likelihood.
- property log_likelihood#
The log likelihood of the fit, which quantifies how well the model data represents the data and noise-map.
- Return type:
The log likelihood of the fit.