.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/maps/run_maps_01_compare.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_auto_examples_maps_run_maps_01_compare.py: Compare Two CAMx Runs ===================== This example compares the standard CAMx v7.3 tutorial simulation to one with updated emissions. The updated emissions come from earlier examples. Those examples adjusted NOx in four ways: 1. scaled mobile NOx across the whole 36km domain, 2. scaled mobile NOx within Georgia, 3. created a synthetic source, 4. increased NOx from a collection of stacks in a location, The plots created here show the changes in ozone in the 12km domain: * small increases around the domain edges from scaling in the 36km, * a small increase near the scaled collection of stack, and * larger increases near Atlanta due to NOx scaling in Georgia. *Reminder*: You must have already activated your python environment. .. GENERATED FROM PYTHON SOURCE LINES 24-26 Configuration ''''''''''''' .. GENERATED FROM PYTHON SOURCE LINES 26-36 .. code-block:: Python # date to process date = '20160610' # file to use as input oldpath = f'../../camx/outputs/CAMx.v7.32.36.12.{date}.avrg.grd02.nc' # file to create newpath = f'../../camx/outputs/CAMx.v7.32.36.12.{date}.2D_EDIT.avrg.grd02.nc' # figure demonstrating the change figpath = 'outputs/ozone_compare.png' .. GENERATED FROM PYTHON SOURCE LINES 37-39 Imports and File Prep ''''''''''''''''''''' .. GENERATED FROM PYTHON SOURCE LINES 39-49 .. code-block:: Python import pyrsig import pycno import numpy as np import os import matplotlib.pyplot as plt import matplotlib.colors as mc os.makedirs('outputs', exist_ok=True) .. GENERATED FROM PYTHON SOURCE LINES 50-54 Open Files '''''''''' - Open the existing file in read-only mode - Open the new file in read-only append mode .. GENERATED FROM PYTHON SOURCE LINES 54-59 .. code-block:: Python oldfile = pyrsig.open_ioapi(oldpath) newfile = pyrsig.open_ioapi(newpath) .. GENERATED FROM PYTHON SOURCE LINES 60-62 Plot Comparison ''''''''''''''' .. GENERATED FROM PYTHON SOURCE LINES 62-87 .. code-block:: Python oldfile = pyrsig.open_ioapi(oldpath) newfile = pyrsig.open_ioapi(newpath) key = 'O3' compfile = newfile[[]] compfile['New'] = newfile[key].isel(LAY=0).max('TSTEP') * 1000 compfile['Old'] = oldfile[key].isel(LAY=0).max('TSTEP') * 1000 Z = compfile.to_dataarray(dim='version') Z.attrs.update(oldfile[key].attrs, units='ppb') fca = Z.plot(col='version', norm=mc.Normalize(0)) dZ = np.abs(compfile['New'] - compfile['Old']) levels = [1, 5, 10] for ax in fca.axs.ravel(): cs = dZ.plot.contour(levels=levels, colors=['grey', 'w', 'r'], ax=ax, add_labels=False) cl, clbl = cs.legend_elements() clbl = [f'+{v:.0f}ppb' for v in levels] ax.legend(cl, clbl) pycno.cno(oldfile.crs_proj4).drawstates(ax=fca.axs) fca.fig.savefig(figpath) .. image-sg:: /auto_examples/maps/images/sphx_glr_run_maps_01_compare_001.png :alt: version = New, version = Old :srcset: /auto_examples/maps/images/sphx_glr_run_maps_01_compare_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.172 seconds) .. _sphx_glr_download_auto_examples_maps_run_maps_01_compare.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_maps_01_compare.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_maps_01_compare.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: run_maps_01_compare.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_