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

.. only:: html

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

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

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

.. _sphx_glr_source_auto_examples_plot_daytime_averages.py:


Example on how to plot up daily daytime temperature averages
------------------------------------------------------------

Example of how to read in MET data and plot up daytime
temperature averages using the add_solar_variable function

Author: Adam Theisen

.. GENERATED FROM PYTHON SOURCE LINES 10-33



.. image:: /source/auto_examples/images/sphx_glr_plot_daytime_averages_001.png
    :alt: act_datastream temp_mean on 20190101
    :class: sphx-glr-single-img


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

 Out:

 .. code-block:: none

    /Users/atheisen/Code/ACT/act/plotting/plot.py:82: UserWarning: Could not discern datastreamname and dict or tuple were not provided. Using defaultname of act_datastream!
      warnings.warn(("Could not discern datastream" +






|

.. code-block:: default


    import act
    import matplotlib.pyplot as plt

    # Read in the sample MET data
    obj = act.io.armfiles.read_netcdf(act.tests.EXAMPLE_MET_WILDCARD)

    # Add the solar variable, including dawn/dusk to variable
    obj = act.utils.geo_utils.add_solar_variable(obj)

    # Using the sun variable, only analyze daytime data
    obj = obj.where(obj['sun_variable'] == 1)

    # Take daily mean using xarray features
    obj = obj.resample(time='1d', skipna=True, keep_attrs=True).mean()

    # Creat Plot Display
    display = act.plotting.TimeSeriesDisplay(obj, figsize=(15, 10))
    display.plot('temp_mean', linestyle='solid')
    display.day_night_background()
    plt.show()

    obj.close()


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

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


.. _sphx_glr_download_source_auto_examples_plot_daytime_averages.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_daytime_averages.py <plot_daytime_averages.py>`



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

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


.. only:: html

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

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