I thought I'd have a go at creating a new service now. I've got most of the 
code in place and I've got the service to run, but I'm struggling a bit 
with the formula. 

The actual formula's very long so I've made up a short, fake one for the 
purposes of this post which is 'outTemp * outHumidity + 5'.

The code for the service is therefore as follows:











*import weewxfrom weewx.engine import StdServiceclass 
MyHeatIndex(StdService):    def __init__(self, engine, config_dict):        
# Pass the initialization information on to my superclass:        
super(MyHeatIndex, self).__init__(engine, config_dict)        
self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)    def 
new_archive_record(self, record):        record['heatindex'] = 
my_fancy_formula(record['outTemp'] * record['outHumidity'] + 5)*


When I tried running that (with the actual formula in place), it says that 
my_fancy_formula isn't defined. I've read up about this but I'm unsure how 
to fix this - any help would be appreciated.

Thanks



On Thursday, 15 June 2017 19:44:40 UTC+1, Tom Keffer wrote:
>
> The "weewx way" would be to write a simple service that binds to the 
> NEW_ARCHIVE_RECORD events and replaces the value of heatindex with the 
> results of your calculation. Something like (NOT TESTED):
>
> from weewx.engine import StdService
> class MyHeatIndex(StdService):
>
>     def __init__(self, engine, config_dict):
>         # Pass the initialization information on to my superclass:
>         super(MyHeatIndex, self).__init__(engine, config_dict)
>         self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
>
>     def new_archive_record(self, record):
>         record['heatindex'] = my_fancy_formula(record['windGust'], 
> record['outTemp'], ........)
>
> Run the service *after* StdWXCalculate.
>
> See the section *Creating a new service 
> <http://weewx.com/docs/customizing.htm#Adding_a_service>* for details.
>
> -tk
>
>
> On Thu, Jun 15, 2017 at 9:52 AM, David Watts <[email protected] 
> <javascript:>> wrote:
>
>> Hi
>>
>> I want to tinker with the 'heat index' formula in wxformulas.py and 
>> introduce wind gusts and speed into it.
>>
>> I notice the wind speed is available (V_mph, used for wind chill) but how 
>> would I introduce the wind gust?
>>
>> Thanks
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to