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

.. only:: html

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

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

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

.. _sphx_glr_auto_examples_calculate_covariance.py:


Calculation of the Covariance Matrix
====================================
After rescaling plots, the covariance matrix is calculated
and then plotted for a 2D Field experiment (spectra as a function
of field with multiple collections or "Times")

.. GENERATED FROM PYTHON SOURCE LINES 9-29



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /auto_examples/images/sphx_glr_calculate_covariance_001.png
         :alt: covariance in B domain
         :srcset: /auto_examples/images/sphx_glr_calculate_covariance_001.png, /auto_examples/images/sphx_glr_calculate_covariance_001_2_00x.png 2.00x
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /auto_examples/images/sphx_glr_calculate_covariance_002.png
         :alt: Covariance in U domain
         :srcset: /auto_examples/images/sphx_glr_calculate_covariance_002.png, /auto_examples/images/sphx_glr_calculate_covariance_002_2_00x.png 2.00x
         :class: sphx-glr-multi-img


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

 .. code-block:: none

    1: covariance in B domain |||('mT', 'mT')
    2: Covariance in U domain |||('kcyc · (T)$^{-1}$', 'kcyc · (T)$^{-1}$')







|

.. code-block:: Python

    from pyspecdata import *
    from pylab import *

    fieldaxis = "$B_0$"
    exp_type = "francklab_esr/alex"
    with figlist_var() as fl:
        for filenum, (thisfile) in enumerate(
            [("230504_3p8mM_TEMPOL_stb_wt_4x.DSC")]
        ):
            d = find_file(thisfile, exp_type=exp_type)["harmonic", 0]
            d.set_units(fieldaxis, 'T').setaxis(fieldaxis, lambda x: x*1e-4)
            d.rename("Time", "observations")
            d.reorder(["observations", fieldaxis])
            fl.next("covariance in B domain")
            # we do this first, because if we were to ift to go to u domain and
            # then ft back, we would introduce a complex component to our data
            fl.image(d.C.cov_mat("observations"))
            d.ift(fieldaxis, shift=True)
            fl.next("Covariance in U domain")
            fl.image(d.cov_mat("observations")) # this time, do not spin up an extra copy of the data


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

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


.. _sphx_glr_download_auto_examples_calculate_covariance.py:

.. only:: html

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

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

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

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

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


.. only:: html

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

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