{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Plot multiple datasets\n\nThis is an example of how to download and\nplot multiple datasets at a time.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import os\n\nimport matplotlib.pyplot as plt\nfrom arm_test_data import DATASETS\n\nimport act\n\n# Place your username and token here\nusername = os.getenv('ARM_USERNAME')\ntoken = os.getenv('ARM_PASSWORD')\n\n# Get data from the web service if username and token are available\n# if not, use test data\nif username is None or token is None or len(username) == 0 or len(token) == 0:\n filename_ceil = DATASETS.fetch('sgpceilC1.b1.20190101.000000.nc')\n ceil_ds = act.io.arm.read_arm_netcdf(filename_ceil)\n filename_met = DATASETS.fetch('sgpmetE13.b1.20190101.000000.cdf')\n met_ds = act.io.arm.read_arm_netcdf(filename_met)\nelse:\n # Download and read data\n results = act.discovery.download_arm_data(\n username, token, 'sgpceilC1.b1', '2022-01-01', '2022-01-07'\n )\n ceil_ds = act.io.arm.read_arm_netcdf(results)\n results = act.discovery.download_arm_data(\n username, token, 'sgpmetE13.b1', '2022-01-01', '2022-01-07'\n )\n met_ds = act.io.arm.read_arm_netcdf(results)\n\n# Read in CEIL data and correct it\nceil_ds = act.corrections.ceil.correct_ceil(ceil_ds, -9999.0)\n\n\n# You can use tuples if the datasets in the tuple contain a\n# datastream attribute. This is required in all ARM datasets.\ndisplay = act.plotting.TimeSeriesDisplay((ceil_ds, met_ds), subplot_shape=(2,), figsize=(15, 10))\ndisplay.plot('backscatter', 'sgpceilC1.b1', subplot_index=(0,))\ndisplay.plot('temp_mean', 'sgpmetE13.b1', subplot_index=(1,))\ndisplay.day_night_background('sgpmetE13.b1', subplot_index=(1,))\nplt.show()\n\n# You can also use a dictionary so that you can customize\n# your datastream names to something that may be more useful.\ndisplay = act.plotting.TimeSeriesDisplay(\n {'ceiliometer': ceil_ds, 'met': met_ds}, subplot_shape=(2,), figsize=(15, 10)\n)\ndisplay.plot('backscatter', 'ceiliometer', subplot_index=(0,))\ndisplay.plot('temp_mean', 'met', subplot_index=(1,))\ndisplay.day_night_background('met', subplot_index=(1,))\nplt.show()\n\nceil_ds.close()\nmet_ds.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 }