
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/oil_and_gas/plot_well_prod_status.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_oil_and_gas_plot_well_prod_status.py>`
        to download the full example code.

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

.. _sphx_glr_auto_examples_oil_and_gas_plot_well_prod_status.py:


=========================================
Check for the production status of a well
=========================================

The data is from an unnamed well in the form of a pickle file. The data is a dataframe that consists of a time
series of master, wing and choke valves. The duration of the data is about 50 days. The figure shows the time
series of the valves and the output of the function which is the production status of the well (0 is OFF and 1
is ON).

.. GENERATED FROM PYTHON SOURCE LINES 13-45



.. image-sg:: /auto_examples/oil_and_gas/images/sphx_glr_plot_well_prod_status_001.png
   :alt: master valve, wing valve, choke valve, well production status
   :srcset: /auto_examples/oil_and_gas/images/sphx_glr_plot_well_prod_status_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import os

    import matplotlib.pyplot as plt
    import pandas as pd

    from indsl.oil_and_gas.well_prod_status import calculate_well_prod_status


    base_path = "" if __name__ == "__main__" else os.path.dirname(__file__)
    data = pd.read_pickle(os.path.join(base_path, "../../datasets/data/valve_data.pkl"))

    master = data.iloc[:, 0]
    wing = data.iloc[:, 1]
    choke = data.iloc[:, 2]

    prod_status = calculate_well_prod_status(master, wing, choke, threshold_choke=5, threshold_master=1, threshold_wing=1)
    names = ["master valve", "wing valve", "choke valve", "well production status"]
    y_label = ["-", "-", "%", "-"]
    y_lim_max = [1.05, 1.05, 105, 1.05]
    y_lim_min = [-0.05, -0.05, -0.05, -0.05]

    fig, ax = plt.subplots(figsize=(12, 12), nrows=4, ncols=1)
    ax = ax.ravel()
    for idx, i in enumerate([master, wing, choke, prod_status]):
        ax[idx].plot(i)
        ax[idx].set_title(names[idx])
        ax[idx].set_ylabel(y_label[idx])
        ax[idx].set_ylim(y_lim_min[idx], y_lim_max[idx])

    plt.tight_layout()
    plt.show()


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

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


.. _sphx_glr_download_auto_examples_oil_and_gas_plot_well_prod_status.py:

.. only:: html

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

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

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

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

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

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_well_prod_status.zip <plot_well_prod_status.zip>`


.. only:: html

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

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