a little bit lost with wind variable formatting..

280 views
Skip to first unread message

wysiwyg

unread,
Apr 7, 2013, 3:47:09 PM4/7/13
to weewx...@googlegroups.com
Hello,
I am a little bit lost with variables regarding wind:

for current data, I use $current.windSpeed or $current.winddir.

when it comes to day data, $day.windSpeed.min or max does not work, i have to use $day.wind.max or min

why this change from windspeed to wind ?

Then, I am interested in average winddir, how can I generate this value ?   (best would be "hourly winddir average", but if not possible I can manage with day average)


if anyone can help ?


Thomas Keffer

unread,
Apr 7, 2013, 6:46:33 PM4/7/13
to weewx-user
The observation types 'windSpeed' and 'windDir' (and 'windGust' and 'windGustDir') are a legacy from wview. Those are the schema names it used in the archive database. Wview simply flattened the wind data into four separate fields. 

The simpler, consolidated type 'wind' was introduced by weewx. It is used in the statistical summary database.

So, those things that use the archive database, namely $current and the plots, use windSpeed and its friends.

Those things that use the statistical summary, such as $day, $week, etc., use wind.

I know that's a bit confusing, but that's the price of systems that inherit a legacy!

The average wind direction is available as $day.wind.vecavg. This will be the true vector averaged wind direction.

However, knowing the history of this question, I suspect what you really want is a plot of wind direction, aggregated over some time period. For example, a plot of winds over the last week, aggregated by one hour averages. 

Most of the part necessary to do this are there. For example, class archive.Archive can return a vector of complex numbers (x, y) with the x and y components of wind, aggregated over some time period. Presently, it is used for the "progressive vector plots." However, one could create a new plot type that plotted the value atan2(y,x), or the wind direction. 

As for how to do that, Matthew Wall is working on a more general plotting engine that will make it a little easier to add new plot types such as this. A little patience and the pieces to do what you want should appear shortly.

Hope I answered your question.

-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.
 
 



--
Tom Keffer
kef...@threefools.org
+1 541-386-8891 (h)
+1 541-490-9507 (c)
Skype: tkeffer

wysiwyg

unread,
Apr 8, 2013, 1:30:17 AM4/8/13
to weewx...@googlegroups.com
Hello,

thanks a lot for explaination, it's now very clear !

Regarding hourly average, my need is a little bit different.

it's a couple of weeks now that I am playing with a javascrip library name steelseries. it provide some pretty nice gauges.

One of the gauge is made for wind direction but it has 2 needdles : a current direction needdle and an average one.

That's where I would need a "$hourly.avg.vecavg" or whatever (I need the value, not the plot).

You may have a look to steelseries gauges here on my site:
http://meteosaintsulpice.free.fr/now.php 
it is still using wview, but while waiting the WMRS200 driver, I  prepare my website for weewx on an other machine using the simulator.

an other exemple is here:
http://www.syroswx.gr/gtest.htm

Thomas Keffer

unread,
Apr 8, 2013, 10:41:12 AM4/8/13
to weewx-user
OK, now I get what you're trying to do.

You could write a custom a custom generator. Follow the example given in the documentation and override the function getToDateSearchList(). The archive database is passed into that function as an argument. You would then create a new tag, say $hour_winddir and add it to the search list.

It would look something like this (NOT TESTED):

import math
from weewx.filegenerator import FileGenerator class MyFileGenerator(FileGenerator): def getToDateSearchList(self, archivedb, statsdb, valid_timespan):
(time_valuetuple, wind_valuetuple) = archivedb.getSqlVectorsExtended('windvec', valid_timespan.stop - 3600, valid_timespan.stop, 3600, 'avg')
# I probably got some of this wrong. You'll have to check!!!

# The data vector in the value tuple is the first element:
  wind_vec = wind_valutuple[0]
# There should be only one point in the data vector. Get it:
x,y = wind_vec[0]
# Calculate the wind direction
wind_dir = math.atan2(y, x)

# Get the superclass's search list: search_list = FileGenerator.getToDateSearchList(self, archivedb, statsdb, valid_timespan) # Now tack on my addition search_list += [ {'hour_winddir' : wind_dir} ]

I probably got many things wrong with this example, but hopefully you get the idea! In particular, it does not check for None values. 

When you're done, the vector average wind direction for the last hour should be available in the templates as $hour_winddir.

-tk
return search_list


wysiwyg

unread,
Apr 8, 2013, 1:19:53 PM4/8/13
to weewx...@googlegroups.com
I will try this !

In the mean time, I think I need a little bit more help to handle the vecavg format:

If I put $day.wind.vecavg, I have a result in km/h....  Is it the vector lenght ? I guess I missed the angle :-)

Thomas Keffer

unread,
Apr 9, 2013, 12:06:35 AM4/9/13
to weewx-user
$day.wind.vecavg is the vector averaged wind speed. That is, if the wind blows from the west for 12 hours, then from the east for 12 hours, vecavg will be zero.

$day.wind.vecdir is the vector averaged wind direction. 

-tk

wysiwyg

unread,
Apr 11, 2013, 6:40:50 PM4/11/13
to weewx...@googlegroups.com

Hello !

Regarding the $hourly option, i discovered the § regarding custom generator in the customize guide.
I was thinking why not create hourly option for all data.

So I used mygenerator.py from example, and copy the file to mygenerator2.py.

In this one, I copy paste the part regarding seven days data and replace "sevenday" by "hours"

I have this:

                                        formatter=self.formatter,
                                        converter
=self.converter)   #6

+        # Now get a TimeSpanStats object for the hourly stats. This one we
+        # will have to calculate. First, calculate the time at midnight, seven
+        # days ago. The variable week_dt will be an instance of datetime.date.
+        hour_dt = datetime.date.fromtimestamp(valid_timespan.stop) - datetime.timedelta(hours=1)    #4bis
+        # Now convert it to unix epoch time:
+        hour_ts = time.mktime(week_dt.timetuple())                  # 5bis
+        # Now form a TimeSpanStats object, using the time span we just calculated:
+        hourly_stats = TimeSpanStats(TimeSpan(hour_ts, valid_timespan.stop),
+                                        statsdb,
+                                        formatter=self.formatter,
+                                        converter=self.converter)   #6bis








       
# Get the superclass's search list:      

        search_list
= FileGenerator.getToDateSearchList(self, archivedb, statsdb, valid_timespan) # 7

       
# Now tack on my two additions as a small dictionary with keys 'alltime' and 'seven_day':
        search_list
+= [ {'alltime'   : all_stats,
                         
'seven_day' : seven_day_stats,
+                         'hourly'    : hourly_stats} ]               # 8

       
return search_list

I does generate errors in syslog (which is already a good point :-)) )
but it does not works.

I use the simulator station for all these testings.  outTemp looks like a sin wave, we are current about minimum:
 

$hourly.outTemp.avg  gives 9.9°C
$hourly.outTemp.min gives -1.1°C
$hourly.outTemp.max 21.1°C

in the mean time:
$day.outTemp.avg  gives 0.1°C
$day.outTemp.min gives -0.3°C
$day.outTemp.max 0.5°C

hourly and day data seems mixed ??

did I made something wrong ??



Thomas Keffer

unread,
Apr 11, 2013, 7:04:30 PM4/11/13
to weewx-user
This is because all of the statistics are run against the stats database, which holds daily summaries. You cannot get information at a finer resolution than one day.

You have to use the archive database to get finer resolution. That's a much harder problem because the tag machinery only works for the stats database.

I am working (lazily) on a resolution to this problem. My solution will have a single database interface for all queries and uses the stats database as merely an optimization strategy.

-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.
 
 

Frederic Stuyk

unread,
Apr 11, 2013, 7:46:38 PM4/11/13
to weewx...@googlegroups.com

Heyhey now I understand my confusion :-)
$day data was looking like hourly data because it's at 0:40 that I have done the test. So day data is on last hour only.

You received this message because you are subscribed to a topic in the Google Groups "Weewx user's group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/nbe5WFbObiU/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages