
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "content/user_guide/auto_examples/1single/plot_eeof.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_content_user_guide_auto_examples_1single_plot_eeof.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_content_user_guide_auto_examples_1single_plot_eeof.py:


Extented EOF analysis
=====================

This example demonstrates Extended EOF (EEOF) analysis on ``xarray`` tutorial
data. EEOF analysis, also termed as Multivariate/Multichannel Singular
Spectrum Analysis, advances traditional EOF analysis to capture propagating
signals or oscillations in multivariate datasets. At its core, this
involves the formulation of a lagged covariance matrix that encapsulates
both spatial and temporal correlations. Subsequently, this matrix is
decomposed to yield its eigenvectors (components) and eigenvalues (explained variance).

Let's begin by setting up the required packages and fetching the data:

.. GENERATED FROM PYTHON SOURCE LINES 15-23

.. code-block:: default


    import matplotlib.pyplot as plt
    import xarray as xr

    import xeofs as xe

    xr.set_options(display_expand_data=False)





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    <xarray.core.options.set_options object at 0x7e85b6450150>



.. GENERATED FROM PYTHON SOURCE LINES 24-25

Load the tutorial data.

.. GENERATED FROM PYTHON SOURCE LINES 25-28

.. code-block:: default

    t2m = xr.tutorial.load_dataset("air_temperature").air









.. GENERATED FROM PYTHON SOURCE LINES 29-42

Prior to conducting the EEOF analysis, it's essential to determine the
structure of the lagged covariance matrix. This entails defining the time
delay ``tau`` and the ``embedding`` dimension. The former signifies the
interval between the original and lagged time series, while the latter
dictates the number of time-lagged copies in the delay-coordinate space,
representing the system's dynamics.
For illustration, using ``tau=4`` and ``embedding=40``, we generate 40
delayed versions of the time series, each offset by 4 time steps, resulting
in a maximum shift of ``tau x embedding = 160``. Given our dataset's
6-hour intervals, tau = 4 translates to a 24-hour shift.
It's obvious that this way of constructing the lagged covariance matrix
and subsequently decomposing it can be computationally expensive. For example,
given our dataset's dimensions,

.. GENERATED FROM PYTHON SOURCE LINES 42-45

.. code-block:: default


    t2m.shape





.. rst-class:: sphx-glr-script-out

 .. code-block:: none


    (2920, 25, 53)



.. GENERATED FROM PYTHON SOURCE LINES 46-54

the extended dataset would have 40 x 25 x 53 = 53000 features
which is much larger than the original dataset's 1325 features.
To mitigate this, we can first preprocess the data using PCA / EOF analysis
and then perform EEOF analysis on the resulting PCA / EOF scores. Here,
we'll use ``n_pca_modes=50`` to retain the first 50 PCA modes, so we end
up with 40 x 50 = 200 (latent) features.
With these parameters set, we proceed to instantiate the ``ExtendedEOF``
model and fit our data.

.. GENERATED FROM PYTHON SOURCE LINES 54-63

.. code-block:: default


    model = xe.single.ExtendedEOF(
        n_modes=10, tau=4, embedding=40, n_pca_modes=50, use_coslat=True
    )
    model.fit(t2m, dim="time")
    scores = model.scores()
    components = model.components()
    components






.. raw:: html

    <div class="output_subarea output_html rendered_html output_result">
    <div><svg style="position: absolute; width: 0; height: 0; overflow: hidden">
    <defs>
    <symbol id="icon-database" viewBox="0 0 32 32">
    <path d="M16 0c-8.837 0-16 2.239-16 5v4c0 2.761 7.163 5 16 5s16-2.239 16-5v-4c0-2.761-7.163-5-16-5z"></path>
    <path d="M16 17c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z"></path>
    <path d="M16 26c-8.837 0-16-2.239-16-5v6c0 2.761 7.163 5 16 5s16-2.239 16-5v-6c0 2.761-7.163 5-16 5z"></path>
    </symbol>
    <symbol id="icon-file-text2" viewBox="0 0 32 32">
    <path d="M28.681 7.159c-0.694-0.947-1.662-2.053-2.724-3.116s-2.169-2.030-3.116-2.724c-1.612-1.182-2.393-1.319-2.841-1.319h-15.5c-1.378 0-2.5 1.121-2.5 2.5v27c0 1.378 1.122 2.5 2.5 2.5h23c1.378 0 2.5-1.122 2.5-2.5v-19.5c0-0.448-0.137-1.23-1.319-2.841zM24.543 5.457c0.959 0.959 1.712 1.825 2.268 2.543h-4.811v-4.811c0.718 0.556 1.584 1.309 2.543 2.268zM28 29.5c0 0.271-0.229 0.5-0.5 0.5h-23c-0.271 0-0.5-0.229-0.5-0.5v-27c0-0.271 0.229-0.5 0.5-0.5 0 0 15.499-0 15.5 0v7c0 0.552 0.448 1 1 1h7v19.5z"></path>
    <path d="M23 26h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path>
    <path d="M23 22h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path>
    <path d="M23 18h-14c-0.552 0-1-0.448-1-1s0.448-1 1-1h14c0.552 0 1 0.448 1 1s-0.448 1-1 1z"></path>
    </symbol>
    </defs>
    </svg>
    <style>/* CSS stylesheet for displaying xarray objects in jupyterlab.
     *
     */

    :root {
      --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));
      --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));
      --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));
      --xr-border-color: var(--jp-border-color2, #e0e0e0);
      --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);
      --xr-background-color: var(--jp-layout-color0, white);
      --xr-background-color-row-even: var(--jp-layout-color1, white);
      --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);
    }

    html[theme=dark],
    body[data-theme=dark],
    body.vscode-dark {
      --xr-font-color0: rgba(255, 255, 255, 1);
      --xr-font-color2: rgba(255, 255, 255, 0.54);
      --xr-font-color3: rgba(255, 255, 255, 0.38);
      --xr-border-color: #1F1F1F;
      --xr-disabled-color: #515151;
      --xr-background-color: #111111;
      --xr-background-color-row-even: #111111;
      --xr-background-color-row-odd: #313131;
    }

    .xr-wrap {
      display: block !important;
      min-width: 300px;
      max-width: 700px;
    }

    .xr-text-repr-fallback {
      /* fallback to plain text repr when CSS is not injected (untrusted notebook) */
      display: none;
    }

    .xr-header {
      padding-top: 6px;
      padding-bottom: 6px;
      margin-bottom: 4px;
      border-bottom: solid 1px var(--xr-border-color);
    }

    .xr-header > div,
    .xr-header > ul {
      display: inline;
      margin-top: 0;
      margin-bottom: 0;
    }

    .xr-obj-type,
    .xr-array-name {
      margin-left: 2px;
      margin-right: 10px;
    }

    .xr-obj-type {
      color: var(--xr-font-color2);
    }

    .xr-sections {
      padding-left: 0 !important;
      display: grid;
      grid-template-columns: 150px auto auto 1fr 20px 20px;
    }

    .xr-section-item {
      display: contents;
    }

    .xr-section-item input {
      display: none;
    }

    .xr-section-item input + label {
      color: var(--xr-disabled-color);
    }

    .xr-section-item input:enabled + label {
      cursor: pointer;
      color: var(--xr-font-color2);
    }

    .xr-section-item input:enabled + label:hover {
      color: var(--xr-font-color0);
    }

    .xr-section-summary {
      grid-column: 1;
      color: var(--xr-font-color2);
      font-weight: 500;
    }

    .xr-section-summary > span {
      display: inline-block;
      padding-left: 0.5em;
    }

    .xr-section-summary-in:disabled + label {
      color: var(--xr-font-color2);
    }

    .xr-section-summary-in + label:before {
      display: inline-block;
      content: '►';
      font-size: 11px;
      width: 15px;
      text-align: center;
    }

    .xr-section-summary-in:disabled + label:before {
      color: var(--xr-disabled-color);
    }

    .xr-section-summary-in:checked + label:before {
      content: '▼';
    }

    .xr-section-summary-in:checked + label > span {
      display: none;
    }

    .xr-section-summary,
    .xr-section-inline-details {
      padding-top: 4px;
      padding-bottom: 4px;
    }

    .xr-section-inline-details {
      grid-column: 2 / -1;
    }

    .xr-section-details {
      display: none;
      grid-column: 1 / -1;
      margin-bottom: 5px;
    }

    .xr-section-summary-in:checked ~ .xr-section-details {
      display: contents;
    }

    .xr-array-wrap {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: 20px auto;
    }

    .xr-array-wrap > label {
      grid-column: 1;
      vertical-align: top;
    }

    .xr-preview {
      color: var(--xr-font-color3);
    }

    .xr-array-preview,
    .xr-array-data {
      padding: 0 5px !important;
      grid-column: 2;
    }

    .xr-array-data,
    .xr-array-in:checked ~ .xr-array-preview {
      display: none;
    }

    .xr-array-in:checked ~ .xr-array-data,
    .xr-array-preview {
      display: inline-block;
    }

    .xr-dim-list {
      display: inline-block !important;
      list-style: none;
      padding: 0 !important;
      margin: 0;
    }

    .xr-dim-list li {
      display: inline-block;
      padding: 0;
      margin: 0;
    }

    .xr-dim-list:before {
      content: '(';
    }

    .xr-dim-list:after {
      content: ')';
    }

    .xr-dim-list li:not(:last-child):after {
      content: ',';
      padding-right: 5px;
    }

    .xr-has-index {
      font-weight: bold;
    }

    .xr-var-list,
    .xr-var-item {
      display: contents;
    }

    .xr-var-item > div,
    .xr-var-item label,
    .xr-var-item > .xr-var-name span {
      background-color: var(--xr-background-color-row-even);
      margin-bottom: 0;
    }

    .xr-var-item > .xr-var-name:hover span {
      padding-right: 5px;
    }

    .xr-var-list > li:nth-child(odd) > div,
    .xr-var-list > li:nth-child(odd) > label,
    .xr-var-list > li:nth-child(odd) > .xr-var-name span {
      background-color: var(--xr-background-color-row-odd);
    }

    .xr-var-name {
      grid-column: 1;
    }

    .xr-var-dims {
      grid-column: 2;
    }

    .xr-var-dtype {
      grid-column: 3;
      text-align: right;
      color: var(--xr-font-color2);
    }

    .xr-var-preview {
      grid-column: 4;
    }

    .xr-index-preview {
      grid-column: 2 / 5;
      color: var(--xr-font-color2);
    }

    .xr-var-name,
    .xr-var-dims,
    .xr-var-dtype,
    .xr-preview,
    .xr-attrs dt {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      padding-right: 10px;
    }

    .xr-var-name:hover,
    .xr-var-dims:hover,
    .xr-var-dtype:hover,
    .xr-attrs dt:hover {
      overflow: visible;
      width: auto;
      z-index: 1;
    }

    .xr-var-attrs,
    .xr-var-data,
    .xr-index-data {
      display: none;
      background-color: var(--xr-background-color) !important;
      padding-bottom: 5px !important;
    }

    .xr-var-attrs-in:checked ~ .xr-var-attrs,
    .xr-var-data-in:checked ~ .xr-var-data,
    .xr-index-data-in:checked ~ .xr-index-data {
      display: block;
    }

    .xr-var-data > table {
      float: right;
    }

    .xr-var-name span,
    .xr-var-data,
    .xr-index-name div,
    .xr-index-data,
    .xr-attrs {
      padding-left: 25px !important;
    }

    .xr-attrs,
    .xr-var-attrs,
    .xr-var-data,
    .xr-index-data {
      grid-column: 1 / -1;
    }

    dl.xr-attrs {
      padding: 0;
      margin: 0;
      display: grid;
      grid-template-columns: 125px auto;
    }

    .xr-attrs dt,
    .xr-attrs dd {
      padding: 0;
      margin: 0;
      float: left;
      padding-right: 10px;
      width: auto;
    }

    .xr-attrs dt {
      font-weight: normal;
      grid-column: 1;
    }

    .xr-attrs dt:hover span {
      display: inline-block;
      background: var(--xr-background-color);
      padding-right: 10px;
    }

    .xr-attrs dd {
      grid-column: 2;
      white-space: pre-wrap;
      word-break: break-all;
    }

    .xr-icon-database,
    .xr-icon-file-text2,
    .xr-no-icon {
      display: inline-block;
      vertical-align: middle;
      width: 1em;
      height: 1.5em !important;
      stroke-width: 0;
      stroke: currentColor;
      fill: currentColor;
    }
    </style><pre class='xr-text-repr-fallback'>&lt;xarray.DataArray &#x27;components&#x27; (mode: 10, embedding: 40, lat: 25, lon: 53)&gt;
    0.0003856 0.0003647 0.0003572 0.0003564 ... -0.001401 -0.0009889 -0.0005825
    Coordinates:
      * lat        (lat) float32 15.0 17.5 20.0 22.5 25.0 ... 67.5 70.0 72.5 75.0
      * lon        (lon) float32 200.0 202.5 205.0 207.5 ... 322.5 325.0 327.5 330.0
      * embedding  (embedding) int64 0 4 8 12 16 20 24 ... 136 140 144 148 152 156
      * mode       (mode) int64 1 2 3 4 5 6 7 8 9 10
    Attributes: (12/15)
        model:          Extended EOF Analysis
        software:       xeofs
        version:        1.2.0
        date:           2024-09-04 15:05:13
        n_modes:        10
        center:         True
        ...             ...
        sample_name:    sample
        feature_name:   feature
        random_state:   None
        compute:        True
        solver:         auto
        solver_kwargs:  {}</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'components'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>mode</span>: 10</li><li><span class='xr-has-index'>embedding</span>: 40</li><li><span class='xr-has-index'>lat</span>: 25</li><li><span class='xr-has-index'>lon</span>: 53</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-2788d169-474a-4eb9-9a0c-efd95634f14b' class='xr-array-in' type='checkbox' ><label for='section-2788d169-474a-4eb9-9a0c-efd95634f14b' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>0.0003856 0.0003647 0.0003572 ... -0.001401 -0.0009889 -0.0005825</span></div><div class='xr-array-data'><pre>array([[[[ 3.85552281e-04,  3.64692799e-04,  3.57200545e-04, ...,
               3.64381868e-04,  4.30269200e-04,  4.71685044e-04],
             [ 5.28614128e-04,  4.69073835e-04,  4.18679812e-04, ...,
               4.39713563e-04,  5.02035188e-04,  5.54297903e-04],
             [ 7.35475812e-04,  6.86503701e-04,  5.40585105e-04, ...,
               5.36876586e-04,  5.28459730e-04,  5.44657800e-04],
             ...,
             [ 4.54723174e-03,  4.73635150e-03,  4.90140379e-03, ...,
               4.28195624e-03,  4.13744150e-03,  3.85329500e-03],
             [ 4.00971952e-03,  4.04303864e-03,  4.09788754e-03, ...,
               3.91658856e-03,  3.95820806e-03,  3.91666063e-03],
             [ 4.04480883e-03,  4.03730457e-03,  4.05027076e-03, ...,
               3.58082226e-03,  3.62287399e-03,  3.66872924e-03]],

            [[ 3.90311800e-04,  3.70068259e-04,  3.63166992e-04, ...,
               3.84102651e-04,  4.50609032e-04,  4.92599371e-04],
             [ 5.35201220e-04,  4.75474477e-04,  4.25367079e-04, ...,
               4.58389755e-04,  5.22380241e-04,  5.75901996e-04],
             [ 7.43806041e-04,  6.93666226e-04,  5.47619236e-04, ...,
               5.54790348e-04,  5.47541274e-04,  5.64920604e-04],
    ...
             [ 3.97107131e-03,  3.79771637e-03,  3.42178834e-03, ...,
              -3.20449801e-03, -2.57418692e-03, -1.74154459e-03],
             [ 1.82164487e-03,  1.64926222e-03,  1.40417425e-03, ...,
              -2.88271175e-03, -2.43506527e-03, -1.78482740e-03],
             [-9.04333282e-05, -1.71714253e-04, -2.74519792e-04, ...,
              -1.42883942e-03, -1.00442354e-03, -5.64190809e-04]],

            [[-1.82512620e-05, -1.00204661e-04, -2.08362883e-04, ...,
               9.57859405e-04,  1.17862564e-03,  1.20887868e-03],
             [ 2.06385778e-04, -6.52785283e-05, -3.57902933e-04, ...,
               1.00104564e-03,  1.35464862e-03,  1.36880330e-03],
             [ 5.06045125e-04,  1.51588570e-04, -5.74778687e-05, ...,
               8.14179105e-04,  1.10897934e-03,  1.22235868e-03],
             ...,
             [ 4.95764550e-03,  4.82627499e-03,  4.47064372e-03, ...,
              -3.08709942e-03, -2.59016454e-03, -1.88505446e-03],
             [ 2.26477156e-03,  2.11134470e-03,  1.86931362e-03, ...,
              -2.74612463e-03, -2.37900725e-03, -1.82847222e-03],
             [-1.12658596e-04, -1.53181401e-04, -2.14039184e-04, ...,
              -1.40131164e-03, -9.88900611e-04, -5.82493495e-04]]]])</pre></div></div></li><li class='xr-section-item'><input id='section-28fd77e3-cd14-4857-93d1-1cf2f25d7d4b' class='xr-section-summary-in' type='checkbox'  checked><label for='section-28fd77e3-cd14-4857-93d1-1cf2f25d7d4b' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lat</span></div><div class='xr-var-dims'>(lat)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>15.0 17.5 20.0 ... 70.0 72.5 75.0</div><input id='attrs-957eb9f5-8e08-4c0f-b3bf-0a1639c3f1a9' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-957eb9f5-8e08-4c0f-b3bf-0a1639c3f1a9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8adaf4c3-5433-48fd-a7aa-eefc27084c4b' class='xr-var-data-in' type='checkbox'><label for='data-8adaf4c3-5433-48fd-a7aa-eefc27084c4b' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([15. , 17.5, 20. , 22.5, 25. , 27.5, 30. , 32.5, 35. , 37.5, 40. , 42.5,
           45. , 47.5, 50. , 52.5, 55. , 57.5, 60. , 62.5, 65. , 67.5, 70. , 72.5,
           75. ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>lon</span></div><div class='xr-var-dims'>(lon)</div><div class='xr-var-dtype'>float32</div><div class='xr-var-preview xr-preview'>200.0 202.5 205.0 ... 327.5 330.0</div><input id='attrs-bdc4fff8-fa77-4f2d-b780-75a1c3f061a1' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bdc4fff8-fa77-4f2d-b780-75a1c3f061a1' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-658bf132-d811-4e9a-8e0b-ffd665826271' class='xr-var-data-in' type='checkbox'><label for='data-658bf132-d811-4e9a-8e0b-ffd665826271' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([200. , 202.5, 205. , 207.5, 210. , 212.5, 215. , 217.5, 220. , 222.5,
           225. , 227.5, 230. , 232.5, 235. , 237.5, 240. , 242.5, 245. , 247.5,
           250. , 252.5, 255. , 257.5, 260. , 262.5, 265. , 267.5, 270. , 272.5,
           275. , 277.5, 280. , 282.5, 285. , 287.5, 290. , 292.5, 295. , 297.5,
           300. , 302.5, 305. , 307.5, 310. , 312.5, 315. , 317.5, 320. , 322.5,
           325. , 327.5, 330. ], dtype=float32)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>embedding</span></div><div class='xr-var-dims'>(embedding)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>0 4 8 12 16 ... 140 144 148 152 156</div><input id='attrs-6bf58637-9692-4154-8058-dc9efa59dd31' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-6bf58637-9692-4154-8058-dc9efa59dd31' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-8c9bf879-f218-4b86-9791-7bea81b9e594' class='xr-var-data-in' type='checkbox'><label for='data-8c9bf879-f218-4b86-9791-7bea81b9e594' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([  0,   4,   8,  12,  16,  20,  24,  28,  32,  36,  40,  44,  48,  52,
            56,  60,  64,  68,  72,  76,  80,  84,  88,  92,  96, 100, 104, 108,
           112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>mode</span></div><div class='xr-var-dims'>(mode)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>1 2 3 4 5 6 7 8 9 10</div><input id='attrs-e206e2e6-2a7c-4ec3-9198-b3fa88d78ec3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-e206e2e6-2a7c-4ec3-9198-b3fa88d78ec3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-73942e29-c33a-4286-86fe-5b0e28375dd2' class='xr-var-data-in' type='checkbox'><label for='data-73942e29-c33a-4286-86fe-5b0e28375dd2' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-fe7f0425-917f-4f7a-9db6-6a9beb42f6c8' class='xr-section-summary-in' type='checkbox'  ><label for='section-fe7f0425-917f-4f7a-9db6-6a9beb42f6c8' class='xr-section-summary' >Indexes: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-index-name'><div>embedding</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-5749412d-3c27-4dc0-9a46-68f22f21b921' class='xr-index-data-in' type='checkbox'/><label for='index-5749412d-3c27-4dc0-9a46-68f22f21b921' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([  0,   4,   8,  12,  16,  20,  24,  28,  32,  36,  40,  44,  48,  52,
            56,  60,  64,  68,  72,  76,  80,  84,  88,  92,  96, 100, 104, 108,
           112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156],
          dtype=&#x27;int64&#x27;, name=&#x27;embedding&#x27;))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>mode</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-7f58aa44-17c7-47b3-aa10-e0bd04f3ec74' class='xr-index-data-in' type='checkbox'/><label for='index-7f58aa44-17c7-47b3-aa10-e0bd04f3ec74' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=&#x27;int64&#x27;, name=&#x27;mode&#x27;))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>lat</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-2da7c4c4-3475-4ab4-81f1-25788b3b3e32' class='xr-index-data-in' type='checkbox'/><label for='index-2da7c4c4-3475-4ab4-81f1-25788b3b3e32' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([15.0, 17.5, 20.0, 22.5, 25.0, 27.5, 30.0, 32.5, 35.0, 37.5, 40.0, 42.5,
           45.0, 47.5, 50.0, 52.5, 55.0, 57.5, 60.0, 62.5, 65.0, 67.5, 70.0, 72.5,
           75.0],
          dtype=&#x27;float32&#x27;, name=&#x27;lat&#x27;))</pre></div></li><li class='xr-var-item'><div class='xr-index-name'><div>lon</div></div><div class='xr-index-preview'>PandasIndex</div><div></div><input id='index-95ab333a-9222-48ad-ad01-85d9b2b3c7ac' class='xr-index-data-in' type='checkbox'/><label for='index-95ab333a-9222-48ad-ad01-85d9b2b3c7ac' title='Show/Hide index repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-index-data'><pre>PandasIndex(Index([200.0, 202.5, 205.0, 207.5, 210.0, 212.5, 215.0, 217.5, 220.0, 222.5,
           225.0, 227.5, 230.0, 232.5, 235.0, 237.5, 240.0, 242.5, 245.0, 247.5,
           250.0, 252.5, 255.0, 257.5, 260.0, 262.5, 265.0, 267.5, 270.0, 272.5,
           275.0, 277.5, 280.0, 282.5, 285.0, 287.5, 290.0, 292.5, 295.0, 297.5,
           300.0, 302.5, 305.0, 307.5, 310.0, 312.5, 315.0, 317.5, 320.0, 322.5,
           325.0, 327.5, 330.0],
          dtype=&#x27;float32&#x27;, name=&#x27;lon&#x27;))</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-3604ca2f-a077-4a4b-a393-c71f4f633681' class='xr-section-summary-in' type='checkbox'  ><label for='section-3604ca2f-a077-4a4b-a393-c71f4f633681' class='xr-section-summary' >Attributes: <span>(15)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>model :</span></dt><dd>Extended EOF Analysis</dd><dt><span>software :</span></dt><dd>xeofs</dd><dt><span>version :</span></dt><dd>1.2.0</dd><dt><span>date :</span></dt><dd>2024-09-04 15:05:13</dd><dt><span>n_modes :</span></dt><dd>10</dd><dt><span>center :</span></dt><dd>True</dd><dt><span>standardize :</span></dt><dd>False</dd><dt><span>use_coslat :</span></dt><dd>True</dd><dt><span>check_nans :</span></dt><dd>True</dd><dt><span>sample_name :</span></dt><dd>sample</dd><dt><span>feature_name :</span></dt><dd>feature</dd><dt><span>random_state :</span></dt><dd>None</dd><dt><span>compute :</span></dt><dd>True</dd><dt><span>solver :</span></dt><dd>auto</dd><dt><span>solver_kwargs :</span></dt><dd>{}</dd></dl></div></li></ul></div></div>
    </div>
    <br />
    <br />

.. GENERATED FROM PYTHON SOURCE LINES 64-68

A notable distinction from standard EOF analysis is the incorporation of an
extra ``embedding`` dimension in the components. Nonetheless, the
overarching methodology mirrors traditional EOF practices. The results,
for instance, can be assessed by examining the explained variance ratio.

.. GENERATED FROM PYTHON SOURCE LINES 68-72

.. code-block:: default


    model.explained_variance_ratio().plot()
    plt.show()




.. image-sg:: /content/user_guide/auto_examples/1single/images/sphx_glr_plot_eeof_001.png
   :alt: plot eeof
   :srcset: /content/user_guide/auto_examples/1single/images/sphx_glr_plot_eeof_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 73-74

Additionally, we can look into the scores; let's spotlight mode 4.

.. GENERATED FROM PYTHON SOURCE LINES 74-78

.. code-block:: default


    scores.sel(mode=4).plot()
    plt.show()




.. image-sg:: /content/user_guide/auto_examples/1single/images/sphx_glr_plot_eeof_002.png
   :alt: mode = 4
   :srcset: /content/user_guide/auto_examples/1single/images/sphx_glr_plot_eeof_002.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 79-82

In wrapping up, we visualize the corresponding EEOF component of mode 4.
For visualization purposes, we'll focus on the component at a specific
latitude, in this instance, 60 degrees north.

.. GENERATED FROM PYTHON SOURCE LINES 82-85

.. code-block:: default


    components.sel(mode=4, lat=60).plot()
    plt.show()



.. image-sg:: /content/user_guide/auto_examples/1single/images/sphx_glr_plot_eeof_003.png
   :alt: lat = 60.0, mode = 4
   :srcset: /content/user_guide/auto_examples/1single/images/sphx_glr_plot_eeof_003.png
   :class: sphx-glr-single-img






.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 2.568 seconds)


.. _sphx_glr_download_content_user_guide_auto_examples_1single_plot_eeof.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example




    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_eeof.py <plot_eeof.py>`

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_eeof.ipynb <plot_eeof.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
