{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Xarray Plotting Examples\n\nThis is an example of how to use some different aspects\nof ACT's plotting tools as well as Xarray's tools.\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# Set up plot space ahead of time\nfig, ax = plt.subplots(3, figsize=(10, 7))\n\n# Plotting up high-temporal resolution 2D data can be very slow at times.\n# In order to increase the speed, the data can be resampled to a courser\n# resolution prior to plotting. Using Xarray's resample and selecting\n# the nearest neighbor will greatly increase the speed.\nfilename_ceil = DATASETS.fetch('sgpceilC1.b1.20190101.000000.nc')\nds = act.io.arm.read_arm_netcdf(filename_ceil)\nds = ds.resample(time='1min').nearest()\n\n# These data can be plotted up using the existing xarray functionality\n# which is quick and easy\nds['backscatter'].plot(x='time', ax=ax[0])\n\n# or using ACT\ndisplay = act.plotting.TimeSeriesDisplay(ds)\ndisplay.assign_to_figure_axis(fig, ax[1])\ndisplay.plot('backscatter')\n\n# When using ACT, the axis object can also be manipulated using normal\n# matplotlib calls for more personalized customizations\ndisplay = act.plotting.TimeSeriesDisplay(ds)\ndisplay.assign_to_figure_axis(fig, ax[2])\ndisplay.plot('backscatter')\ndisplay.axes[-1].set_ylim([0, 1500])\n\nplt.show()" ] } ], "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 }