.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "source/auto_examples/plotting/plot_daytime_averages.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_source_auto_examples_plotting_plot_daytime_averages.py: Calculate and plot 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-45 .. image-sg:: /source/auto_examples/plotting/images/sphx_glr_plot_daytime_averages_001.png :alt: sgpmetE13.b1 temp_mean on 20190101 :srcset: /source/auto_examples/plotting/images/sphx_glr_plot_daytime_averages_001.png :class: sphx-glr-single-img .. code-block:: Python from arm_test_data import DATASETS import matplotlib.pyplot as plt import act # Read in the sample MET data met_wildcard_list = [ 'sgpmetE13.b1.20190101.000000.cdf', 'sgpmetE13.b1.20190102.000000.cdf', 'sgpmetE13.b1.20190103.000000.cdf', 'sgpmetE13.b1.20190104.000000.cdf', 'sgpmetE13.b1.20190105.000000.cdf', 'sgpmetE13.b1.20190106.000000.cdf', 'sgpmetE13.b1.20190107.000000.cdf', ] met_filenames = [DATASETS.fetch(file) for file in met_wildcard_list] ds = act.io.arm.read_arm_netcdf(met_filenames) # Add the solar variable, including dawn/dusk to variable ds = act.utils.geo_utils.add_solar_variable(ds) # Using the sun variable, only analyze daytime data ds = ds.where(ds['sun_variable'] == 1) # Take daily mean using xarray features ds = ds.resample(time='1d', skipna=True).mean() # Creat Plot Display display = act.plotting.TimeSeriesDisplay(ds, figsize=(15, 10)) display.plot('temp_mean', linestyle='solid') display.day_night_background() plt.show() ds.close() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.170 seconds) .. _sphx_glr_download_source_auto_examples_plotting_plot_daytime_averages.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_daytime_averages.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_daytime_averages.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_daytime_averages.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_