Reduced Order Modeling for Inverse Problems#

pyoed.assimilation.extras.reduced_order_modeling.ReducedHessian()

Base class implementing Reduced-Order approximation of the Hessian of the negative-log-posterior function in DA.i

pyoed.assimilation.extras.reduced_order_modeling.SVDReducedHessian(...)

Reduced-Order Approximation of the Hessian (of the posterior negative-log) using standard Singular Value Decomposition.

pyoed.assimilation.extras.reduced_order_modeling.NystromRandomizedHessian(...)

An implementation that enables creating randomized approximation for a forward model once, and thus enable reutilizing it efficiently

This utility mnodule provides implementations to aid in reducing the computaitonal cost of solving data assimilation and inverse problems. This includes, reduced order modeling and randmization for matrix-vector approximations, etc.

class ReducedHessian[source]#

Bases: ABC

Base class implementing Reduced-Order approximation of the Hessian of the negative-log-posterior function in DA.i

abstract array()[source]#

Return an array representation of the reduced-order Hessian

abstract array_inverse()[source]#

Return an array representation of the the inverse of the reduced-order Hessian

abstract matvec()[source]#

Return the matrix-vector product of the reduced-order Hessian by a vector

abstract initialize()[source]#

Re-Create/Re-Initialize the reduced-order Hessian

class SVDReducedHessian(inverse_problem, rank_p=50, data_misfit_only=False, eval_at=None, random_seed=None, verbose=False)[source]#

Bases: ReducedHessian, RandomNumberGenerationMixin

Reduced-Order Approximation of the Hessian (of the posterior negative-log) using standard Singular Value Decomposition. This can be used to speed up inverse applications, but it still is expensive to carry out. Yet, it is valid for Hessian with singular values those do not decay quickly.

Parameters:
  • inverse_problem – the inverse problem to use (a variational filter or smoother) e.g., a 4D-Var smoother instance

  • rank_p (int) – requested rank of the reduced order Hessian approximation (Number of singular values to keep.) If None, all singular values are kept (Full Hessian).

  • data_misfit_only (bool)

  • eval_at – point to approximate/linearize the Hessian at (optional; discarded for linear problems)

  • verbose (bool) – flag to control screen output verbosity

Returns:

an instance of NystromRandomizedHessian

__init__(inverse_problem, rank_p=50, data_misfit_only=False, eval_at=None, random_seed=None, verbose=False)[source]#
initialize(Hessian_matvec=None, eval_at=None, data_misfit_only=None, verbose=False)[source]#

Use the associated settings to generate/update the POD reduced-order approximation of the Hessian All the arguments here are optional, and if not explicitly provided, are replaced with internal values set upon initilization (or if modified explicitly) check properties

Parameters:
  • Hessian_matvec

  • eval_at

  • data_misfit_only

array(eval_at=None, data_misfit_only=False, verbose=False)[source]#

Construct an array repersentatiton of the reduced Hessian

array_inverse(eval_at=None, data_misfit_only=False, verbose=False)[source]#

Construct an array repersentatiton of the reduced Hessian

matvec(state, eval_at=None, data_misfit_only=None, verbose=False)[source]#
Return the product of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

Parameters:
  • state – initial state/guess of the model state/parameter

  • eval_at – state at which the Hessian is evaluated (passed to the model adjoint)

  • data_misfit_only (bool) – if True the prior term of the Hessian is discarded, and only the data-misfit term is evaluated

  • verbose (bool) – flag to control screen output verbosity

Returns:

estimate of the product of the inverse of the posterior covariance (of the linearized problem) with a state vector

apply(state, eval_at=None, data_misfit_only=None, verbose=False)#
Return the product of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

Parameters:
  • state – initial state/guess of the model state/parameter

  • eval_at – state at which the Hessian is evaluated (passed to the model adjoint)

  • data_misfit_only (bool) – if True the prior term of the Hessian is discarded, and only the data-misfit term is evaluated

  • verbose (bool) – flag to control screen output verbosity

Returns:

estimate of the product of the inverse of the posterior covariance (of the linearized problem) with a state vector

Hessian_matvec(state, eval_at=None, data_misfit_only=None, verbose=False)#
Return the product of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

Parameters:
  • state – initial state/guess of the model state/parameter

  • eval_at – state at which the Hessian is evaluated (passed to the model adjoint)

  • data_misfit_only (bool) – if True the prior term of the Hessian is discarded, and only the data-misfit term is evaluated

  • verbose (bool) – flag to control screen output verbosity

Returns:

estimate of the product of the inverse of the posterior covariance (of the linearized problem) with a state vector

inv_matvec(state, eval_at=None, data_misfit_only=None, verbose=False)[source]#
Return the product of the Inverse of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

Hessian_inv_matvec(state, eval_at=None, data_misfit_only=None, verbose=False)#
Return the product of the Inverse of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

test_accuracy(sample_size=10, verbose=False, test_inverse_Hessian=True)[source]#

Test the accuracy of the constructed reduced-order Hessian approximation 1- Generate random vectors and evaluate Hessian matvec and Hessian inv matvec (both full and reduced order approxiamtion) 2- show infinity norm of the difference magnitude;

By default, this function tests the accuracy of the Hessian-inverse matrix vector product. set test_inverse_Hessian to test Hessian instead of the inverse

property inverse_problem#

Pointer to the underlying inverse_problem (which gives access to all other elements; model, error models, observation operator, etc.)

property verbose#

Evaluate the data-misfit term of the Hessian only

property data_misfit_only#

Evaluate the data-misfit term of the Hessian only

property state_size#
property rank_p#
property linearize_at#
class NystromRandomizedHessian(inverse_problem, rank_p=20, over_sampling=15, data_misfit_only=True, random_seed=None, verbose=False)[source]#

Bases: ReducedHessian, RandomNumberGenerationMixin

An implementation that enables creating randomized approximation for a forward model once, and thus enable reutilizing it efficiently

Parameters:
  • inverse_problem – the inverse problem to use (a variational filter or smoother) e.g., a 4D-Var smoother instance

  • rank_p (int) – requested rank of the reduced order Hessian approximation

  • over_sampling (int)

  • data_misfit_only (bool)

  • verbose (bool) – flag to control screen output verbosity

Returns:

an instance of NystromRandomizedHessian

__init__(inverse_problem, rank_p=20, over_sampling=15, data_misfit_only=True, random_seed=None, verbose=False)[source]#
initialize()[source]#

Use the associated settings to generate/update the randomized approximation of the Hessian

array(eval_at=None, data_misfit_only=False, verbose=False)[source]#

Construct an array repersentatiton of the reduced Hessian

array_inverse(eval_at=None, data_misfit_only=False, verbose=False)[source]#

Construct an array repersentatiton of the reduced Hessian

matvec(state, eval_at=None, data_misfit_only=False, verbose=False)[source]#
Return the product of the Randomized-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’. Here, we use a two-pass algorithm for GN-Hessian approximation

Parameters:
  • state – initial state/guess of the model state/parameter

  • eval_at – state at which the Hessian is evaluated (passed to the model adjoint)

  • data_misfit_only (bool) – if True the prior term of the Hessian is discarded, and only the data-misfit term is evaluated

  • verbose (bool) – flag to control screen output verbosity

Returns:

estimate of the product of the inverse of the posterior covariance (of the linearized problem) with a state vector

Hessian_matvec(state, eval_at=None, data_misfit_only=False, verbose=False)#
Return the product of the Randomized-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’. Here, we use a two-pass algorithm for GN-Hessian approximation

Parameters:
  • state – initial state/guess of the model state/parameter

  • eval_at – state at which the Hessian is evaluated (passed to the model adjoint)

  • data_misfit_only (bool) – if True the prior term of the Hessian is discarded, and only the data-misfit term is evaluated

  • verbose (bool) – flag to control screen output verbosity

Returns:

estimate of the product of the inverse of the posterior covariance (of the linearized problem) with a state vector

inv_matvec(state, eval_at=None, data_misfit_only=None, verbose=False)[source]#
Return the product of the Inverse of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

Hessian_inv_matvec(state, eval_at=None, data_misfit_only=None, verbose=False)#
Return the product of the Inverse of the Reduced-Hessian-Approxmiation of 4D-Var objective

(inverse of posterior covariance) with a vector ‘state’.

property inverse_problem#

Pointer to the underlying inverse_problem (which gives access to all other elements; model, error models, observation operator, etc.)

property verbose#

Evaluate the data-misfit term of the Hessian only

property data_misfit_only#

Evaluate the data-misfit term of the Hessian only

property rank_p#
property over_sampling#