X-Git-Url: https://wylark.com/src/infoex-autowx.git/blobdiff_plain/7ec3b0b74884347d7b1c38fa18b4d3879371b495..cbf0401825aae556d5ecf800d32d226b76d6d93d:/infoex-autowx.py diff --git a/infoex-autowx.py b/infoex-autowx.py index f951c0d..d62b1e6 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -4,9 +4,8 @@ # InfoEx <-> NRCS Auto Wx implementation # Alexander Vasarab # Wylark Mountaineering LLC -# 2020-04-22 # -# Version 0.8 +# Version 1.0.0 # # This program fetches data from an NRCS SNOTEL site and pushes it to # InfoEx using the new automated weather system implementation. @@ -19,6 +18,9 @@ # hours ago because the instrumentation had a hiccup. It's worth # considering if this is a bug or a feature. # +# For more information, see file: README +# For licensing, see file: LICENSE +# import configparser import csv @@ -61,7 +63,7 @@ try: 'uuid': config['ftp']['uuid'], 'api_key': config['ftp']['api_key'], 'location_uuid': config['wxsite']['location_uuid'], - 'wx_data': {}, + 'wx_data': {}, # placeholder key, values to come later 'csv_filename': config['wxsite']['csv_filename'] } @@ -172,6 +174,10 @@ for elementCd in desired_data: values = tmp[0]['values'] # sort and isolate the most recent + # + # NOTE: we do this because sometimes there are gaps in hourly data + # in NRCS; yes, we may end up with slightly inaccurate data, + # so perhaps this decision will be re-evaluated in the future if values: ordered = sorted(values, key=lambda t: t['dateTime'], reverse=True) infoex['wx_data'][elementCd] = ordered[0]['value'] @@ -183,16 +189,12 @@ log.info("Time to get all elementCds : %.3f sec" % (time.time() - log.debug("infoex[wx_data]: %s", str(infoex['wx_data'])) -# Only need to add in what we want to change thanks to that abomination -# of a variable declaration earlier +# Now we only need to add in what we want to change thanks to that +# abomination of a variable declaration earlier final_data[fmap['Location UUID']] = infoex['location_uuid'] final_data[fmap['obDate']] = end_date.strftime('%m/%d/%Y') final_data[fmap['obTime']] = end_date.strftime('%H:%M') -#final_data[fmap['tempPres']] = float(infoex['wx_data']['TOBS']) -#final_data[fmap['precipitationGauge']] = float(infoex['wx_data']['PREC']) -#final_data[fmap['hS']] = float(infoex['wx_data']['SNWD']) - for elementCd in infoex['wx_data']: if elementCd not in iemap: log.warning("BAD KEY wx_data['%s']" % (elementCd))