Skip to content

Commit

Permalink
--hours replaces --one
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpus committed Feb 24, 2022
1 parent bba5fa6 commit 377c3ce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions eht_met_forecast/am.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def grib2_to_extra_information(grbindx, u, v):
ret = {}

try:
# appears for lev_surface at level 0
k = 'csnow'
ret['csnow'] = (grid_interp(grbindx.select(name='Categorical snow', level=0)[0].values, u, v))
k = 'cicep'
Expand All @@ -110,11 +111,11 @@ def grib2_to_extra_information(grbindx, u, v):
k = 'crain'
ret['crain'] = (grid_interp(grbindx.select(name='Categorical rain', level=0)[0].values, u, v))

# appears for level_surface
# appears for lev_surface at level 0
k = 'wgust'
ret['wgust'] = (grid_interp(grbindx.select(name='Wind speed (gust)', level=0)[0].values, u, v))

# this one is mediated by lev_max_wind
# appears for lev_max_wind at level 0
k = 'max wind u'
a = grbindx.select(name='U component of wind', level=0)[0].values
k = 'max wind v'
Expand Down
4 changes: 2 additions & 2 deletions eht_met_forecast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def main(args=None):
help='directory to store output (default: eht-met-data')
parser.add_argument('--wait', action='store_true', help='Retry forever on 404, awaiting data availability')
parser.add_argument('--dry-run', '-n', action='store_true', help='Show what would be done. Implies -v')
parser.add_argument('--one', action='store_true', help='Just do one hour. Used for testing')
parser.add_argument('--hours', action='store', default=384, type=int, help='Hours to compute. Used for testing')
parser.add_argument('--stdout', action='store_true', help='Print output to stdout instead of a file')
parser.add_argument('--log', action='store', help='File to write logging information to')
parser.add_argument('--verbose', '-v', action='store_true', help='Print more information')
Expand Down Expand Up @@ -131,7 +131,7 @@ def main(args=None):
f2.writeheader()

try:
make_forecast_table(station, gfs_cycle, f, f2, wait=args.wait, verbose=args.verbose, one=args.one, stats=stats)
make_forecast_table(station, gfs_cycle, f, f2, wait=args.wait, verbose=args.verbose, hours=args.hours, stats=stats)
except TimeoutError:
# raised by gfs.py
print('Gave up on {} {}'.format(station, gfs_cycle), file=sys.stderr)
Expand Down
8 changes: 5 additions & 3 deletions eht_met_forecast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ def compute_one_hour(site, gfs_cycle, forecast_hour, f, f2, wait=False, verbose=
time.sleep(1)


def make_forecast_table(site, gfs_cycle, f, f2, wait=False, verbose=False, one=False, stats=None):
def make_forecast_table(site, gfs_cycle, f, f2, wait=False, verbose=False, hours=-1, stats=None):
print_table_line(table_header, f)
for forecast_hour in range(0, 121):
compute_one_hour(site, gfs_cycle, forecast_hour, f, f2, wait=wait, verbose=verbose, stats=stats)
if one:
if forecast_hour > hours:
return
compute_one_hour(site, gfs_cycle, forecast_hour, f, f2, wait=wait, verbose=verbose, stats=stats)
for forecast_hour in range(123, 385, 3):
if forecast_hour > hours:
return
compute_one_hour(site, gfs_cycle, forecast_hour, f, f2, wait=wait, verbose=verbose, stats=stats)


Expand Down

0 comments on commit 377c3ce

Please sign in to comment.