<commit_before>.. _sec_modaldecomp:

------------------------------------------
Modal decompositions -- POD, BPOD, and DMD
------------------------------------------

This tutorial discusses computing modes from data, using the Proper Orthogonal
Decomposition (POD), Balanced Proper Orthogonal Decomposition (BPOD), and
Dynamic Mode Decomposition (DMD).
For details of these algorithms, see [HLBR]_ for POD and BPOD and [TRLBK]_ for
DMD.

The first step is to collect your data.
We call each piece of data a "vector" or "vector object".
**By vector, we don't mean a 1D array.**
Rather, we mean an element of a vector space.
This could be a 1D, 2D, or 3D array, or any other object that satisfies the
properties of a vector space.
The examples below build on one another, each introducing new aspects.


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Example 1 -- All data in an array
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A simple way to find POD modes is:

.. literalinclude:: ../modred/examples/tutorial_ex1.py

Let's walk through the important steps.
First, we create an array of random data.
Each column is a vector represented as a 1D array.
Then we call the function ``compute_POD_arrays_direct_method``, which returns
the first ``num_modes`` modes as columns of the array ``modes``, and all of the<commit_msg>DOC: match function in text<commit_after>.. _sec_modaldecomp:

------------------------------------------
Modal decompositions -- POD, BPOD, and DMD
------------------------------------------

This tutorial discusses computing modes from data, using the Proper Orthogonal
Decomposition (POD), Balanced Proper Orthogonal Decomposition (BPOD), and
Dynamic Mode Decomposition (DMD).
For details of these algorithms, see [HLBR]_ for POD and BPOD and [TRLBK]_ for
DMD.

The first step is to collect your data.
We call each piece of data a "vector" or "vector object".
**By vector, we don't mean a 1D array.**
Rather, we mean an element of a vector space.
This could be a 1D, 2D, or 3D array, or any other object that satisfies the
properties of a vector space.
The examples below build on one another, each introducing new aspects.


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Example 1 -- All data in an array
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A simple way to find POD modes is:

.. literalinclude:: ../modred/examples/tutorial_ex1.py

Let's walk through the important steps.
First, we create an array of random data.
Each column is a vector represented as a 1D array.
Then we call the function ``compute_POD_arrays_snaps_method``, which returns
the first ``num_modes`` modes as columns of the array ``modes``, and all of the
{'fraction_non_alphanumeric': 0.1756601607347876, 'fraction_numerical': 0.005357826253348641, 'mean_word_length': 3.3206611570247935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7121862', 'n_tokens_mistral': 752, 'n_tokens_neox': 694, 'n_words': 357}