pysdic.Parametrization.encode#

Parametrization.encode(p_i, *, dp=False, **kwargs)[source]#

Apply the parametrization to the given parameters \(\vec{p_i} \in \mathbb{R}^{n_i}\) to return the encoded parameters \(\vec{p_o} \in \mathbb{R}^{n_o}\).

\[\vec{p_o} = P(\vec{p_i})\]

Important

  • The encode method can only be used if the parametrization implements it (i.e., has_encode must be True).

  • The jacobian dp can only be computed if the parametrization supports it (i.e., has_encode_dp must be True).

Note

This method is called by __call__ to allow the parametrization to be applied directly to parameters using the syntax parametrization(p_i).

Parameters:
  • p_i (ArrayLike) – Input parameters \(\vec{p_i}\) with shape \((n_i,)\) to which the parametrization will be applied.

  • dp (bool, optional (default: False)) – Whether to compute the Jacobian with respect to the input parameters. (i.e., \(\mathbf{J}_p = \frac{\partial P}{\partial \vec{p_i}}\)).

  • **kwargs – Additional arguments passed to the underlying _encode method.

Returns:

Contains the encoded parameters accessible using the p attribute with shape \((n_o,)\), and the Jacobian matrix with respect to the input parameters accessible using the jacobian_dp attribute with shape \((n_o, n_i)\) if computed, or None otherwise.

Return type:

pysdic.ParametrizationResult

Notes

The jacobian dp has the following structure:

jacobian_dp[0, 0]  # ∂p_o1/∂p_i1
jacobian_dp[0, 1]  # ∂p_o1/∂p_i2
jacobian_dp[1, 0]  # ∂p_o2/∂p_i1
jacobian_dp[1, 1]  # ∂p_o2/∂p_i2
jacobian_dp[j, i]  # ∂p_oj/∂p_ii

Developers notes#

Subclasses must implement the _encode method. This method should:

  1. Accept a NumPy array of shape \((n_i,)\).

  2. Return \(\vec{p_o}\) Numpy array of shape \((n_o,)\) and optionally the Jacobian matrix with respect to the input parameters as a 2D array of shape \((n_o, n_i)\) if dp is True, or None otherwise.

The shapes of the outputs of _encode are checked, and a RuntimeError is raised if they do not match the expected shapes.