curepy.retrieval_methods.base module#
Base class for retrieval methods
- class curepy.retrieval_methods.base.BaseRetrieval[source]#
Bases:
ABCBase retrieval object.
- find_chisum(theta: ndarray, repeat_dims: List[int] = []) float[source]#
Compute the chi-squared cost between the forward model and observations.
Evaluates the measurement function at
theta, computes the residual with respect to the observations, and returns the weighted sum of squared residuals using the inverse covariance matrix (or diagonal uncertainties when no covariance is available).- Parameters:
theta – Current retrieval state vector.
repeat_dims – Indices of repeat dimensions along which to accumulate the chi-squared sum. Only zero or one repeat dimensions are currently supported.
- Returns:
Chi-squared cost value.
- static generate_theta_0(ig: ndarray) ndarray[source]#
Convert the initial guess into a flat 1-D state vector.
- Parameters:
ig – Initial guess, which may be a scalar, 1-D array, or 2-D array (one row per measurement location).
- Returns:
Flat 1-D initial state vector.
- lnprob(theta: ndarray) float[source]#
Compute the log posterior probability for state vector
theta.Evaluates the log prior and the log likelihood and returns their sum. Returns
-np.infif the prior is not finite attheta.- Parameters:
theta – Current retrieval state vector.
- Returns:
Log posterior probability.
- reshape_outputs(x: ndarray, u_x: ndarray, corr_x: ndarray | None) tuple[source]#
Reshape flat retrieval outputs back to the initial-guess shape.
- Parameters:
x – Flat retrieved state vector.
u_x – Flat uncertainties of the retrieved state vector.
corr_x – Correlation matrix of the retrieved state vector, or
None. Reshaping of correlation matrices is not yet implemented; a warning is emitted whencorr_xis notNone.
- Returns:
Tuple of
(x, u_x, corr_x)reshaped to the initial-guess shape.
- run_retrieval(retrieval_inputs: RetrievalInput, *args, **kwargs)[source]#
Execute the retrieval algorithm.
- Parameters:
retrieval_inputs – Object encapsulating all inputs needed for the retrieval.