{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Calculate and plot daily daytime temperature averages\n\nExample of how to read in MET data and plot up daytime\ntemperature averages using the add_solar_variable function\n\nAuthor: Adam Theisen\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nfrom arm_test_data import DATASETS\n\nimport act\n\n# Read in the sample MET data\nmet_wildcard_list = [\n 'sgpmetE13.b1.20190101.000000.cdf',\n 'sgpmetE13.b1.20190102.000000.cdf',\n 'sgpmetE13.b1.20190103.000000.cdf',\n 'sgpmetE13.b1.20190104.000000.cdf',\n 'sgpmetE13.b1.20190105.000000.cdf',\n 'sgpmetE13.b1.20190106.000000.cdf',\n 'sgpmetE13.b1.20190107.000000.cdf',\n]\nmet_filenames = [DATASETS.fetch(file) for file in met_wildcard_list]\nds = act.io.arm.read_arm_netcdf(met_filenames)\n\n# Add the solar variable, including dawn/dusk to variable\nds = act.utils.geo_utils.add_solar_variable(ds)\n\n# Using the sun variable, only analyze daytime data\nds = ds.where(ds['sun_variable'] == 1)\n\n# Take daily mean using xarray features\nds = ds.resample(time='1d', skipna=True).mean()\n\n# Creat Plot Display\ndisplay = act.plotting.TimeSeriesDisplay(ds, figsize=(15, 10))\ndisplay.plot('temp_mean', linestyle='solid')\ndisplay.day_night_background()\nplt.show()\n\nds.close()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }