.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plots/surface_declarative.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_examples_plots_surface_declarative.py: ========================================= Surface Analysis using Declarative Syntax ========================================= The MetPy declarative syntax allows for a simplified interface to creating common meteorological analyses including surface observation plots. .. GENERATED FROM PYTHON SOURCE LINES 14-22 .. code-block:: default from datetime import datetime, timedelta import cartopy.crs as ccrs import pandas as pd from metpy.cbook import get_test_data import metpy.plots as mpplots .. GENERATED FROM PYTHON SOURCE LINES 23-29 **Getting the data** In this example, data is originally from the Iowa State ASOS archive (https://mesonet.agron.iastate.edu/request/download.phtml) downloaded through a separate Python script. The data are pre-processed to determine sky cover and weather symbols from text output. .. GENERATED FROM PYTHON SOURCE LINES 29-33 .. code-block:: default data = pd.read_csv(get_test_data('SFC_obs.csv', as_file_obj=False), infer_datetime_format=True, parse_dates=['valid']) .. GENERATED FROM PYTHON SOURCE LINES 34-38 **Plotting the data** Use the declarative plotting interface to plot surface observations over the state of Georgia. .. GENERATED FROM PYTHON SOURCE LINES 38-68 .. code-block:: default # Plotting the Observations using a 15 minute time window for surface observations obs = mpplots.PlotObs() obs.data = data obs.time = datetime(1993, 3, 12, 13) obs.time_window = timedelta(minutes=15) obs.level = None obs.fields = ['tmpf', 'dwpf', 'emsl', 'cloud_cover', 'wxsym'] obs.locations = ['NW', 'SW', 'NE', 'C', 'W'] obs.colors = ['red', 'green', 'black', 'black', 'blue'] obs.formats = [None, None, lambda v: format(10 * v, '.0f')[-3:], 'sky_cover', 'current_weather'] obs.vector_field = ('uwind', 'vwind') obs.reduce_points = 1 # Add map features for the particular panel panel = mpplots.MapPanel() panel.layout = (1, 1, 1) panel.area = 'ga' panel.projection = ccrs.PlateCarree() panel.layers = ['coastline', 'borders', 'states'] panel.plots = [obs] # Collecting panels for complete figure pc = mpplots.PanelContainer() pc.size = (10, 10) pc.panels = [panel] # Showing the results pc.show() .. image-sg:: /examples/plots/images/sphx_glr_surface_declarative_001.png :alt: tmpf and dwpf and emsl and cloud_cover and wxsym :srcset: /examples/plots/images/sphx_glr_surface_declarative_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.822 seconds) .. _sphx_glr_download_examples_plots_surface_declarative.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: surface_declarative.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: surface_declarative.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_