Skip to main content

stactools-noaa-hrrr

PyPI GitHub Workflow Status (with event)

wind speed forecast from 2024-05-10T12:00:00Z for 2024-05-10T14:00:00Z

This package can be used to generate STAC metadata for the NOAA High Resolution Rapid Refresh (HRRR) atmospheric forecast dataset.

The data are uploaded to cloud storage in AWS, Azure, and Google so you can pick which cloud provider you want to use for the grib and index hrefs using the cloud_provider argument to the functions in stactools.noaa_hrrr.stac.

Background

The NOAA HRRR dataset is a continuously updated atmospheric forecast data product.

Data structure

  • There are two regions: CONUS and Alaska
  • Every hour, new hourly forecasts are generated for many atmospheric attributes for each region
    • All hours (00-23) get an 18-hour forecast in the conus region
    • Forecasts are generated every three hours (00, 03, 06, etc) in the alaska region
    • On hours 00, 06, 12, 18 a 48-hour forecast is generated
    • One of the products (subh) gets 15 minute forecasts (four per hour per attribute), but the sub-hourly forecasts are stored as layers within a single GRIB2 file for the forecast hour rather than in separate files.
  • The forecasts are broken up into 4 products (sfc, prs, nat, subh),
  • Each GRIB2 file has hundreds to thousands of variables
  • Each .grib2 file is accompanied by a .grib2.idx which has variable-level metadata including the starting byte for the data in that variable (useful for making range requests instead of reading the entire file) and some other descriptive metadata

Summary of Considerations for Organizing STAC Metadata

After extensive discussions, we decided to organize the STAC metadata with the following structure:

  1. Collections: Separate collections for each region-product combination

    • regions: conus and alaska
    • products: sfc, prs, nat, and subh
  2. Items: Each GRIB file in the archive is represented as an item with two assets:

    • "grib": Contains the actual data.
    • "index": The .grib2.idx sidecar file.

    Each GRIB file contains the forecasts for all of a product's variables for a particular forecast hour from a reference time, so you need to combine data from multiple items to construct a time series for a forecast.

  3. grib:messages: Within each "grib" asset, a grib:messages property describes each layer's GRIB message index within the GRIB2 file. This enables applications to access specific parts of the GRIB2 files without downloading the entire file.

  4. grib:layer_definitions: This field is meant to be populated at in the item-assets definitions at the collection level. It describes the variable name, units, and other relevant properties for the each layer within the GRIB file.

  • We intend to propose a GRIB STAC extension with the grib:messages and grib:layer_definitions properties for describing the grib message indexes of the variables within the GRIB files.
  • The layer-level metadata is worth storing in STAC because you can construct URIs for specific layers that GDAL can read using the VRT URI syntaxvrt://:
    • vrt:///vsicurl/{grib_href}?bands={grib_message}, where grib_message is the index of the layer within the GRIB2 file.
      • under the hood, GDAL's vrt driver is reading the sidecar .grib2.idx file and translating it into a /vsisubfile URI.

Advantages

  • Applications can use grib:layer_definitions and grib:messages to create layer-specific data sets, facilitating efficient data handling.
  • Splitting by region and product allows defining coherent collection-level datacube metadata, enhancing accessibility.

Disadvantages

- Storing layer-level metadata like byte ranges in the STAC metadata bloats the STAC items because there are hundreds to thousands of layers in each GRIB2 file.

For more details, please refer to the related issue discussion and pull requests #3 and #6.

STAC examples

Python usage example

  • Check out the example notebook for examples of how to create STAC metadata and how to use STAC items with grib:layers metadata to load the data into xarray.

Installation

Install stactools-noaa-hrrr with pip:

pip install stactools-noaa-hrrr

Command-line usage

To create a collection object:

stac noaahrrr create-collection {region} {product} {cloud_provider} {destination_file}

e.g.

stac noaahrrr create-collection conus sfc azure example-collection.json

To create an item:

stac noaahrrr create-item \
  {region} \
  {product} \
  {cloud_provider} \
  {reference_datetime} \
  {forecast_hour} \
  {destination_file}

e.g.

stac noaahrrr create-item conus sfc azure 2024-05-01T12 10 example-item.json

To create all items for a date range:

stac noaahrrr create-item-collection \
  {region} \
  {product} \
  {cloud_provider} \
  {start_date} \
  {end_date} \
  {destination_folder}

e.g.

stac noaahrrr create-item-collection conus sfc azure 2024-05-01 2024-05-31 /tmp/items

Docker

You can launch a jupyterhub server in a docker container with all of the dependencies installed using these commands:

docker/build
docker/jupyter

Use stac noaahrrr --help to see all subcommands and options.

Contributing

We use pre-commit to check any changes. To set up your development environment, install uv:

uv sync
uv run pre-commit install

To check all files:

uv run pre-commit run --all-files

To run the tests:

uv run pytest -vv

If you've updated the STAC metadata output, update the examples:

uv run scripts/update-examples

Metadata

Release files for stactools-noaa-hrrr 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stactools-noaa-hrrr 1.0.1
File Size Uploaded
stactools_noaa_hrrr-1.0.1.tar.gz 1.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for stactools-noaa-hrrr 1.0.1
File Interpreter ABI Platform
stactools_noaa_hrrr-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / stactools_noaa_hrrr-1.0.1.tar.gz

Download URL stactools_noaa_hrrr-1.0.1.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
587006bc680b8bc654c0ad18fa6bb94d5321fceea46c519a045e28c9771049f2
BLAKE2b-256 checksum
How to use checksums
ea9b4097922700e28eb5668744c3b453986d3a1f2105c605e4a451d904fef8ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / stactools_noaa_hrrr-1.0.1-py3-none-any.whl

Download URL stactools_noaa_hrrr-1.0.1-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d96be89eba7d76b525a28b9e957a8b9a164fa5be6ff138495c528a6d2aea969c
BLAKE2b-256 checksum
How to use checksums
d8ae344ad8fcdd45962d6cf54298539fbd5f0a26111d690549dacf73b1d10bd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page