From 54ee9670371b146340d0b25f4ea5580eeb37e29b Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Mon, 15 Nov 2021 17:14:09 -0800 Subject: [PATCH] Add num_hrs_to_fetch var The value defaults to "3" but should be bumped to "24" if the user wants HN24 or wind averaging. --- infoex-autowx.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index a1bcf00..2b7880e 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -128,6 +128,12 @@ def setup_config(config): LOG.critical("%s is not a valid timezone", tz) sys.exit(1) + # By default, fetch three hours of data + # + # If user wants hn24 or wind averaging, then + # we need more. + station['num_hrs_to_fetch'] = 3 + # HN24 if 'hn24' in config['station']: if config['station']['hn24'] not in ['true', 'false']: @@ -135,6 +141,7 @@ def setup_config(config): if config['station']['hn24'] == "true": station['hn24'] = True + station['num_hrs_to_fetch'] = 24 else: station['hn24'] = False else: @@ -147,6 +154,9 @@ def setup_config(config): raise ValueError("wind_mode must be either 'normal' or 'average'") station['wind_mode'] = config['station']['wind_mode'] + + if station['wind_mode'] == "average": + station['num_hrs_to_fetch'] = 24 else: # default to False station['wind_mode'] = "normal" @@ -632,7 +642,7 @@ def setup_time_values(station): end_date = date_time - datetime.timedelta(minutes=date_time.minute % 60, seconds=date_time.second, microseconds=date_time.microsecond) - begin_date = end_date - datetime.timedelta(hours=3) + begin_date = end_date - datetime.timedelta(hours=station['num_hrs_to_fetch']) return (begin_date, end_date) def f_to_c(f): -- 2.30.2