This utility will generate a base map and any number of the most recent NEXRAD radar imagery frames, with the primary purpose of presenting an animated loop in HTML (but you could use the map and frames however you like).
It uses python-awips to pull raw NEXRAD level III radar data from the EDEX server maintained by UCAR's Unidata Program Center in Boulder, Colorado.
The instructions below assume Linux or macOS. The same should work in Windows, but the commands will be slightly different.
First, grab a copy of the utility:
git clone https://github.com/MaffooClock/MrRadar.git
The easiest way to run this utility is with Docker, which guarantees that you won't have any dependency issues.
First, build the image:
docker build -t mr_radar:latest .
Then run it (minimal command to output --help
):
docker run -t --rm mr_radar:latest
Conda make managing Python environments easy.
Start by creating the environment, which will also install the required dependencies:
cd MrRadar
conda env create -f environment.yml
Activate the environment:
conda activate mr_radar
Then run it:
python3 -m run mr_radar --help
And for those who prefer using good ol' Pip... of course, doing this in a Python venv (virtual environment) is recommended:
Create the venv:
cd MrRadar
python -m venv .venv
Activate the venv:
source .venv/bin/activate
Install the dependencies
python3 -m pip install -r requirements.txt
Then run it:
python3 -m run mr_radar --help
The instructions below show running this utility with just mr_radar
, but the actual invocation will depend on whether you installed via Docker or Conda/Pip, so adjust accordingly.
There are two positional arguments that are required:
mr_radar <command> <site>
map
: generate the geographical map that will serve as the background to the NEXRAD imagery framesframes
: generate one or more NEXRAD image framesdump-products
: Dump a list of valid radar products to the console for the given site without generating any imageryTypically, the map
command is only ever needed once; the only time you'd want to run it again would be for a different site or radius. The frames
command would then be executed at some interval to have the latest quantity of frames available at all times.
This is the four-letter site code (known as the ICAO) of the radar site from which you want to use NEXRAD data. Consult the NWS Radar Operations Center for various methods on finding available radar sites.
Here are the flags with explanations of each:
Flag | Default | Description |
---|---|---|
‑‑radius ‑r |
150 | The distance in miles around the radar site that you'd like to feature in the generated images |
‑‑root ‑R |
Dockerized: /data Direct: ./out in current working directory |
The root path for all output (JSON cache file and generated images) |
‑‑images ‑i |
./<site_id> relative to root path |
The directory in which the generated PNG files will be saved, which will be relative to the root path. Specify an absolute path to save the images outside of the root path. |
‑‑file ‑f |
Map mode: map.png Frames mode: frame_<i>.png |
The file name to use for the generated PNG file(s). It is not necessary to include the .png extension. |
‑‑frames ‑n |
12 | The quantity of NEXRAD imagery frames to generate |
‑‑product ‑p |
Reflectivity | The radar product to use for generating NEXRAD imagery frames. Hint: use the dump-products command to find the one you want. |
[!TIP] When running in Docker, don't forget to map the
/data
directory within the container to a local path, or you won't get any of the generated images:docker run -t --rm --volume $(pwd)/out:/data mr_radar:latest <command> <site_id>
Generate a map with a 150-mile radius centered around KSJT:
mr_radar map KSJT
This will result in a new PNG file at ./out/ksjt/map.png
.
Generate 12 of the latest NEXRAD frames for the same location and radius:
mr_radar frames KSJT
This will result in 12 new PNG files at ./out/ksjt/frame_0.png
through ./out/ksjt/frame_11.png
.
You will also find a new JSON file (./out/ksjt.json
, in this example) in the root output path, which contains the command-line arguments you supplied, as well as additional derived information based on the site ID and radius.
Here's what it's good for:
Deleting this file won't hurt anything, but it's not a necessary task in the course of normal use.
Check out the html
directory for a basic example of how to "animate" the frames on top of the base map.
The example HTML will work out-of-the-box if you run the utility with:
./out
)map.png
and frame_<i>.png
).--images .
to save generated images in the root pathOtherwise, you'll need to tweak the loop.html
file to make it work.
To view the animated loop after generating the map and NEXRAD frames, simply open the loop.html
file in your browser (no web server needed to test-drive locally).
[!IMPORTANT] The example HTML files aren't intended to be deployed as-is to your website, they're just an example to show how to create an animated loop effect (but you may certainly copy/paste to your heart's desire).