.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/io/plot_nexrad_data_google_cloud.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_nexrad_data_google_cloud.py: ========================================= Reading NEXRAD Data from Google Cloud ========================================= Within this example, we show how you can remotely access Next Generation Weather Radar (NEXRAD) Data from Google Cloud Storage and plot quick looks of the datasets. .. GENERATED FROM PYTHON SOURCE LINES 10-24 .. code-block:: Python print(__doc__) # Author: Zach Sherman # License: BSD 3 clause import tarfile # This example requires installation of the gcsfs library import gcsfs import matplotlib.pyplot as plt import pyart .. GENERATED FROM PYTHON SOURCE LINES 25-37 Read NEXRAD Level 2 Data ------------------------ Let's start first with NEXRAD Level 2 data, which is ground-based radar data collected by the National Oceanic and Atmospheric Administration (NOAA), as a part of the National Weather Service ### Configure our Filepath for NEXRAD Level 2 Data We will access data from Google cloud storage, with the data organized as: ``gcp-public-data-nexrad-l2/year/month/day/radarsite/NWS_NEXRAD_NXL2DPBL_{radarsite}_{year}{month}{date}{hour}0000_{year}{month}{date}{hour}{minute}.tar`` Where in our case, we are using a sample data file from Miami, Florida (KAMX) on October 7, 2016, at 0401:25 UTC. This means our path would look like: .. GENERATED FROM PYTHON SOURCE LINES 37-40 .. code-block:: Python gcs_path = "gcp-public-data-nexrad-l2/2016/10/07/KAMX/NWS_NEXRAD_NXL2DPBL_KAMX_20161007040000_20161007045959.tar" .. GENERATED FROM PYTHON SOURCE LINES 41-42 First we can create a file system and retrieve the tar file to our current directory. .. GENERATED FROM PYTHON SOURCE LINES 42-45 .. code-block:: Python fs = gcsfs.GCSFileSystem() fs.get(gcs_path, ".") .. rst-class:: sphx-glr-script-out .. code-block:: none [None] .. GENERATED FROM PYTHON SOURCE LINES 46-47 The we can use the tarfile module to extract the files within. .. GENERATED FROM PYTHON SOURCE LINES 47-55 .. code-block:: Python file = tarfile.open("NWS_NEXRAD_NXL2DPBL_KAMX_20161007040000_20161007045959.tar") members = file.getmembers() # This case we are getting only the first file, use extract_all if wanting all files. file.extract(members[0].name, ".") file.close() .. GENERATED FROM PYTHON SOURCE LINES 56-57 We can use the **pyart.io.read_nexrad_archive** module to access our data, passing in the member filepath. .. GENERATED FROM PYTHON SOURCE LINES 57-60 .. code-block:: Python radar = pyart.io.read_nexrad_archive(members[0].name) .. GENERATED FROM PYTHON SOURCE LINES 61-62 Let's take a look at a summary of what fields are available. .. GENERATED FROM PYTHON SOURCE LINES 62-65 .. code-block:: Python print(list(radar.fields)) .. rst-class:: sphx-glr-script-out .. code-block:: none ['spectrum_width', 'differential_reflectivity', 'differential_phase', 'reflectivity', 'velocity', 'cross_correlation_ratio'] .. GENERATED FROM PYTHON SOURCE LINES 66-67 Let's plot the reflectivity field as a first step to investigating our dataset. .. GENERATED FROM PYTHON SOURCE LINES 67-73 .. code-block:: Python fig = plt.figure(figsize=(12, 4)) display = pyart.graph.RadarMapDisplay(radar) display.plot_ppi_map("reflectivity") plt.show() .. image-sg:: /examples/io/images/sphx_glr_plot_nexrad_data_google_cloud_001.png :alt: KAMX 0.5 Deg. 2016-10-07T04:05:25Z Equivalent reflectivity factor :srcset: /examples/io/images/sphx_glr_plot_nexrad_data_google_cloud_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 26.579 seconds) .. _sphx_glr_download_examples_io_plot_nexrad_data_google_cloud.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_nexrad_data_google_cloud.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_nexrad_data_google_cloud.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_nexrad_data_google_cloud.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_