### Install Py-ART from Source Source: https://github.com/arm-doe/pyart/blob/main/doc/source/index.rst Installs Py-ART by cloning the git repository or downloading the source code zip file and running the setup script. This method is for installing the latest, unreleased version. ```bash python setup.py install ``` -------------------------------- ### Install Py-ART Locally from Source Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Install Py-ART locally for the current user using the setup.py script. ```bash $ python setup.py install --user ``` -------------------------------- ### Install Py-ART Globally from Source Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Install Py-ART globally using the setup.py script after specifying the TRMM RSL path. ```bash $ python setup.py install ``` -------------------------------- ### Install Py-ART for All Users (Unix/Linux) Source: https://github.com/arm-doe/pyart/blob/main/README.rst Build and install Py-ART for all users on a Unix/Linux system. This typically requires administrator privileges. ```bash python setup.py build sudo python setup.py install ``` -------------------------------- ### Install Py-ART for User Source: https://github.com/arm-doe/pyart/blob/main/README.rst Install Py-ART into your home directory. This is useful for personal use without requiring administrator privileges. ```bash python setup.py install --user ``` -------------------------------- ### Install open-radar-data for Test Files Source: https://github.com/arm-doe/pyart/blob/main/README.rst Install the open-radar-data package using conda. This package provides test files used in Py-ART's example gallery. ```bash $ conda install -c conda-forge open-radar-data ``` -------------------------------- ### Install Py-ART on Windows using Anaconda Source: https://github.com/arm-doe/pyart/wiki/Simple-Install-of-Py-ART-using-Anaconda Execute these commands in a command prompt or PowerShell to install Py-ART and dependencies on Windows. Answer 'Y' when prompted to install additional packages. ```bash conda update conda conda install basemap netcdf4 conda install -c conda-forge arm_pyart ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Run this command in the Py-ART repository to install pre-commit hooks. These hooks will automatically run on every commit to enforce code style. ```bash pre-commit install ``` -------------------------------- ### Install Py-ART 2.0 Release Candidate Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/pyart_2_0.rst Install the release candidate of Py-ART 2.0 directly from GitHub. This is a work in progress and feedback is welcome. ```bash pip install git+https://github.com/ARM-DOE/pyart@release/2.0 ``` -------------------------------- ### Install Python 3 Compatible CyLP from GitHub Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Installs a Python 3 compatible version of CyLP directly from its GitHub repository using pip. This command should be run after setting the COIN_INSTALL_DIR environment variable. ```bash pip install git+https://github.com/jjhelmus/CyLP.git@py3 ``` -------------------------------- ### Correct Pip Installation for Py-ART Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Ensure you install the correct Py-ART package from ARM using 'pip install arm_pyart' to avoid conflicts with other packages named 'pyart'. ```bash pip install arm_pyart ``` -------------------------------- ### Export Coincbc Installation Path Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Sets the COIN_INSTALL_DIR environment variable. This is necessary for CyLP to locate the coincbc installation, especially when installing CyLP from a GitHub repository. ```bash export COIN_INSTALL_DIR=/Users/yourusername/youranacondadir/envs/pyart_env ``` ```bash export COIN_INSTALL_DIR=/home/zsherman/anaconda3/envs/pyart_env ``` -------------------------------- ### Install Required Packages Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2023/severe-storms-southern-wisconsin.ipynb Installs the necessary Python packages for radar data analysis and visualization using conda. ```bash conda install -c conda-forge arm_pyart metpy cartopy pandas numpy shapely ``` -------------------------------- ### Install Py-ART in Development Mode Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Install Py-ART in development mode using pip, allowing for direct code modifications. ```bash $ pip install -e . ``` -------------------------------- ### Development Install Py-ART with Pip Source: https://github.com/arm-doe/pyart/blob/main/README.rst Perform a development installation using pip from within the Py-ART source directory. This allows for immediate use of changes made to the source code. ```bash pip install -e . ``` -------------------------------- ### Example Function Docstring Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Illustrates the expected format for function docstrings, including parameter types, explanations, units, and return values. ```python def u_wind(self): """ U component of horizontal wind in meters per second. """ ``` -------------------------------- ### Avoid Incorrect Pip Installation Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Do not install the incorrect 'pyart' package from pip, as it is a different package and may cause issues. ```bash pip install pyart ``` -------------------------------- ### Create Environment from Scratch Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Creates a new conda environment named 'pyart_env' and installs specified packages (arm_pyart, netCDF4, cartopy, scipy, numpy, matplotlib) from the conda-forge channel. ```bash conda create -n pyart_env -c conda-forge arm_pyart netCDF4 cartopy scipy numpy matplotlib ``` -------------------------------- ### Install Py-ART with Conda Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Use this command to install the latest version of Py-ART from the conda-forge channel. ```bash conda install -c conda-forge arm_pyart ``` -------------------------------- ### Install Package with Conda-Forge Channel Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Installs a package, such as numpy, using the conda-forge channel. This can be done directly during installation if the channel was not previously added as a priority. ```bash conda install -c conda-forge numpy ``` -------------------------------- ### Install Py-ART with Mamba Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst This command installs Py-ART using mamba, a faster package manager for conda. ```bash mamba install -c conda-forge arm_pyart ``` -------------------------------- ### Install Py-ART on Mac OS X using Anaconda Source: https://github.com/arm-doe/pyart/wiki/Simple-Install-of-Py-ART-using-Anaconda Use these commands in the terminal to install Py-ART and dependencies on macOS. Answer 'Y' when prompted to install additional packages. ```bash conda update conda conda install -c conda-forge arm_pyart conda install basemap ``` -------------------------------- ### Install Pytest for Testing Source: https://github.com/arm-doe/pyart/blob/main/README.rst Install pytest, a popular Python testing framework, using conda. Pytest is used for running Py-ART's unit tests. ```bash $ conda install -c conda-forge pytest ``` -------------------------------- ### Create Basic Conda Environment Source: https://github.com/arm-doe/pyart/blob/main/doc/source/index.rst Creates a new conda environment named 'pyart_env' and installs the Py-ART package from the conda-forge channel, downloading optional dependencies as needed. ```bash conda create -n pyart_env -c conda-forge arm_pyart ``` -------------------------------- ### Install Coincbc Dependency Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Installs the 'coincbc' package from the conda-forge channel, which is a dependency for CyLP. This should be done within the activated 'pyart_env'. ```bash conda install -c conda-forge coincbc ``` -------------------------------- ### Clone Py-ART Repository Source: https://github.com/arm-doe/pyart/blob/main/README.rst Use git to clone the latest source code from GitHub. This is the first step for both installation and development. ```bash git clone https://github.com/ARM-DOE/pyart.git ``` -------------------------------- ### List Available Datasets Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Use this snippet to view the files available in the open-radar-data repository for use in example scripts. ```python from open_radar_data import DATASETS print(DATASETS.registry_files) ``` -------------------------------- ### NumPy Docstring Style Example Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst This example demonstrates the NumPy docstring format for function documentation, including parameters and other relevant information. ```python def velocity_azimuth_display( radar, velocity=None, z_want=None, valid_ray_min=16, gatefilter=False, window=2): """ Velocity azimuth display. Parameters ---------- radar : Radar Radar object used. velocity : string Velocity field to use for VAD calculation. If None, the default velocity field will be used. Other Parameters ---------------- z_want : array Height array user would like for the VAD calculation. None will result in a z_want of np.linspace and use of _inverse_dist_squared and _Average1D functions. Note, height must have same shape as expected u_wind and v_wind if user ``` -------------------------------- ### Fetch a Dataset File Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Use this snippet to download a specific file from the open-radar-data repository for use in examples. ```python files = DATASETS.fetch('gucxprecipradarcmacppiS2.c1.20220314.025840.nc') ``` -------------------------------- ### Import Py-ART Modules Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/the_pyart_radar_object_and_indexing.ipynb Import necessary libraries for working with Py-ART. Ensure numpy and pyart are installed. ```python # Import needed modules import numpy as np import pyart ``` -------------------------------- ### Configure and Install TRMM RSL Library Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/first_pullrequest.ipynb Configure and install the TRMM RSL Library. Ensure the library's location is added to your PATH by exporting it in your shell's configuration file (e.g., ~/.kshrc). ```bash ./configure ``` ```bash make install ``` ```bash export PATH="/opt/rsl-v1.50/:$PATH" ``` -------------------------------- ### Clone Py-ART Repository Source: https://github.com/arm-doe/pyart/wiki/Getting-started-with-Py-ART-development Clone your forked Py-ART repository to your local machine. Ensure you have git installed. ```bash git clone https://github.com/github_username/pyart.git ``` -------------------------------- ### Download ARM data using ACT Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/epcape-blog-post.ipynb This example demonstrates how to download netCDF files from a specified datastream within a date range using the `download_arm_data` function. Ensure you replace placeholder values with your actual ARM Live username and token. The data will be saved in a directory named after the datastream. ```python act.discovery.download_data( "userName", "XXXXXXXXXXXXXXXX", "sgpmetE13.b1", "2017-01-14", "2017-01-20" ) ``` -------------------------------- ### Compile Py-ART Extensions In-Place Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Compile Py-ART extensions in-place to use the library without a formal installation, by adding its path to PYTHONPATH. ```bash $ python setup.py build_ext -i ``` -------------------------------- ### Initialize NexradAwsInterface and Get Scans Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/hail-analysis-spc.ipynb Initializes the NexradAwsInterface and retrieves available radar scans within a specified time range for a given radar ID. This prepares for downloading the data. ```python # Configure the nexrad interface using our time and location conn = nexradaws.NexradAwsInterface() scans = conn.get_avail_scans_in_range(start, end, radar_id) print("There are {} scans available between {} and \n".format(len(scans), start, end)) ``` -------------------------------- ### Import Necessary Modules Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/changing_fields_and_saving.ipynb Imports required libraries for radar data manipulation, plotting, and numerical operations. Ensure these are installed before running. ```python import cartopy.crs as ccrs import matplotlib.pyplot as plt import numpy as np import pyart ``` -------------------------------- ### Launch Coding Editors Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Launches various Python-based coding editors or interactive environments from the command line within the activated conda environment. The available options depend on what has been installed. ```bash python ``` ```bash ipython ``` ```bash jupyter notebook ``` ```bash spyder ``` -------------------------------- ### Display `download_arm_data` function signature Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/epcape-blog-post.ipynb This snippet displays the signature of the `download_arm_data` function from the ACT library. It shows the required parameters such as username, token, datastream, start date, and end date, along with optional parameters for time and output directory. ```python ?act.discovery.download_arm_data ``` -------------------------------- ### Initialize Py-ART Environment with Pixi Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Use pixi to create a new environment for Py-ART development and add the pyart package. ```bash $ pixi init pyart_dev $ cd pyart_dev $ pixi add arm_pyart ``` -------------------------------- ### Visualize Gridded Data with cmweather Colormaps Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/pyart_2_0.rst Example of plotting gridded radar data using Py-ART's GridMapDisplay. It shows how to use colormaps from the cmweather package, replacing Py-ART's older colormap names. ```python import cmweather display = pyart.graph.GridMapDisplay(grid) display.plot_grid( "reflectivity_horizontal", level=0, vmin=-20, vmax=60, cmap="ChaseSpectral" ) ``` -------------------------------- ### List and Download GOES Data Files Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/TRACER.ipynb Use s3fs to connect to an S3 bucket anonymously, list files for a specific GOES satellite product and time, and download relevant files. Ensure the 'data' directory exists before running. ```python fs = s3fs.S3FileSystem(anon=True) day_no = 168 # Day number of year (here is June 17th, 16th on leap year) year = 2022 hour = 20 files = np.array(fs.ls("noaa-goes16/ABI-L1b-RadC/%d/%d/%02d/" % (year, day_no, hour))) band = "13" for fi in files: if "C13" in fi: print("Downloading %s" % fi) fs.get(fi, "../data/" + fi.split("/")[-1]) ``` -------------------------------- ### Python File Module Introduction Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst The top of a new Python file should include a brief introductory docstring explaining the module's purpose. ```python """ Retrieval of VADs from a radar object. """ ``` -------------------------------- ### Build Py-ART In-Place Source: https://github.com/arm-doe/pyart/wiki/Getting-started-with-Py-ART-development Build Py-ART in-place to make the module available in Python. This command should be run from within the cloned pyart directory. ```bash python setup.py build_ext -i ``` -------------------------------- ### Create Conda Environment Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/first_pullrequest.ipynb Create a new conda environment named 'pyart-docs' from the provided environment.yml file. This environment contains packages necessary for active development. ```bash conda env create -f environment.yml ``` -------------------------------- ### Investigate plt.pcolormesh Parameters Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/plot-nexrad-level3.ipynb Use the question mark to display the signature and docstring for the `plt.pcolormesh` function. This is useful for understanding its available parameters and usage. ```python ?plt.pcolormesh ``` -------------------------------- ### Create Environment from Scratch Source: https://github.com/arm-doe/pyart/blob/main/guides/setting_up_an_environment.rst Creates a new conda environment named 'pyart_env' with specified packages like Python 3.8, arm_pyart, netCDF4, cartopy, scipy, numpy, and matplotlib, using the conda-forge channel. ```bash conda create -n pyart_env -c conda-forge python=3.8 arm_pyart netCDF4 cartopy scipy numpy matplotlib ``` -------------------------------- ### Install Jupyter Notebook in Activated Environment Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Installs Jupyter Notebook within the currently activated conda environment. Ensure the environment is activated before running this command. ```bash conda install -c conda-forge jupyter notebook ``` -------------------------------- ### Importing Libraries and Setting Up Data Retrieval Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/animated-gifs-with-pyart.ipynb Imports necessary libraries for radar data processing, plotting, and GIF creation. Sets up S3 filesystem access, defines time ranges, station details, and geographic points of interest for data retrieval. ```python import pyart import fsspec import matplotlib.pyplot as plt import os from io import BytesIO import warnings import cartopy.crs as ccrs from metpy.plots import USCOUNTIES from PIL import Image from datetime import datetime, timedelta from IPython.display import display, Image as IPImage %matplotlib inline warnings.filterwarnings("ignore") fs = fsspec.filesystem("s3", anon=True) # Define the start and end dates and hours start_date = datetime(2024, 6, 5, 4, 0) # YYYY/MM/DD HH end_date = datetime(2024, 6, 5, 4, 0) # YYYY/MM/DD HH station = "KLOT" latitude = [41.700937896518866, 41.704120] longitude = [-87.99578103231573, -87.968328] labels = ["Tower", "SCM"] markers = ["v", "o"] colors = ["magenta", "cyan"] # Generate the list of files for the specified date and hour range files = [] current_date = start_date while current_date <= end_date: date_str = current_date.strftime("%Y/%m/%d") date_str_compact = current_date.strftime("%Y%m%d") if current_date.date() == start_date.date(): start_hour = start_date.hour else: start_hour = 0 if current_date.date() == end_date.date(): end_hour = end_date.hour else: end_hour = 23 for hour in range(start_hour, end_hour + 1): hour_str = f"{hour:02d}" all_files = fs.glob( f"s3://noaa-nexrad-level2/{date_str}/{station}/{station}{date_str_compact}_{hour_str}*" ) filtered_files = [f for f in all_files if not f.endswith("_MDM")] files += sorted(filtered_files) current_date = current_date.replace(hour=0) + timedelta(days=1) ``` -------------------------------- ### Get range data shape Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/basic_ingest_using_test_radar_object.ipynb Determine the shape of the range data array. ```python data["range"][:].shape ``` -------------------------------- ### Get azimuth data shape Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/basic_ingest_using_test_radar_object.ipynb Determine the shape of the azimuth data array. ```python data["azimuth"][:].shape ``` -------------------------------- ### Prepare Data for KDTree and Plotting Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/TRACER.ipynb Extracts RHI gate locations, prepares lightning strike and RHI gate data for KDTree, and performs nearest neighbor queries. Ensure `KDTree` is imported. ```python rhi_lons = csapr_rhi.gate_longitude["data"].flatten() rhi_lats = csapr_rhi.gate_latitude["data"].flatten() rhi_alts = csapr_rhi.gate_altitude["data"].flatten() kdtree_data = np.stack([rhi_lons, rhi_lats], axis=1) kdtree = KDTree(kdtree_data) inp_data = np.stack([flash_lons, flash_lats], axis=1) dist, where_in_rhi = kdtree.query(inp_data) flash_ranges = csapr_rhi.range["data"][where_in_rhi % csapr_rhi.ngates] ``` -------------------------------- ### Get Metadata for Reflectivity Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/basic_ingest_using_test_radar_object.ipynb Retrieve metadata for a specific field, such as reflectivity, using `get_metadata`. ```python from pyart.config import get_metadata ref_dict = get_metadata("reflecitivity_horizontal") ``` -------------------------------- ### Update Py-ART with Conda Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Use this command to update an existing Py-ART installation to the latest release. ```bash conda update -c conda-forge arm_pyart ``` -------------------------------- ### Load and Subset TRACER Data for Overlays Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/TRACER.ipynb Loads GOES IR radiance, CSAPR radar, and LMA flash data. It then calculates latitude and longitude bounds for subsetting the data based on specified ranges. ```python goes_ds = xr.open_dataset( "../data/OR_ABI-L1b-RadC-M6C13_G16_s20221682056178_e20221682058562_c20221682059029.nc" ) csapr = pyart.io.read( "/Users/rjackson/TRACER-PAWS-NEXRAD-LMA/data/houcsapr2cfrS2.a1.20220617.203229.nc" ) lma_ds = xr.open_dataset( "/Users/rjackson/TRACER-PAWS-NEXRAD-LMA/data/LYLOUT_220617_000000_86400_map500m.nc" ) lma_ds lat, lon = calculate_degrees(goes_ds) lat = np.nan_to_num(lat, -9999) lon = np.nan_to_num(lon, -9999) lat_range = (25.0, 35.0) lon_range = (-100.0, -95.0) lat_min = lat.min(axis=1) lat_max = lat.max(axis=1) lat_min_bound = np.argmin(np.abs(lat_min - lat_range[0])) lat_max_bound = np.argmin(np.abs(lat_max - lat_range[1])) lon_min = lon.min(axis=0) lon_max = lon.max(axis=0) lon_min_bound = np.argmin(np.abs(lon_min - lon_range[0])) lon_max_bound = np.argmin(np.abs(lon_max - lon_range[1])) ``` -------------------------------- ### Switch Between Branches Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Command to change your current working branch. ```bash git checkout ``` -------------------------------- ### Activate and Deactivate Conda Environment Source: https://github.com/arm-doe/pyart/blob/main/guides/setting_up_an_environment.rst Commands to activate the 'pyart_env' environment before installing packages or running applications, and to deactivate it when finished. ```bash source activate pyart_env ``` ```bash source deactivate pyart_env ``` -------------------------------- ### Get Elevation for a Specific Sweep Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/the_pyart_radar_object_and_indexing.ipynb Use the get_slice() function to extract the elevation data for a single sweep from the radar object. ```python # If we just want the elevations of one sweep, we can use the get_slice() function ``` -------------------------------- ### Create a New Branch Source: https://github.com/arm-doe/pyart/blob/main/CONTRIBUTING.rst Command to create and switch to a new branch for development. ```bash git checkout -b ``` -------------------------------- ### Import Necessary Modules in Py-ART Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/mapping_data_to_a_cartesian_grid.ipynb Import the required libraries for data manipulation, plotting, and Py-ART functionality. Ensure these are installed before running. ```python # First import needed modules import matplotlib.pyplot as plt import numpy as np import pyart ``` -------------------------------- ### Get Projection Parameters Source: https://github.com/arm-doe/pyart/blob/main/examples/plotting/radar-cross-section.ipynb Retrieves the projection parameters from the grid object. These parameters are essential for correctly interpreting and displaying the spatial data. ```python params = grid.get_projparams() ``` -------------------------------- ### Create Frames for Animated GIF Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/animated-gifs-with-pyart.ipynb Generates individual PNG frames for an animated GIF by plotting radar reflectivity data for each sweep. Requires PyART, Matplotlib, and Cartopy. Ensure necessary data (files, latitude, longitude, labels, markers, colors) and directories are set up prior to execution. ```python # Create directories for the frames frames_dir = "frames/PPI" os.makedirs(frames_dir, exist_ok=True) # Create frames for the animated GIF frames = [] # Loop through each radar file for i, file in enumerate(files): radar = read_radar_data(file) if radar is None: print(f"Skipping file {file} due to read error.") continue # Create a plot for the first sweep's reflectivity fig = plt.figure(figsize=[12, 8]) ax = plt.subplot(111, projection=ccrs.PlateCarree()) radar_display = pyart.graph.RadarMapDisplay(radar) try: radar_display.plot_ppi_map( "reflectivity", sweep=0, vmin=10, vmax=65, ax=ax, title=f"Z for {os.path.basename(file)}", cmap="pyart_ChaseSpectral", colorbar_flag=False, ) # Disable the built-in colorbar mappable = radar_display.plots[0] except Exception as e: print(f"Error plotting radar data for file {file}: {e}") plt.close(fig) continue # Set the extent to zoom in much closer and centered on the points plt.xlim(-88.2, -87.7) plt.ylim(41.5, 41.9) # Add counties ax.add_feature(USCOUNTIES, linewidth=0.5) for lat, lon, label, marker, color in zip( latitude, longitude, labels, markers, colors ): ax.plot( lon, lat, marker, label=label, color=color, transform=ccrs.PlateCarree(), markersize=10, ) # Create a colorbar manually plt.tight_layout() cbar = plt.colorbar( mappable, ax=ax, orientation="vertical", fraction=0.046, pad=0.04 ) cbar.set_label("equivalent reflectivity factor (dBZ)") # Save the plot to a file filename = os.path.join(frames_dir, f"radar_frame_{i}.png") plt.legend(loc="upper right", fontsize="large", title="Locations") plt.savefig(filename, bbox_inches="tight") plt.close(fig) # Add the file to the frames list frames.append(filename) ``` -------------------------------- ### Add Conda-Forge Channel Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Adds the conda-forge channel as a priority for package installations. This is recommended for Py-ART as it often contains the most recent package versions. ```bash conda config --add channels conda-forge ``` -------------------------------- ### Set ARM Data Download Credentials Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/epcape-blog-post.ipynb Provide your ARM username, token, datastream, and date range to download data. ```python username = "USERNAME" token = "TOKEN" datastream = "epckasacrcfrS2.a1" startdate = "2024-01-21T01:00:00" enddate = "2024-01-21T01:30:00" ``` -------------------------------- ### Get Latitude and Longitude Coordinates Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/plot-nexrad-level3.ipynb Retrieves the latitude and longitude coordinates for a given radar sweep. Assumes a single sweep (index 0). ```python lats, lons, alt = radar.get_gate_lat_lon_alt(0) lats, lons ``` -------------------------------- ### Activate Environment Source: https://github.com/arm-doe/pyart/blob/main/doc/source/userguide/setting_up_an_environment.rst Activates the 'pyart_env' environment. Once activated, commands will operate within this isolated environment. ```bash source activate pyart_env ``` -------------------------------- ### Get Elevation Data for a Specific Sweep Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/the_pyart_radar_object_and_indexing.ipynb Access the elevation data for a specific sweep of the radar. This is useful for isolating data from a particular scan. ```python sweep_1 = radar.get_slice(1) print(radar.elevation["data"][sweep_1]) ``` -------------------------------- ### Load Radar File with Py-ART Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/the_pyart_radar_object_and_indexing.ipynb Load a radar file using pyart.io.read. This function is used to access radar data for analysis. ```python # Load the radar file radar = pyart.io.read("KATX20130717_195021_V06") ``` -------------------------------- ### Run Py-ART Tests with Pytest Source: https://github.com/arm-doe/pyart/blob/main/README.rst Execute the Py-ART test suite using pytest. This command can be run from outside the source directory if pytest is installed. ```bash $ pytest --pyargs pyart ``` -------------------------------- ### Read CSAPR NetCDF File with Py-ART Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/TRACER.ipynb Reads a CSAPR NetCDF file using the Py-ART library. Ensure Py-ART is installed and the file path is correct. ```python csapr = pyart.io.read( "/Users/rjackson/TRACER-PAWS-NEXRAD-LMA/data/houcsapr2cfrS2.a1.20220712.200714.nc" ) ``` -------------------------------- ### Plot Cross-Section with Custom Grid Source: https://github.com/arm-doe/pyart/blob/main/examples/plotting/radar-cross-section.ipynb Creates a cross-section plot from a generated target grid. This example demonstrates plotting the 'reflectivity' field using latitude as the x-axis. ```python fig = plt.figure() start = (34.8, -98.75) end = (38.6, -96.45) grid = pyart.testing.make_target_grid() display = pyart.graph.GridMapDisplay(grid) display.plot_cross_section("reflectivity", start, end, x_axis="lat", vmin=-5, vmax=35) ``` -------------------------------- ### Create and Push Git Tag Source: https://github.com/arm-doe/pyart/blob/main/doc/source/dev/how_to_release.rst Create a new annotated Git tag for the release and push it to the upstream repository. Ensure no commits are made to the tag after creation to avoid breaking PyPI versioning. ```bash git tag -a v1.8.0 -m "Py-ART version 1.8.0" git push --tags upstream master ``` -------------------------------- ### Git Commit Command Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2022/first_pullrequest.ipynb This command stages changes for commit and allows for writing a commit message. The message explains the purpose of the changes, and lines starting with '#' are ignored. ```bash (pyart-docs) git commit hint: Waiting for your editor to close the file... ENH: PyART doc static image color schemes changed to colorblind friendly PyART scheme. plot_ppi_mdv.py modified for this change. plot_rhi_cfradial_singlescan.py created to create one rhi cfradial plot for the docs. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch blog_PR # Changes to be committed: # modified: ../../doc/source/_static/ppi.png # modified: ../../doc/source/_static/rhi.png # modified: plot_ppi_mdv.py # new file: plot_rhi_cfradial_singlescan.py ``` -------------------------------- ### Assign Sweep Start Ray Index Data to Radar Object Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/basic_ingest_using_test_radar_object.ipynb Assigns the 'sweep_start_ray_index' data from a dictionary to the 'sweep_start_ray_index' attribute of the radar object. Ensure it is a NumPy array. ```python radar.sweep_start_ray_index["data"] = np.array(data["sweep_start_ray_index"]) ``` -------------------------------- ### Print Sorted File Lists Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/epcape-blog-post.ipynb Display the lists of PPI and RHI files after sorting them by scan strategy. ```python print(f"RHI Files: {rhi_files}") print(f"PPI Files: {ppi_files}") ``` -------------------------------- ### Set up S3 Filesystem for AWS Data Access Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/animated-gifs-with-pyart.ipynb Initializes an anonymous filesystem object for accessing NEXRAD Level 2 data stored on AWS S3. This is a prerequisite for downloading radar data. ```python fs = fsspec.filesystem("s3", anon=True) ``` -------------------------------- ### Set PROJ_LIB Environment Variable for Basemap Source: https://github.com/arm-doe/pyart/blob/main/INSTALL.rst Manually set the PROJ_LIB environment variable to the Basemap installation path to resolve 'KeyError: PROJ_LIB'. This is a workaround, and using Cartopy is recommended. ```python import os os.environ['PROJ_LIB'] = 'C:/Users/xx Username xxx/Anaconda3/Lib/site-packages/mpl_toolkits/basemap' ``` -------------------------------- ### Import necessary libraries for data analysis Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/epcape-blog-post.ipynb Imports essential Python libraries for data handling, visualization, and radar data processing. Ensure these libraries are installed before running the code. ```python import glob import tarfile import act import cartopy.crs as ccrs import cartopy.feature as cfeature import pyart import matplotlib.pyplot as plt import numpy as np ``` -------------------------------- ### Download ARM Data Source: https://github.com/arm-doe/pyart/blob/main/doc/source/blog_posts/2024/epcape-blog-post.ipynb Use the provided credentials and parameters to download data from the ARM facility. ```python files = act.discovery.download_arm_data(username, token, datastream, startdate, enddate) ``` -------------------------------- ### Create empty radar object Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/basic_ingest_using_test_radar_object.ipynb Initialize an empty Py-ART radar object with specified dimensions for gates and rays. ```python radar = pyart.testing.make_empty_ppi_radar(667, 400, 1) ``` -------------------------------- ### Get Data for a Specific Slice Source: https://github.com/arm-doe/pyart/blob/main/doc/source/notebooks/the_pyart_radar_object_and_indexing.ipynb Retrieve the data for a single slice (sweep) of radar data using the get_slice() method. This is useful for analyzing data from a specific elevation angle. ```python slice_indices = radar.get_slice(0) print(radar.fields["reflectivity"]["data"][slice_indices]) ```