### OptDMD Initialization Example Source: https://pydmd.github.io/PyDMD/optdmd.html Instantiate the OptDMD class with custom parameters for factorization and rank truncation. The default factorization is 'evd'. ```python from pydmd import OptDMD dmd = OptDMD(factorization='svd', svd_rank=0.9, tlsq_rank=2, opt=True) ``` -------------------------------- ### Example Usage of ModesSelectors Source: https://pydmd.github.io/PyDMD/_modules/pydmd/dmd_modes_tuner.html Demonstrates how to use `ModesSelectors` with `select_modes` to select DMD modes based on integral contributions. Requires importing `ModesSelectors` and `select_modes`. ```python >>> from pydmd.dmd_modes_tuner import ModesSelectors, select_modes >>> select_modes(dmd, ModesSelectors.integral_contribution(x)) ``` -------------------------------- ### HAVOK Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/havok.html Initializes the HAVOK model with precomputed Koopman operator components and input data. This setup is crucial before performing predictions or reconstructions. ```python # Set the input data information. self._snapshots = X self._ho_snapshots = hankel_matrix self._time = time # Set the SVD information. self._singular_vecs = U self._singular_vals = s self._delay_embeddings = V # Save the full HAVOK operator. self._havok_operator = havok_operator self._eigenvalues = np.linalg.eig( havok_operator[: -self._num_chaos, : -self._num_chaos] )[0] return self ``` -------------------------------- ### Example of Invalid Stable Modes Configuration Source: https://pydmd.github.io/PyDMD/_modules/pydmd/dmd_modes_tuner.html Demonstrates an invalid configuration for `stable_modes` where both `max_distance_from_unity` and `max_distance_from_unity_inside` are provided, which is not allowed. ```python >>> # this is not allowed >>> stable_modes(max_distance_from_unity=1.e-3, ... max_distance_from_unity_inside=1.e-4) ``` -------------------------------- ### VarProDMD Initialization Parameters Source: https://pydmd.github.io/PyDMD/_modules/pydmd/varprodmd.html Demonstrates the initialization of the VarProDMD class with various parameters controlling SVD rank, exactness, eigenvalue sorting, and compression. ```python svd_rank: Union[float, int] = 0, exact: bool = False, sorted_eigs: Union[bool, str] = False, compression: float = 0.0, optargs: Dict[str, Any] = None, ``` -------------------------------- ### Get Index Slices Example Source: https://pydmd.github.io/PyDMD/havok.html Demonstrates how to compute the beginning and ending indices for consecutive sets of indices in an array, useful for plotting or data segmentation. ```python >>> a = np.array([2, 3, 4, 5, 10, 11, 12, 25, 26, 28]) >>> _get_index_slices(a, min_jump_dist=2) [(2, 5), (10, 12), (25, 28)] ``` -------------------------------- ### Install PyDMD from Source Source: https://pydmd.github.io/PyDMD/index.html Installs PyDMD from its source code using pip. ```bash pip install -e . ``` -------------------------------- ### ParametricDMD Class Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/paramdmd.html Demonstrates the initialization of the ParametricDMD class, showing how to configure it for monolithic or partitioned approaches and specify optional arguments for DMD fitting. ```python class ParametricDMD: """ Implementation of the parametric Dynamic Mode Decomposition proposed in arXiv:2110.09155v1. Both the *monolithic* and *partitioned* methods are available, see the documentation of the parameter `dmd` for more details. :param dmd: Instance(s) of :class:`dmdbase.DMDBase`, used by the paramtric DMD for the prediction of future spatial modal coefficients. If `dmd` is a `list` the *partitioned* approach is selected, in this case the number of parameters in the training set should be equal to the number of DMD instances provided. If `dmd` is not a list, we employ the monolithic approach. :type dmd: DMDBase or list :param spatial_pod: Instance of an object usable for the generation of a ROM of the dataset (see for instance the class `POD `_ from the Python library `EZyRB `_). :param approximation: An interpolator following the standard learning-prediction pattern (`fit()` -> `predict()`). For some convenient wrappers see those implemented in `EZyRB `_). :param bool light: Whether this instance should be light or not. A light instance uses less memory since it caches a smaller number of resources. Setting `light=True` might invalidate several properties (see also :meth:`training_modal_coefficients`). :param dmd_fit_args: Positional arguments to be passed to the `fit` method of the given DMD instance. :param dmd_fit_kwargs: Keyword arguments to be passed to the `fit` method of the given DMD instance. """ def __init__( self, dmd, spatial_pod, approximation, light=False, dmd_fit_args=None, dmd_fit_kwargs=None, ): self._dmd = dmd self._spatial_pod = spatial_pod self._approximation = approximation if dmd_fit_args is None: dmd_fit_args = tuple() if not isinstance(dmd_fit_args, (list, tuple)): raise TypeError("Expected list, tuple or None for dmd_fit_args") self._dmd_fit_args = dmd_fit_args if dmd_fit_kwargs is None: dmd_fit_kwargs = {} if not isinstance(dmd_fit_kwargs, dict): raise TypeError("Expected dict or None for dmd_fit_kwargs") self._dmd_fit_kwargs = dmd_fit_kwargs self._training_parameters = None self._parameters = None self._ntrain = None self._time_instants = None self._space_dim = None self._light = light self._training_modal_coefficients = None ``` -------------------------------- ### Install PyDMD from source Source: https://pydmd.github.io/PyDMD/_sources/index.rst.txt Installs PyDMD in editable mode from the cloned source code. ```bash pip install -e . ``` -------------------------------- ### Install PyDMD using pip Source: https://pydmd.github.io/PyDMD/_sources/index.rst.txt Installs the latest released version of PyDMD from PyPI. ```bash pip install pydmd ``` -------------------------------- ### VarProOperator Constructor Parameters Source: https://pydmd.github.io/PyDMD/_modules/pydmd/varprodmd.html Explains the parameters for initializing the VarProOperator. Key parameters include `svd_rank` for determining the optimal rank, `exact` for choosing between exact and projected space computation, `sorted_eigs` for eigenvalue sorting criteria, `compression` for sample selection, and `optargs` for SciPy's least squares optimizer. ```python def __init__( self, svd_rank: Union[float, int], exact: bool, sorted_eigs: Union[bool, str], compression: float, optargs: Dict[str, Any], ): r""" VarProOperator constructor. :param svd_rank: Desired SVD rank. If rank :math:`r = 0`, the optimal rank is determined automatically. If rank is a float s.t. :math:`0 < r < 1`, the cumulative energy of the singular values is used to determine the optimal rank. If rank is an integer and :math:`r > 0`, the desired rank is used iff possible. :type svd_rank: Union[float, int] :param exact: Perform computations in original state space if `exact=True`, else perform optimization in projected (low dimensional) space. :type exact: bool :param sorted_eigs: Sort eigenvalues. If `sorted_eigs=True`, the variance of the absolute values of the complex eigenvalues :math:`\sqrt{\omega_i \cdot \bar{\omega}_i}`, the variance absolute values of the real parts :math:`\left|\Re\{{\omega_i}\}\right|` and the variance of the absolute values of the imaginary parts :math:`\left|\Im\{{\omega_i}\}\right|` is computed. The eigenvalues are then sorted according to the highest variance (from highest to lowest). If `sorted_eigs=False`, no sorting is performed. If the parameter is a string and set to sorted_eigs='auto', the eigenvalues are sorted accoring to the variances of previous mentioned quantities. If `sorted_eigs='real'` the eigenvalues are sorted w.r.t. the absolute values of the real parts of the eigenvalues (from highest to lowest). If `sorted_eigs='imag'` the eigenvalues are sorted w.r.t. the absolute values of the imaginary parts of the eigenvalues (from highest to lowest). If `sorted_eigs='abs'` the eigenvalues are sorted w.r.t. the magnitude of the eigenvalues :math:`\left(\sqrt{\omega_i \cdot \bar{\omega}_i}\right)` (from highest to lowest). :type sorted_eigs: Union[bool, str] :param compression: If libary compression :math:`c = 0`, all samples are used. If :math:`0 < c < 1`, the best fitting :math:`\lfloor \left(1 - c\right)m\rfloor` samples are selected. :type compression: float :param optargs: Arguments for 'least_squares' optimizer. Use `OPT_DEF_ARGS` as starting point. :type optargs: Dict[str, Any] """ super().__init__(svd_rank, exact, False, None, sorted_eigs, False) self._sorted_eigs = sorted_eigs self._svd_rank = svd_rank self._exact = exact self._optargs: Dict[str, Any] = optargs self._compression: float = compression self._modes: np.ndarray = None self._eigenvalues: np.ndarray = None ``` -------------------------------- ### ActivationBitmaskProxy Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/dmdbase.html Initializes the proxy with the DMD operator and amplitudes. It sets up internal storage for original values and applies an initial bitmask. ```python proxy = ActivationBitmaskProxy(dmd_operator, amplitudes) ``` -------------------------------- ### reconstructed_data Source: https://pydmd.github.io/PyDMD/mrdmd.html Get the reconstructed data. ```APIDOC ## reconstructed_data ### Description Get the reconstructed data. ### Returns - **numpy.ndarray** - the matrix that contains the reconstructed snapshots. ``` -------------------------------- ### CDMD Initialization and Fit Method Source: https://pydmd.github.io/PyDMD/_modules/pydmd/cdmd.html Explains the parameters for initializing the CDMD class and how to use the `fit` method to compute the Dynamic Modes Decomposition. ```APIDOC ## CDMD Class ### Description Initializes the Compressed Dynamic Mode Decomposition (CDMD) object. This class allows for compressed snapshots and various options for computing the DMD operator. ### Parameters * **svd_rank** (int or float) - Argument for truncation. If float between 0 and 1, the rank is the number of the biggest singular values that are needed to reach the 'energy' specified by `svd_rank`. If -1, no truncation is computed. * **tlsq_rank** (int) - Rank truncation for Total Least Square. Default is 0, meaning TLSQ is not applied. * **compression_matrix** ({'linear', 'sparse', 'uniform', 'sample'} or numpy.ndarray) - The matrix that pre-multiplies the snapshots matrix to compress it. If a numpy.ndarray, its dimension must be (`nsnaps`, `ndim`). Default value is '`uniform`'. * **opt** (bool or int) - Argument to control the computation of DMD modes amplitudes. See :class:`DMDBase`. Default is False. * **rescale_mode** ({'auto'} or None or numpy.ndarray) - Scales Atilde before computing its eigendecomposition. None means no rescaling, 'auto' means automatic rescaling using singular values, otherwise the scaling factors. * **forward_backward** (bool) - If True, the low-rank operator is computed like in fbDMD. * **sorted_eigs** ({'real', 'abs'} or False) - Sorts eigenvalues (and modes/dynamics accordingly) by magnitude if 'abs', by real part (and then by imaginary part to break ties) if 'real'. Default: False. * **tikhonov_regularization** (int or float) - Tikhonov parameter for the regularization. If `None`, no regularization is applied, if `float`, it is used as the :math:`\lambda` tikhonov parameter. ### Methods #### `fit(X)` ##### Description Compute the Dynamic Modes Decomposition to the input data. ##### Parameters * **X** (numpy.ndarray or iterable) - The input snapshots. ##### Returns * self - The fitted CDMD object. ``` -------------------------------- ### ParametricDMD _reference_dmd Property Source: https://pydmd.github.io/PyDMD/_modules/pydmd/paramdmd.html Provides access to the reference DMD instance, which is used for properties like `dmd_time` and `dmd_timesteps`. It returns the single DMD instance for monolithic setups or the first DMD instance in the list for partitioned setups. ```python @property def _reference_dmd(self): """ An object used as a reference for several properties like :func:`dmd_time` and :func:`dmd_timesteps`. If this instance is monolithic the returned value is `self._dmd`, otherwise it is the first item of the list `self._dmd`. :return: The object used as a reference. :rtype: pydmd.DMDBase """ if self.is_partitioned: return self._dmd[0] return self._dmd ``` -------------------------------- ### BOP-DMD Initialization Parameters Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Illustrates the various parameters available during the initialization of a BOP-DMD object. These control aspects like SVD rank, projection basis usage, trial configurations, eigenvalue sorting and constraints, and data processing options. ```python init_alpha=None, proj_basis=None, num_trials=0, trial_size=0.6, eig_sort="auto", eig_constraints=None, mode_prox=None, remove_bad_bags=False, bag_warning=100, bag_maxfail=200, varpro_opts_dict=None, real_eig_limit=None, varpro_flag=True, ``` -------------------------------- ### _property _varpro_opts Source: https://pydmd.github.io/PyDMD/bopdmd.html Get the variable projection options. ```APIDOC ## _property _varpro_opts ### Description Get the variable projection options. ### Returns the variable projection options. ### Return type tuple ``` -------------------------------- ### BOP-DMD Class Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Initializes the BOP-DMD class with parameters controlling SVD truncation, computation of the full Koopman operator, and projection usage. Default is not to compute the full operator due to potential high cost. ```python class BOPDMD(DMDBase): """ Bagging, Optimized Dynamic Mode Decomposition. :param svd_rank: The rank for the truncation; If 0, the method computes the optimal rank and uses it for truncation; if positive integer, the method uses the argument for the truncation; if float between 0 and 1, the rank is the number of the biggest singular values that are needed to reach the 'energy' specified by `svd_rank`; if -1, the method does not compute truncation. :type svd_rank: int or float :param compute_A: Flag that determines whether or not to compute the full Koopman operator A. Default is False, do not compute the full operator. Note that the full operator is potentially prohibitively expensive to compute. :type compute_A: bool :param use_proj: Flag that determines the type of computation to perform. If True, fit input data projected onto the first svd_rank POD modes or ``` -------------------------------- ### _property _modes_std Source: https://pydmd.github.io/PyDMD/bopdmd.html Get the modes standard deviation. ```APIDOC ## _property _modes_std ### Description Get the modes standard deviation. ### Returns modes standard deviation. ### Return type numpy.ndarray ``` -------------------------------- ### _property _eigenvalues_std Source: https://pydmd.github.io/PyDMD/bopdmd.html Get the eigenvalues standard deviation. ```APIDOC ## _property _eigenvalues_std ### Description Get the eigenvalues standard deviation. ### Returns eigenvalues standard deviation. ### Return type numpy.ndarray ``` -------------------------------- ### BOPDMDOperator Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Initializes the BOPDMDOperator with various parameters controlling the computation, projection, bagging, and eigenvalue constraints. Use `use_proj=True` to project data onto POD modes for fitting. ```python BOPDMDOperator( compute_A=True, use_proj=False, init_alpha=None, proj_basis=None, num_trials=100, trial_size=0.8, eig_sort="auto", eig_constraints=set(), mode_prox=None, remove_bad_bags=False, bag_warning=100, bag_maxfail=200 ) ``` -------------------------------- ### OptDMD Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/optdmd.html Initializes the OptDMD class with specified factorization, SVD rank, TLSQ rank, and optimization parameters. ```APIDOC ## __init__ ### Description Initializes the OptDMD class. ### Parameters * **factorization** (str): Type of factorization to use ('evd' or 'svd'). Default is 'evd'. * **svd_rank** (int or float): Rank for SVD truncation. If float between 0 and 1, it represents energy threshold. If -1, no truncation is applied. Default is 0. * **tlsq_rank** (int): Rank truncation for Total Least Square computation. Default is 0 (TLSQ not applied). * **opt** (bool or int): Argument to control the computation of DMD modes amplitudes. Default is False. ``` -------------------------------- ### _property _amplitudes_std Source: https://pydmd.github.io/PyDMD/bopdmd.html Get the amplitudes standard deviation. ```APIDOC ## _property _amplitudes_std ### Description Get the amplitudes standard deviation. ### Returns amplitudes standard deviation. ### Return type numpy.ndarray ``` -------------------------------- ### _snapshots_shape Source: https://pydmd.github.io/PyDMD/dmdbase.html Get the original input snapshot shape. ```APIDOC ## _snapshots_shape ### Description Get the original input snapshot shape. ### Returns - input snapshots shape (tuple) ``` -------------------------------- ### Prepare Testing Parameters and Snapshots Source: https://pydmd.github.io/PyDMD/tutorial10paramdmd.html Define testing parameters, some at dishomogeneous distances from training parameters, to assess the model's accuracy. This involves generating corresponding testing snapshots for evaluation. ```python similar_testing_params = [1, 3, 5, 7, 9] testing_params = training_params[similar_testing_params] + np.array( [5 * pow(10, -i) for i in range(2, 7)] ) testing_params_labels = [ str(training_params[similar_testing_params][i - 2]) + "+$5*10^{{-{}}}$".format(i) for i in range(2, 7) ] time_step = t[1] - t[0] N_predict = 40 N_nonpredict = 40 t2 = np.array( [4 * np.pi + i * time_step for i in range(-N_nonpredict + 1, N_predict + 1)] ) xgrid2, tgrid2 = np.meshgrid(x, t2) testing_snapshots = np.array( [f(mu=p, x=xgrid2, t=tgrid2).T for p in testing_params] ) ``` -------------------------------- ### factorization Property Source: https://pydmd.github.io/PyDMD/optdmd.html Gets the factorization method used by the OptDMD instance. ```APIDOC ## factorization ### Description Gets the factorization method used by the OptDMD instance. ``` -------------------------------- ### partial_time_interval Source: https://pydmd.github.io/PyDMD/mrdmd.html Evaluate the start and end time and the period of a given bin. ```APIDOC ## partial_time_interval(level, leaf) ### Description Evaluate the start and end time and the period of a given bin. ### Parameters #### Path Parameters - **level** (int) - Required - the level in the binary tree. - **leaf** (int) - Required - the node id. ### Returns - **dictionary** - the start and end time and the period of the bin ``` -------------------------------- ### Initialize MrDMD with a single DMD instance Source: https://pydmd.github.io/PyDMD/_modules/pydmd/mrdmd.html This example shows how to initialize MrDMD using a single DMD instance (SpDMD in this case) which will be applied to all levels and leaves of the multi-resolution decomposition. The fit method is then called with snapshot data X. ```python >>> # this SpDMD is used for all the levels, for all the leaves >>> MrDMD(dmd=SpDMD(), max_level=5).fit(X) ``` -------------------------------- ### Get Eigenvalue Constraints Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Returns the set of eigenvalue constraints that are currently applied. ```python @property def eig_constraints(self): """ Get the eigenvalue constraints. :return: eigenvalue constraints. :rtype: set(str) """ return self._eig_constraints ``` -------------------------------- ### Initialize MrDMD with a list of DMD instances Source: https://pydmd.github.io/PyDMD/mrdmd.html This example shows how to initialize MrDMD with a list of DMD instances. The list is structured such that the first three instances have svd_rank=10, and subsequent instances have svd_rank=2, corresponding to different levels. ```python >>> dmds_list = [DMD(svd_rank=10) for i in range(6) if i < 3 ... else DMD(svd_rank=2)] >>> MrDMD(dmd=dmds_list, max_level=5).fit(X) ``` -------------------------------- ### Initialize Kernelized Extended DMD Source: https://pydmd.github.io/PyDMD/edmd.html Instantiate the Kernelized Extended DMD class with various parameters for SVD rank, TLSQ rank, optimization, kernel metric, and kernel parameters. ```python from pydmd.edmd import EDMD # Example with default parameters edm = EDMD() # Example with custom parameters edm = EDMD(svd_rank=0.9, tlsq_rank=2, opt=True, kernel_metric='rbf', kernel_params={'gamma': 0.1}) ``` -------------------------------- ### modes Property Source: https://pydmd.github.io/PyDMD/optdmd.html Gets the matrix containing the Dynamic Modes, stored column-wise. ```APIDOC ## modes ### Description Get the matrix containing the DMD modes, stored by column. ### Returns the matrix containing the DMD modes. ### Return type numpy.ndarray ``` -------------------------------- ### _snapshots_y Source: https://pydmd.github.io/PyDMD/dmdbase.html Get the input left-hand side data (space flattened) if given. ```APIDOC ## _snapshots_y ### Description Get the input left-hand side data (space flattened) if given. ### Returns - matrix that contains the flattened left-hand side snapshots (numpy.ndarray) ``` -------------------------------- ### VarProDMD Constructor Parameters Source: https://pydmd.github.io/PyDMD/varprodmd.html Defines the parameters for the VarProDMD constructor, including SVD rank, exact projection, eigenvalue sorting, sample compression, and optimizer arguments. ```python _class _VarProDMD(_svd_rank : float | int = 0_, _exact : bool = False_, _sorted_eigs : bool | str = False_, _compression : float = 0.0_, _optargs : Dict[str, Any] | None = None_)[source] Bases: `DMDBase` ``` -------------------------------- ### Initialize VarProDMD Source: https://pydmd.github.io/PyDMD/_modules/pydmd/varprodmd.html Initializes the VarProDMD object. It takes parameters for SVD rank, exactness, sorted eigenvalues, compression, and optimizer arguments. ```python self._Atilde = VarProOperator( svd_rank, exact, sorted_eigs, compression, optargs ) self._optres: OptimizeResult = None self._snapshots_holder: Snapshots = None self._indices: np.ndarray = None self._modes_activation_bitmask_proxy = None ``` -------------------------------- ### reconstructed_data Source: https://pydmd.github.io/PyDMD/havok.html Get the reconstructed data. This property returns the matrix containing the reconstructed snapshots. ```APIDOC ## reconstructed_data ### Description Get the reconstructed data. ### Returns * **numpy.ndarray** - the matrix that contains the reconstructed snapshots. ``` -------------------------------- ### reconstructed_embeddings Source: https://pydmd.github.io/PyDMD/havok.html Get the reconstructed time-delay embeddings. This property returns the matrix containing the reconstructed embeddings. ```APIDOC ## reconstructed_embeddings ### Description Get the reconstructed time-delay embeddings. ### Returns * **numpy.ndarray** - the matrix that contains the reconstructed embeddings. ``` -------------------------------- ### VarProDMD Constructor Source: https://pydmd.github.io/PyDMD/_modules/pydmd/varprodmd.html Initializes the VarProDMD object with specified parameters for SVD rank, exact projection, eigenvalue sorting, compression, and optional arguments for the optimization solver. ```APIDOC ## VarProDMD(svd_rank: Union[float, int] = 0, exact: bool = False, sorted_eigs: Union[bool, str] = False, compression: float = 0.0, optargs: Dict[str, Any] = None) ### Description Initializes the VarProDMD object. This class implements the Variable Projection method for DMD, reformulating the problem to handle complex residuals and Jacobians by transforming them into real numbers. It also uses simplifications like outer products to avoid sparse matrices. ### Parameters * **svd_rank** (Union[float, int], optional): Desired SVD rank. Defaults to 0. - If 0, the optimal rank is determined automatically. - If a float between 0 and 1, the cumulative energy of singular values determines the rank. - If an integer > 0, the desired rank is used if possible. * **exact** (bool, optional): If `False`, performs variable projection in a low-dimensional space. If `True`, the optimization is performed in the original space. Defaults to `False`. * **sorted_eigs** (Union[bool, str], optional): Determines how eigenvalues are sorted. Defaults to `False` (no sorting). - `True` or `'auto'`: Sorts eigenvalues based on the variance of their absolute values, real parts, or imaginary parts. - `'real'`: Sorts by the absolute values of the real parts (highest to lowest). - `'imag'`: Sorts by the absolute values of the imaginary parts (highest to lowest). - `'abs'`: Sorts by the magnitude of the eigenvalues (highest to lowest). * **compression** (float, optional): Compression parameter. If 0, all samples are used. If between 0 and 1, it relates to the selection of indices. Defaults to 0.0. * **optargs** (Dict[str, Any], optional): Additional arguments to be passed to SciPy's nonlinear least squares solver. Defaults to `None`. ``` -------------------------------- ### SpDMD Class Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/spdmd.html Initializes the SpDMD class with various parameters to control the sparsity-promoting dynamic mode decomposition. Users can configure SVD truncation, total least squares rank, exact DMD computation, mode amplitude optimization, rescaling, forward-backward DMD, eigenvalue sorting, ADMM convergence criteria, sparsity promotion level, verbosity, and memory management. ```APIDOC ## SpDMD ### Description Implements Sparsity-Promoting Dynamic Mode Decomposition. Promotes solutions having an high number of amplitudes set to zero (i.e. *sparse solutions*). ### Parameters * **svd_rank**: The rank for the truncation; If 0, the method computes the optimal rank and uses it for truncation; if positive integer, the method uses the argument for the truncation; if float between 0 and 1, the rank is the number of the biggest singular values that are needed to reach the 'energy' specified by `svd_rank`; if -1, the method does not compute truncation. * **tlsq_rank**: Rank truncation computing Total Least Square. Default is 0, that means TLSQ is not applied. * **exact**: Flag to compute either exact DMD or projected DMD. Default is True. * **opt**: Argument to control the computation of DMD modes amplitudes. See :class:`DMDBase`. Default is False. * **rescale_mode**: Scale Atilde as shown in 10.1016/j.jneumeth.2015.10.010 (section 2.4) before computing its eigendecomposition. None means no rescaling, 'auto' means automatic rescaling using singular values, otherwise the scaling factors. * **forward_backward**: If True, the low-rank operator is computed like in fbDMD (reference: https://arxiv.org/abs/1507.02264). Default is False. * **sorted_eigs**: Sort eigenvalues (and modes/dynamics accordingly) by magnitude if `sorted_eigs='abs'`, by real part (and then by imaginary part to break ties) if `sorted_eigs='real'`. Default: False. * **abs_tolerance**: Controls the convergence of ADMM. See :func:`_loop_condition` for more details. * **rel_tolerance**: Controls the convergence of ADMM. See :func:`_loop_condition` for more details. * **max_iterations**: The maximum number of iterations performed by ADMM, after that the algorithm is stopped. * **rho**: Controls the convergence of ADMM. For a reference on the optimal value for `rho` see 10.1109/TAC.2014.2354892 or 10.3182/20120914-2-US-4030.00038. * **gamma**: Controls the level of "promotion" assigned to sparse solution. Increasing `gamma` will result in an higher number of zero-amplitudes. * **verbose**: If `False`, the information provided by SpDMD (like the number of iterations performed by ADMM) are not shown. * **enforce_zero**: If `True` the DMD amplitudes which should be set to zero according to the solution of ADMM are manually set to 0 (since we solve a sparse linear system to find the optimal vector of DMD amplitudes very small terms may survive in some cases). * **release_memory**: If `True` the intermediate matrices computed by the algorithm are deleted after the termination of a call to :func:`fit`. * **zero_absolute_tolerance**: Tolerance for considering values as zero in the context of sparsity enforcement. ``` -------------------------------- ### Get DMD Operator Source: https://pydmd.github.io/PyDMD/_modules/pydmd/dmdbase.html Returns the instance of the DMDOperator class, which holds the computed DMD operator. ```python @property def operator(self): """ Get the instance of DMDOperator. :return: the instance of DMDOperator :rtype: DMDOperator """ return self._Atilde ``` -------------------------------- ### Run Rank Sensitivity Analysis (Case 1) Source: https://pydmd.github.io/PyDMD/tutorial8comparison.html Executes the rank-sensitivity analysis on a given dynamic system and training data. The output contains results for later use. ```python output = rank_sensitvity(dsys, x_train.T) # Keep for later use. long_time_series_optdmd_train, long_time_series_optdmd_test = output[2], output[3] ``` -------------------------------- ### Get Modes Standard Deviation Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Retrieves the standard deviation of the modes. This property can only be accessed after the model has been fitted. ```python @property def modes_std(self): """ Get the modes standard deviation. :return: modes standard deviation. :rtype: numpy.ndarray """ if not self.fitted: raise ValueError("You need to call fit() before.") return self.operator.modes_std ``` -------------------------------- ### Get Amplitudes Standard Deviation Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Retrieves the standard deviation of the amplitudes. This requires the model to be fitted first. ```python @property def amplitudes_std(self): """ Get the amplitudes standard deviation. :return: amplitudes standard deviation. :rtype: numpy.ndarray """ if not self.fitted: raise ValueError("You need to call fit() before.") return self.operator.amplitudes_std ``` -------------------------------- ### BOPDMD Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Initializes the BOP-DMD class with various parameters to control the decomposition process, including SVD rank, projection usage, eigenvalue constraints, and trial-specific settings for bagged optimization. ```APIDOC ## BOPDMD Constructor ### Description Initializes the Bagged Optimized Dynamic Mode Decomposition (BOP-DMD) object. This class allows for a more robust DMD analysis by performing multiple randomized trials and averaging the results. ### Method __init__ ### Parameters - **svd_rank** (int) - Optional - The rank of the SVD to be used for approximating the Koopman operator. If 0, the rank is automatically determined. Default is 0. - **compute_A** (bool) - Optional - If True, the Koopman operator A is computed and returned. Default is False. - **use_proj** (bool) - Optional - If True, the DMD modes are projected onto the columns of `proj_basis` if provided, or POD modes if not. If False, the full input data is used. Default is True. - **init_alpha** (numpy.ndarray) - Optional - Initial guess for the continuous-time DMD eigenvalues. If not provided, one is computed via a trapezoidal rule approximation. Default is None. - **proj_basis** (numpy.ndarray) - Optional - Orthogonal basis for projection, where each column contains a basis mode. If not provided, POD modes are used. Default is None. - **num_trials** (int) - Optional - Number of BOP-DMD trials to perform. If positive, multiple trials are run. Otherwise, standard optimized DMD is performed. Default is 0. - **trial_size** (int or float) - Optional - Size of the randomly selected subset of observations for each trial. If int, `trial_size` observations are used. If float between 0 and 1, `int(trial_size * m)` observations are used (where m is total data points). Default is 0.6. - **eig_sort** ({"real", "imag", "abs", "auto"}) - Optional - Method to sort eigenvalues and modes. Options include sorting by real part, imaginary part, magnitude, or automatically based on variance. Default is "auto". - **eig_constraints** (set(str) or function) - Optional - Set of desired DMD operator eigenvalue constraints (e.g., "stable", "imag", "conjugate_pairs"), or a custom constraint function. Default is None. - **mode_prox** (function) - Optional - Proximal operator function to apply to the DMD modes. Applied during iteration if `use_proj` is False, or after projection if `use_proj` is True. Default is None. - **remove_bad_bags** (bool) - Optional - If True, excludes results from bagging trials that did not converge. Default is False. - **bag_warning** (int) - Optional - Number of consecutive non-converged trials before a warning is issued (active when `remove_bad_bags=True`). Negative values disable warnings. Default is 100. - **bag_maxfail** (int) - Optional - Number of consecutive non-converged trials before the fit terminates (active when `remove_bad_bags=True`). Negative values disable stopping. Default is 200. - **varpro_opts_dict** (dict) - Optional - Dictionary of parameters for variable projection (e.g., `init_lambda`, `maxiter`, `tol`). Default values are used for unspecified parameters. See `BOPDMDOperator` documentation for details. Default is an empty dictionary. - **real_eig_limit** (float) - Optional - Value limiting real eigenvalues. Only effective when "limited" is an eigenvalue constraint. Default is None. - **varpro_flag** (bool) - Optional - Indicates whether to use true variable projection or an approximation of exact DMD. Default is True. ``` -------------------------------- ### Get Koopman Operator A Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Retrieves the full Koopman operator A. Ensure the model has been fitted before calling this method. ```python def A(self): """ Get the full Koopman operator A. :return: the full Koopman operator A. :rtype: numpy.ndarray """ if not self.fitted: raise ValueError("You need to call fit() before.") return self.operator.A ``` -------------------------------- ### _HAVOK Source: https://pydmd.github.io/PyDMD/havok.html Initializes the Havok analysis module. It allows for various configurations of Hankel matrix construction and truncation for dynamical system analysis. ```APIDOC ## _HAVOK ### Description Initializes the Havok analysis module. It allows for various configurations of Hankel matrix construction and truncation for dynamical system analysis. ### Parameters * **svd_rank** (int or float) – The rank for truncation. If 0, computes optimal rank. If positive integer, uses the argument. If float between 0 and 1, uses singular values to reach specified 'energy'. If -1, no truncation is performed. * **delays** (int) – The number of consecutive time-shifted copies of the data to use when building Hankel matrices. For n-dimensional data, the Hankel matrix will have n * delays rows. * **lag** (int) – The number of time steps between each time-shifted copy of data in the Hankel matrix. Each row will be separated by a time-step of dt * lag. * **num_chaos** (int) – The number of forcing terms to use in the HAVOK model. * **structured** (bool) – Whether to perform standard HAVOK or structured HAVOK (sHAVOK). If True, sHAVOK is performed; otherwise, HAVOK is performed. sHAVOK cannot be performed with a BOPDMD model. * **lstsq** (bool) – Method used for computing the HAVOK operator if a DMD method is not provided. If True, least-squares is used; otherwise, the pseudo-inverse is used. Ignored if dmd is provided. * **dmd** (DMDBase) – DMD instance used to compute the HAVOK operator. If None, least-squares or pseudo-inverse is used based on lstsq. ``` -------------------------------- ### time_window_frequency Source: https://pydmd.github.io/PyDMD/mrdmd.html Get the frequencies relative to the modes of the bins embedded (partially or totally) in a given time window. ```APIDOC ## time_window_frequency(t0, tend) ### Description Get the frequencies relative to the modes of the bins embedded (partially or totally) in a given time window. ### Parameters #### Query Parameters - **t0** (float) - Required - start time of the window. - **tend** (float) - Required - end time of the window. ### Returns - **numpy.ndarray** - the frequencies for that time window. ``` -------------------------------- ### Initialize ModesTuner Source: https://pydmd.github.io/PyDMD/_modules/pydmd/dmd_modes_tuner.html Initializes the ModesTuner with one or more DMD instances. Can work in-place or on copies. ```python from pydmd.dmd_modes_tuner import ModesTuner from pydmd import DMD from copy import deepcopy dmd = DMD() mtuner = ModesTuner(dmd) ``` -------------------------------- ### time_window_eigs Source: https://pydmd.github.io/PyDMD/mrdmd.html Get the eigenvalues relative to the modes of the bins embedded (partially or totally) in a given time window. ```APIDOC ## time_window_eigs(t0, tend) ### Description Get the eigenvalues relative to the modes of the bins embedded (partially or totally) in a given time window. ### Parameters #### Query Parameters - **t0** (float) - Required - start time of the window. - **tend** (float) - Required - end time of the window. ### Returns - **numpy.ndarray** - the eigenvalues for that time window. ``` -------------------------------- ### OptDMD Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/optdmd.html Initializes the OptDMD class with specified factorization, SVD rank, TLSQ rank, and optimization settings. The `svd_rank` controls truncation based on singular value energy, `tlsq_rank` is for Total Least Square truncation, and `opt` influences the computation of DMD modes amplitudes. ```python def __init__(self, factorization="evd", svd_rank=0, tlsq_rank=0, opt=False): self._factorization = factorization self._tlsq_rank = tlsq_rank self._Atilde = DMDOptOperator( svd_rank=svd_rank, factorization=factorization ) self._svds = None self._input_space = None self._output_space = None self._input_holder = None self._output_holder = None ``` -------------------------------- ### time Source: https://pydmd.github.io/PyDMD/havok.html Get the times of the input data. This property returns the vector containing the times of the input data. ```APIDOC ## time ### Description Get the times of the input data. ### Returns * **numpy.ndarray** - the vector that contains the times of the input data. ``` -------------------------------- ### Return Values from compute_varprodmd_any Source: https://pydmd.github.io/PyDMD/_modules/pydmd/varprodmd.html Shows the unpacking of results from the `compute_varprodmd_any` function, including modes, eigenvalues, and optimization results. ```python (self._modes, self._eigenvalues, eigenf, indices, opt) = compute_varprodmd_any( X, Y, self._optargs, self._svd_rank, not self._exact, self._compression ) ``` -------------------------------- ### snapshots Source: https://pydmd.github.io/PyDMD/havok.html Get the input data (time-series or space-flattened). This property returns the matrix containing the original input data. ```APIDOC ## snapshots ### Description Get the input data (time-series or space-flattened). ### Returns * **numpy.ndarray** - the matrix that contains the original input data. ``` -------------------------------- ### Define and visualize training parameters Source: https://pydmd.github.io/PyDMD/tutorial10paramdmd.html Selects 10 equispaced parameters within the [0,1] interval for training and visualizes them on a plot. This step is crucial for ensuring the algorithm can adequately explore the solution manifold. ```python training_params = np.round(np.linspace(0, 1, 10), 1) plt.figure(figsize=(8, 2)) plt.scatter(training_params, np.zeros(len(training_params)), label="training") plt.title("Training parameters") plt.grid() plt.xlabel("$\\mu$") plt.yticks([], []); ``` -------------------------------- ### singular_vals Source: https://pydmd.github.io/PyDMD/havok.html Get the singular value spectrum of the Hankel matrix. This property returns the singular values of the Hankel matrix. ```APIDOC ## singular_vals ### Description Get the singular value spectrum of the Hankel matrix. ### Returns * **numpy.ndarray** - the singular values of the Hankel matrix. ``` -------------------------------- ### r Source: https://pydmd.github.io/PyDMD/havok.html Get the number of HAVOK embeddings utilized by the HAVOK model. This represents the integer rank truncation used. ```APIDOC ## r ### Description Get the number of HAVOK embeddings utilized by the HAVOK model. Note that this is essentially the integer rank truncation used. ### Returns * **int** - rank of the HAVOK model. ``` -------------------------------- ### BOPMD Initialization Source: https://pydmd.github.io/PyDMD/_modules/pydmd/bopdmd.html Initializes the BOPMD class with various parameters controlling the DMD computation and projection process. Key parameters include data characteristics (compute_A, use_proj, init_alpha, proj_basis, num_trials, trial_size), mode sorting and constraints (eig_sort, eig_constraints), and bag-related settings (mode_prox, remove_bad_bags, bag_warning, bag_maxfail). It also accepts parameters for the variable projection routine. ```python def __init__( self, compute_A, use_proj, init_alpha, proj_basis, num_trials, trial_size, eig_sort, eig_constraints, mode_prox, remove_bad_bags, bag_warning, bag_maxfail, real_eig_limit, init_lambda=1.0, maxlam=52, lamup=2.0, use_levmarq=True, maxiter=30, tol=1e-6, eps_stall=1e-12, use_fulljac=True, verbose=False, varpro_flag=True, ): self._compute_A = compute_A self._use_proj = use_proj self._init_alpha = init_alpha self._proj_basis = proj_basis self._num_trials = num_trials self._trial_size = trial_size self._eig_sort = eig_sort self._eig_constraints = eig_constraints self._mode_prox = mode_prox self._remove_bad_bags = remove_bad_bags self._bag_warning = bag_warning self._bag_maxfail = bag_maxfail self._real_eig_limit = real_eig_limit self._varpro_flag = varpro_flag self._varpro_opts = [ init_lambda, maxlam, lamup, use_levmarq, maxiter, tol, eps_stall, use_fulljac, verbose, ] self._varpro_opts_warn() self._modes = None self._eigenvalues = None self._modes_std = None self._eigenvalues_std = None self._amplitudes_std = None self._Atilde = None self._A = None ``` -------------------------------- ### dynamics Property Source: https://pydmd.github.io/PyDMD/optdmd.html Gets the time evolution of each mode, representing the temporal behavior of the system's dynamic modes. ```APIDOC ## dynamics ### Description Get the time evolution of each mode. \mathbf{x}(t) \approx \sum_{k=1}^{r} \boldsymbol{\phi}_{k} \exp \left( \omega_{k} t \right) b_{k} = \sum_{k=1}^{r} \boldsymbol{\phi}_{k} \left( \lambda_{k} \right)^{\left( t / \Delta t \right)} b_{k} ### Returns the matrix that contains all the time evolution, stored by row. ### Return type numpy.ndarray ```