Windchill using windgust?

155 views
Skip to first unread message

Bob Weber

unread,
Jan 22, 2014, 4:59:41 PM1/22/14
to weewx...@googlegroups.com
I have a Davis Vantage Pro2 weather station.  I use a Envoy and WeatherlinkIP logger.  I use weewx version 2.5.1 running on Debian 32bit in a virtual machine on my 6 core AMD  desktop running Debian 64bit.  I have little problems with this setup.  weewx just seems to run.
However, I have noticed that the Wind Chill/Heat Index  graph that weewx produces almost never shows any wind chill since the windspeed in the archive database is very low compared the the wind gusts.  Usually a 3 or 4 to one ratio. Today the wind speed has been mostly below the 3 mph threshold for the wind chill formula while the wind gusts have been as high as 20.  The "Since Midnight" tabulation on the "Current" page of the standard report shows a low wind chill of -6 deg F at 7:37 this morning from the $day.windchill.min variable.  The archive database shows a wind gust of 17 but only a wind speed of 2 at 7:40 ... the closest time to 7:37 in the archive.  The out temp was 11.2 deg F and the wind chill was the same at 11.2 deg F in the archive database.  Using the noaa wind chill calculator the "new formula" wind chill is calculated to be -6 deg with a temp of 11 and wind speed of 17.

So I would like to calculate the wind chill from the wind gust so that I will get more realistic wind chill in the graphs.  I tried using this in the StdCalibrate section realizing that it would not make any boundary checks before the wind chill was calculated/changed:

windChill = 35.74 + 0.6215 * outTemp + (-35.75  + 0.4275 * outTemp) * math.pow(windSpeed, 0.16)

This only produced errors in the weewx log file.  Any ideas as to how to accomplish this?  Maybe in the vantage driver?

Thanks.

...Bob

CWOP:   DW1736
Wunderground:   


KVAURBAN2

Thomas Keffer

unread,
Jan 22, 2014, 6:26:45 PM1/22/14
to weewx-user
Hi, Bob

For the Vantage series, windchill is obtained directly from the console. It is not calculated in weewx.

To do what you want, you're on the right track using StdCalibrate. Problem is, the "namespace" available for the calibration functions is limited to the record variables (such as 'outTemp') and any modules that happen to have been imported into the host module (wxengine.py, in this case). Unfortunately, math isn't one of them.

There is a ticket in our bug tracker to be a little more rigorous about this and allow sensible, arbitrary, functions.

In the meantime, if you want to hack this, just add 

import math

at the top of wxengine.py

-tk



--
You received this message because you are subscribed to the Google Groups "Weewx user's group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Bob Weber

unread,
Jan 22, 2014, 7:24:40 PM1/22/14
to weewx...@googlegroups.com
That sounds easy enough.  Is there any way to do the boundary checks in StdCalibrate?  Maybe like a if ... then... else pair or access to the weewx.wxformulas.windchill function? As you know the formula is only good below 50 deg and above 3 mph wind. 


In playing with the interactive python i see that something like:
cc = compile(' a = weewx.wxformulas.windchill(40, 10)', '<string>', 'exec')
exec cc
print a
gives the answer 33.6425...

So would a stdCalibrate string like this work:

windChill = weewx.wxformulas.windchill(outTemp, windGust)

after putting:

import weewx.wxformulas

at the top of wxengine.py

...Bob

Thomas Keffer

unread,
Jan 22, 2014, 7:32:55 PM1/22/14
to weewx-user
You're getting the hang of it!

Unfortunately, everything has to be on one line. Mostly because of the limitations of getting a multi-line program (with indentations!) in through ConfigObj, the utility that reads the configuration file. 

But, there are tricks. In particular, the "ternary" operator is useful. This operator is of the form

x if test else y

so, you could do something like:

windchill = outTemp if windSpeed < 3 else 35.74 + 0.6215 * outTemp + (-35.75  + 0.4275 * outTemp) * math.pow(windSpeed, 0.16)

BTW, it's "windchill", not "windChill"

-tk

Bob Weber

unread,
Jan 23, 2014, 1:37:05 PM1/23/14
to weewx...@googlegroups.com
After extensive tests with a small program and a test weewx.conf file I discovered that the formula needed to be enclosed in quotes in the weewx.conf file since the ConfigObj function split the line in the config file at the comma in the pow function.  Thats where the errors were coming from.  The compile function was only seeing the formula up to  'pow(windGust' and was aborting since that was an invalid formula.  I also put the 'import math' in the weewx.py so the power function would be found.  I found these two ways of calculating the wind chill that worked:

windchill = 'outTemp if ( outTemp > 50 or windGust < 3 ) else 35.74 + 0.6215 * outTemp + ( -35.75 + 0.4275 * outTemp )  * pow(windGust, 0.16)'

windchill = 'weewx.wxformulas.windchillF(outTemp, windGust)'

The last required a import of weewx.wxformulas in wxengine.py so I used the first one since you mentioned that the import math library may be put in in later versions of weewx.

So an old C programmer learned a little about python!  Thanks for your help.

...Bob




Thomas Keffer

unread,
Jan 23, 2014, 7:22:24 PM1/23/14
to weewx-user
This is a limitation of ConfigObj, the utility we use to read the configuration file. If it sees a comma, it figures the entry must be a list, so it chops it up into separate elements. Sigh.

-tk


Reply all
Reply to author
Forward
0 new messages