.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/io/plot_older_nexrad_data_aws.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_io_plot_older_nexrad_data_aws.py: ================================================================== Reading Older NEXRAD Data and Fixing Latitude and Longitude Issues ================================================================== In this example, we will show how to read in older NEXRAD files prior to 2008 that are missing some coordinate metadata. .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: Python print(__doc__) # Author: Zachary Sherman (zsherman@anl.gov) # License: BSD 3 clause .. GENERATED FROM PYTHON SOURCE LINES 18-19 Import our required packages. .. GENERATED FROM PYTHON SOURCE LINES 19-25 .. code-block:: Python import cartopy.crs as ccrs import matplotlib.pyplot as plt import pyart .. GENERATED FROM PYTHON SOURCE LINES 26-41 Read older NEXRAD Level 2 Data ------------------------------ Older NEXRAD files prior to 2008, have the tendency to not contain some of the required metadata for Py-ART's NEXRAD reader. This usually results in missing latitude and longitude data, so after reading with Py-ART, both coordinates have a value of 0. This example, we will show how to properly read in an older NEXRAD file. First we want to get an older file from amazon web service: ``s3://noaa-nexrad-level2/year/month/date/radarsite/{radarsite}{year}{month}{date}_{hour}{minute}{second}.gz`` Where in our case, we are using a sample data file from Handford, CA (KHNX) on July 24, 2006, at 0203:38 UTC. This means our path would look like this: .. GENERATED FROM PYTHON SOURCE LINES 41-48 .. code-block:: Python # Note: Older files do not contain the 'V06' but instead '.gz' in the AWS path. aws_nexrad_level2_file = ( "s3://noaa-nexrad-level2/2006/07/24/KHNX/KHNX20060724_020338.gz" ) .. GENERATED FROM PYTHON SOURCE LINES 49-50 We can use the **pyart.io.read_nexrad_archive** module to access our data, passing in the filepath. .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python radar = pyart.io.read_nexrad_archive(aws_nexrad_level2_file) .. GENERATED FROM PYTHON SOURCE LINES 54-55 Now let us take a look at the radar latitude and longitude data. .. GENERATED FROM PYTHON SOURCE LINES 55-58 .. code-block:: Python print(radar.latitude["data"]) print(radar.longitude["data"]) .. rst-class:: sphx-glr-script-out .. code-block:: none [0.] [0.] .. GENERATED FROM PYTHON SOURCE LINES 59-64 This is clearly not correct! The problem is the reader could not find the metadata (message 31) for the coordinates. Lucky for us, we can provide the station in Py-ART's NEXRAD reader, which will pull the coordinate information from a dictionary found within Py-ART. .. GENERATED FROM PYTHON SOURCE LINES 64-67 .. code-block:: Python radar = pyart.io.read_nexrad_archive(aws_nexrad_level2_file, station="KHNX") .. GENERATED FROM PYTHON SOURCE LINES 68-69 Again, let us take a look at the radar latitude and longitude data. .. GENERATED FROM PYTHON SOURCE LINES 69-72 .. code-block:: Python print(radar.latitude["data"]) print(radar.longitude["data"]) .. rst-class:: sphx-glr-script-out .. code-block:: none [36.31417] [-119.63111] .. GENERATED FROM PYTHON SOURCE LINES 73-74 Everything now looks correct as this is in Handford CA! .. GENERATED FROM PYTHON SOURCE LINES 74-88 .. code-block:: Python # We can create a plot as well utilizing Cartopy to see how it looks. display = pyart.graph.RadarMapDisplay(radar) # Setting projection and ploting the first tilt. projection = ccrs.LambertConformal( central_latitude=radar.latitude["data"][0], central_longitude=radar.longitude["data"][0], ) fig = plt.figure(figsize=(6, 6)) display.plot_ppi_map( "reflectivity", 0, vmin=-20, vmax=54, projection=projection, resolution="10m" ) .. image-sg:: /examples/io/images/sphx_glr_plot_older_nexrad_data_aws_001.png :alt: KHNX 0.4 Deg. 2006-07-24T02:03:37Z Equivalent reflectivity factor :srcset: /examples/io/images/sphx_glr_plot_older_nexrad_data_aws_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 8.972 seconds) .. _sphx_glr_download_examples_io_plot_older_nexrad_data_aws.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_older_nexrad_data_aws.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_older_nexrad_data_aws.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_older_nexrad_data_aws.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_