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

.. only:: html

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

        Click :ref:`here <sphx_glr_download__gallery_plot_fig3.py>`
        to download the full example code

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

.. _sphx_glr__gallery_plot_fig3.py:


Figure 3
========

Plot formalisms using parameter values from fig3 (table1)

.. GENERATED FROM PYTHON SOURCE LINES 7-58



.. image:: /_gallery/images/sphx_glr_plot_fig3_001.png
    :alt: plot fig3
    :class: sphx-glr-single-img





.. code-block:: default

    import matplotlib.pyplot as plt
    import numpy as np
    import pandas as pd

    from harley1992 import pth_clean, raw

    # params
    tab1 = pd.read_csv(pth_clean / "table1.csv", sep=";", comment="#", index_col=['name', 'ca'])['value']

    # recompute curves
    temps = np.linspace(10, 40, 100)
    df = {}
    names = ['vc_max', 'j_max', 'tpu']

    for name in names:
        records = []

        for mod_growth in (35, 65):
            for t_leaf in temps:
                tk = t_leaf + 273.15
                val = raw.eq9(tk,
                              tab1.at[(f'{name}_c', mod_growth)],
                              tab1.at[(f'{name}_deltaha', mod_growth)],
                              tab1.at[(f'{name}_deltahd', mod_growth)],
                              tab1.at[(f'{name}_deltas', mod_growth)])
                records.append(dict(
                    mod_growth=mod_growth,
                    t_leaf=t_leaf,
                    val=val,
                ))

        df[name] = pd.DataFrame(records)

    # plot result
    fig, axes = plt.subplots(2, 2, sharex='all', figsize=(12, 8), squeeze=False)

    for name, ax in zip(names, axes.flatten()):

        for mod_growth, sdf in df[name].groupby('mod_growth'):
            ax.plot(sdf['t_leaf'], sdf['val'], label=f"{mod_growth:.0f}")

        ax.legend(loc='upper left', title="Oxygen")
        ax.set_xlabel("Leaf temperature [°C]")

        ax.set_xlim(10, 40)
        ax.set_ylabel(f"{name} [µmol.m-2.s-1]")

    axes[1, 1].set_visible(False)

    fig.tight_layout()
    plt.show()


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

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


.. _sphx_glr_download__gallery_plot_fig3.py:


.. only :: html

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



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

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



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

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


.. only:: html

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

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