.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/comparisons/plot_cmaqairnow.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_comparisons_plot_cmaqairnow.py: Pairing CMAQ with AirNow Ozone ============================== This example performs a simple comparison of CMAQ to AirNow for ozone. .. GENERATED FROM PYTHON SOURCE LINES 7-47 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/comparisons/images/sphx_glr_plot_cmaqairnow_001.png :alt: LAY = 0.9987 :srcset: /auto_examples/comparisons/images/sphx_glr_plot_cmaqairnow_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/comparisons/images/sphx_glr_plot_cmaqairnow_002.png :alt: plot cmaqairnow :srcset: /auto_examples/comparisons/images/sphx_glr_plot_cmaqairnow_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none | | ozone | CMAQ_O3 | |:------|-----------:|--------------:| | count | 29089 | 30024 | | mean | 33.4526 | 32.9829 | | std | 16.2011 | 14.3848 | | min | 0 | 0.0621035 | | 25% | 22 | 22.3072 | | 50% | 33 | 31.535 | | 75% | 44 | 42.4275 | | max | 113 | 282.538 | | r | 1 | 0.77156 | | mb | 0 | -0.469692 | | nmb | 0 | -0.0140405 | | fmb | 0 | -0.0141398 | | ioa | 1 | 0.872455 | | .. code-block:: default import pyrsig import pycno cmaqkey = 'cmaq.equates.conus.aconc.O3' datakey = 'airnow.ozone' api = pyrsig.RsigApi() # Return CMAQ for default bbox (-126, 24, -66, -50) for a single day ds = api.to_ioapi(cmaqkey, bdate='2018-07-01') # pair_rsigcmaq will match the bbox, bdate, and edate from the CMAQ dataset. df = pyrsig.cmaq.pair_rsigcmaq(ds, 'O3', datakey) # Or, use persist=True to save pairing to disk and return output path instead. # import pandas as pd # outpath = pyrsig.cmaq.pair_rsigcmaq(ds, 'O3', datakey, persist=True) # df = pd.read_csv(outpath) # Calculate stats table with common quantile, correlation, and bias metrics statsdf = pyrsig.utils.quickstats(df[['ozone', 'CMAQ_O3']], 'ozone') # Print them for the user to review. print(statsdf.to_markdown()) dds = ds['O3'].mean('TSTEP') ddf = df.groupby(['x', 'y'], as_index=False).mean(numeric_only=True) qm = dds.plot() qm.axes.scatter( ddf.x, ddf.y, c=ddf.ozone, norm=qm.norm, cmap=qm.cmap, edgecolor='w' ) pycno.cno(ds.crs_proj4).drawstates() qm.figure.savefig('ozone_map.png') vmax = df[['ozone', 'CMAQ_O3']].max().max() ax = df.plot.hexbin(x='ozone', y='CMAQ_O3', mincnt=1, extent=(0, vmax, 0, vmax)) ax.set(xlabel='Obs Ozone [ppb]', ylabel='CMAQ [ppb]', facecolor='gainsboro') ax.axline((0, 0), slope=1, label='1:1') ax.collections[0].colorbar.set_label('count') ax.figure.savefig('ozone_scatter.png') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 20.835 seconds) .. _sphx_glr_download_auto_examples_comparisons_plot_cmaqairnow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_cmaqairnow.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_cmaqairnow.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_