{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Calculate and View Aerosol Percentages\n\nCalculate the percentages of different aerosols in a Aerosol\nChemical Speciation (AOS) monitor dataset and view the percentages\nin a pie chart.\n\nWritten: Zach Sherman\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\nfrom act.io.arm import read_arm_netcdf\n\n# Read an ARM AOS dataset\nfilename = DATASETS.fetch('sgpaosacsmE13.b2.20230420.000109.nc')\nds = read_arm_netcdf(filename)\n\n# Let us print out the fields in the dataset and see what it contains.\nprint(ds.data_vars.keys())\n\n# Knowing what fields the dataset contains, let's create a list of fields\n# to use in the plot.\n\nfields = ['sulfate', 'ammonium', 'nitrate', 'chloride']\n\n# We also want to provide some keyword arguments to avoid invalid data such\n# as negative values.\nthreshold = 0.0\nfill_value = 0.0\n\n# Create a DistributionDisplay object to compare fields\ndisplay = act.plotting.DistributionDisplay(ds)\n\n# We can set one of the slices to explode and give it a nice shadow.\nexplode = (0, 0.1, 0, 0)\nshadow = True\n\n# Create a pie chart using the fields list. The percentages of the\n# fields will be calculated using act.utils.calculate_percentages.\ndisplay.plot_pie_chart(\n fields,\n threshold=threshold,\n fill_value=fill_value,\n explode=explode,\n shadow=True,\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 }