Skip to content

Commit

Permalink
fix: correct API usage of archive_fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Feb 12, 2024
1 parent 2f70efc commit 7a57d0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions scripts/climodat/hrrr_solarrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
# pylint: disable=unpacking-non-sequence
import datetime
import os

import click
import geopandas as gpd
Expand Down Expand Up @@ -105,7 +104,7 @@ def compute(df, sids, dt, do_regions=False):
with archive_fetch(
now.strftime("%Y/%m/%d/model/hrrr/%H/hrrr.t%Hz.3kmf01.grib2")
) as fn:
if os.path.isfile(fn):
if fn is not None:
grbs = pygrib.open(fn)
selgrbs = grbs.select(name=GRBNAME)
if len(selgrbs) == 4:
Expand All @@ -128,8 +127,8 @@ def compute(df, sids, dt, do_regions=False):
with archive_fetch(
now.strftime("%Y/%m/%d/model/hrrr/%H/hrrr.t%Hz.3kmf00.grib2")
) as fn:
if not os.path.isfile(fn):
LOG.info("Missing %s", fn)
if fn is None:
LOG.info("Missing %s", now)
continue
grbs = pygrib.open(fn)
try:
Expand Down
5 changes: 2 additions & 3 deletions scripts/iemre/merge_narr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Called from dl/download_narr.py each month around the 9th.
"""
import datetime
import os
import sys

import numpy as np
Expand All @@ -23,8 +22,8 @@ def to_netcdf(valid):
with archive_fetch(
f"{valid:%Y/%m/%d}/model/NARR/apcp_{valid:%Y%m%d%H%M}.grib"
) as fn:
if not os.path.isfile(fn):
LOG.warning("Missing file %s", fn)
if fn is None:
LOG.warning("Missing file %s", valid)
return False
gribs = pygrib.open(fn)
grb = gribs[1]
Expand Down

0 comments on commit 7a57d0d

Please sign in to comment.