adam_core.coordinates.residuals module¶
- class adam_core.coordinates.residuals.Residuals(table: Table, **kwargs: int | float | str)[source]¶
Bases:
Table- values¶
A column for storing variably-sized lists of values.
The values in the list can be of any type.
Note that all quivr Tables are storing lists of values, so this column type is only useful for storing lists of lists.
- Parameters:
value_type – The type of the values in the list.
nullable – Whether the list can contain null values.
metadata – A dictionary of metadata to attach to the column.
validator – A validator to run against the column’s values.
- chi2¶
A column for storing 64-bit floating point numbers.
- dof¶
A column for storing 64-bit integers.
- probability¶
A column for storing 64-bit floating point numbers.
- classmethod calculate(observed: CartesianCoordinates | CometaryCoordinates | KeplerianCoordinates | SphericalCoordinates, predicted: CartesianCoordinates | CometaryCoordinates | KeplerianCoordinates | SphericalCoordinates, custom_coordinates: bool = False, use_predicted_covariance: bool = True) Residuals[source]¶
Calculate the residuals between the observed and predicted coordinates. Residuals are defined as the observed coordinates minus the predicted coordinates.
The covariance used for chi2 is the sum of the observed covariance and (optionally) the predicted covariance. If a single predicted coordinate is provided, it is broadcast to the same length as the observed coordinates.
- Parameters:
observed (CoordinateType (N, D)) – Observed coordinates.
predicted (CoordinateType (N, D) or (1, D)) – Predicted coordinates. If a single coordinate is provided, it is broadcasted to the same shape as the observed coordinates.
custom_coordinates (bool, optional) – If True, the coordinate class will not be checked against the supported coordinate classes included in adam_core.
use_predicted_covariance (bool, optional) – If True, include predicted covariance in the chi2 calculation (i.e., use Σ_obs + Σ_pred). If False, use only the observed covariance (Σ_obs).
- Returns:
residuals – Residuals between the observed and predicted coordinates.
- Return type:
~adam_core.coordinates.residuals.Residuals
- to_array() ndarray[tuple[Any, ...], dtype[float64]][source]¶
Convert the residuals to a numpy array.
- Returns:
residuals – Array of residuals.
- Return type:
~numpy.ndarray (N, D)
- schema: ClassVar[pa.Schema] = values: list<item: double> child 0, item: double chi2: double dof: int64 probability: double¶
- adam_core.coordinates.residuals.calculate_chi2(residuals: ndarray[tuple[Any, ...], dtype[float64]], covariances: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]][source]¶
Calculate the vectorized normalized squared residual for each residual and covariance pair. This normalized residual is equivalent to the Mahalanobis distance squared. For residuals with no covariance (all non-diagonal covariance elements are zero) this is exactly equivalent to chi2.
If the off-diagonal covariance elements (the covariate terms) are missing (represented by NaNs), then they will assumed to be 0.0.
- Parameters:
residuals (~numpy.ndarray (N, D)) – Array of N residuals in D dimensions (observed - predicted).
covariances (~numpy.ndarray (N, D, D)) – Array of N covariance matrices in D dimensions.
- Returns:
chi2 – Array of chi2 values for each residual and covariance pair.
- Return type:
~numpy.ndarray (N)
References
- [1] Carpino, M. et al. (2003). Error statistics of asteroid optical astrometric observations.
Icarus, 166, 248-270. https://doi.org/10.1016/S0019-1035(03)00051-4