.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/raqms_example.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_raqms_example.py: RAQMS LBC for CMAQ ================================ This example shows how to use aqmbc with RAQMS's publicly available forecasts. * Download from RAQMS (only if not available in RAQMS folder). * Define translation. * Extract and translate. * Display figures and statistics. .. GENERATED FROM PYTHON SOURCE LINES 11-20 .. code-block:: default from os.path import basename import aqmbc import glob import pandas as pd import matplotlib.pyplot as plt gdnam = '12US1' .. GENERATED FROM PYTHON SOURCE LINES 21-23 Download from RAQMS via HTTP ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 23-31 .. code-block:: default todayat12z = ( pd.to_datetime('now', utc=True).floor('1d') + pd.to_timedelta('12h') ) dates = [todayat12z] aqmbc.models.raqms.download(dates) .. GENERATED FROM PYTHON SOURCE LINES 32-34 Define Translation Expressions ------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 34-38 .. code-block:: default # In Notebooks, display available expressions aqmbc.exprlib.avail('raqms') .. GENERATED FROM PYTHON SOURCE LINES 39-45 .. code-block:: default exprpaths = aqmbc.exprlib.exprpaths([ 'raqms_o3so4.expr' # 'raqms_to_cb6r4_ae6.expr' # for full run ], prefix='raqms') .. GENERATED FROM PYTHON SOURCE LINES 46-48 Translate RAQMS for use by CMAQ ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 48-68 .. code-block:: default # For "real" VGLVLS use # METBDYD_PATH = '...' # metaf = pnc.pncopen(METBDY3D_PATH, format='ioapi') metaf = aqmbc.options.getmetaf(bctype='bcon', gdnam=gdnam, vgnam='EPA_35L') inpaths = sorted(glob.glob('RAQMS/uwhyb*.nc')) bcpaths = [] suffix = f'_{gdnam}_BCON.nc' gcdims = aqmbc.options.dims['raqms'] for inpath in inpaths: print(inpath, flush=True) outpath = basename(inpath).replace('.nc', suffix) history = f'From {outpath}' outf = aqmbc.bc( inpath, outpath, metaf, vmethod='linear', exprpaths=exprpaths, dimkeys=gcdims, format_kw={'format': 'raqms'}, history=history, clobber=True, verbose=0 ) bcpaths.append(outpath) .. GENERATED FROM PYTHON SOURCE LINES 69-71 Figures and Statistics ---------------------- .. GENERATED FROM PYTHON SOURCE LINES 71-76 .. code-block:: default vprof = aqmbc.report.get_vertprof(bcpaths) statdf = aqmbc.report.getstats(bcpaths) statdf.to_csv('raqms_summary.csv') .. GENERATED FROM PYTHON SOURCE LINES 77-79 Visualize Vertical Profiles --------------------------- .. GENERATED FROM PYTHON SOURCE LINES 79-84 .. code-block:: default fig = aqmbc.report.plot_2spc_vprof(vprof) fig.suptitle('RAQMS Boundary Conditions for CMAQ') fig.savefig('raqms_profiles.png') .. GENERATED FROM PYTHON SOURCE LINES 85-87 Barplot of Concentrations ------------------------- .. GENERATED FROM PYTHON SOURCE LINES 87-90 .. code-block:: default fig = aqmbc.report.plot_gaspm_bars(statdf) fig.savefig('raqms_bar.png') .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_raqms_example.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: raqms_example.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: raqms_example.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_