Skip to content

python pattern for checking if there is a most recent forecast available? #272

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

You must be logged in to vote

Hi @datalus667, I'm happy to hear you like Herbie.

Herbie was designed to retrieve archived forecasts, and it does that by predicting what URLs should exist. I'm not aware of a "model availability service" aside from the page you shared or checking if a file is available.

When I need the latest forecast available, I loop over a set of recent datetimes (hitting URLs until I find something, like you suggested). For example:

from herbie import Herbie
import pandas as pd

# Create a list of dates to try
dates = pd.date_range(
    pd.Timestamp.utcnow().floor("1h").tz_localize(None), periods=6, freq="-1H"
)

# Find first existing Herbie object
for i in dates:
    H = Herbie(i, model="hrrr", pri…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@datalus667
Comment options

Answer selected by datalus667
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants