Skip to content

How can I create index files for local GRIB files? #366

Answered by blaylockbk
blaylockbk asked this question in Q&A
Discussion options

You must be logged in to vote

NCEP-style index files can be generated with wgrib2.

wgrib2 -s file.grib2 > file.grib2.idx

If wgrib2 is in your path, Herbie has a helper function to make the index files.

from pathlib import Path
from herbie import wgrib2

# Create list of grib2 files
files = sorted(Path("/user/data/my_local_urma_data").rglob("*/*.grb2*"))

# Generate an index file for each file
n = len(files)
for i, f in enumerate(files):
    print(f"Create index file {i:,}/{n:,} ({i / n:.1%}).", end="\r")
    wgrib2.create_inventory_file(f)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by blaylockbk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
inventory Related to GRIB index inventory files
1 participant