From da393231544404d89edf1cb2bd5e8554e121dcd0 Mon Sep 17 00:00:00 2001 From: Matthew Wall Date: Tue, 26 Jan 2016 00:34:14 -0500 Subject: [PATCH] add ability to disable specific calculations. report exactly which calculations will be performed, and which algorithms will be used. --- bin/weewx/wxservices.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/bin/weewx/wxservices.py b/bin/weewx/wxservices.py index c39e85b8..f667e919 100644 --- a/bin/weewx/wxservices.py +++ b/bin/weewx/wxservices.py @@ -64,6 +64,7 @@ class StdWXCalculate(weewx.engine.StdService): windchill = hardware heatindex = prefer_hardware dewpoint = software + humidex = None [[Algorithms]] altimeter = aaASOS maxSolarRad = RS @@ -90,22 +91,26 @@ class StdWXCalculate(weewx.engine.StdService): self.max_delta_12h = int(svc_dict.get('max_delta_12h', 1800)) # find out which calculations should be performed - # we recognize only the names in our dispatch list; others are ignored self.calculations = dict() - calc_dict = svc_dict.get('Calculations', {}) + # look in the 'Calculations' stanza. if no 'Calculations' stanza, then + # look directly in the service stanza. + where_to_look = svc_dict.get('Calculations', svc_dict) + # we recognize only the names in our dispatch list; others are ignored for v in self._dispatch_list: - if v in calc_dict: - self.calculations[v] = calc_dict[v] - else: - # fallback to 3.0/3.1 behavior of no 'Calculations' stanza - self.calculations[v] = svc_dict.get(v, 'prefer_hardware') + x = where_to_look.get(v, 'prefer_hardware') + if x in ('hardware', 'software', 'prefer_hardware'): + self.calculations[v] = x - # get any custom algorithms + # determine which algorithms to use for the calculations self.algorithms = svc_dict.get('Algorithms', {}) + self.algorithms.setdefault('altimeter', 'aaNOAA') + self.algorithms.setdefault('maxSolarRad', 'RS') # various bits we need for internal housekeeping - self.altitude_ft = weewx.units.convert(engine.stn_info.altitude_vt, "foot")[0] - self.altitude_m = weewx.units.convert(engine.stn_info.altitude_vt, "meter")[0] + self.altitude_ft = weewx.units.convert( + engine.stn_info.altitude_vt, "foot")[0] + self.altitude_m = weewx.units.convert( + engine.stn_info.altitude_vt, "meter")[0] self.latitude = engine.stn_info.latitude_f self.longitude = engine.stn_info.longitude_f self.temperature_12h_ago = None @@ -113,6 +118,11 @@ class StdWXCalculate(weewx.engine.StdService): self.archive_interval = None self.rain_events = [] + # report about which values will be calculated... + syslog.syslog(syslog.LOG_INFO, "wxcalculate: The following values will be calculated: %s" % ','.join(["%s=%s" % (k, self.calculations[k]) for k in self.calculations])) + # ...and which algorithms will be used. + syslog.syslog(syslog.LOG_INFO, "wxcalculate: The following algorithms will be used for calculations: %s" % ','.join(["%s=%s" % (k, self.algorithms[k]) for k in self.algorithms])) + # we will process both loop and archive events self.bind(weewx.NEW_LOOP_PACKET, self.new_loop_packet) self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)