New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windrun calculation #194
Comments
The code within Belchertown does not calculate wind run. Can you tell me where you see that? Everything within the skin with reference to wind run is using the weewx built in tags (e.g. https://github.com/poblabs/weewx-belchertown/search?utf8=%E2%9C%93&q=windrun&type= |
I'm looking at this again and everything I can find is with the weewx tags which are not generated from Belchertown. Belchertown gets that data from weewx directly when using a tag. Are you saying the MQTT payload contains incorrect data? If so, the MQTT payload data isn't being calculated by Belchertown. It's just showing the data the weewx-mqtt extension is publishing. If the MQTT payload data is wrong, then mwall needs to be made aware of with his extension (post a message to the weewx-user forums) Let me know what I am missing? |
Sorry, I wasn't super clear with my statement above. Basically, since 3.9.2, weewx has changed how it stores windrun in the database. It used to be (3.9.1 and earlier) that the field "windrun" recorded the sum of the daily windrun on each day. So your weewx db entries for windrun would look like 1.2, 2.3, 2.9, 3.7,... Consequently for displaying windrun in Belchertown then you can just take the maximum over the day and compare this for each day to get the record. All good so far. However, since 3.9.2, the weewx calculation has changed so that it records the windrun for each archive period, rather than the running sum. The values in the DB above would then be 1.2, 0.9, 0.6, 0.8,... This change was made to make it more consistent with other values in the DB such as rain. I think to fix the implementation in Belchertown, all you need to do is take the "sum" value for windrun for each day, rather than the "max". I hope that makes sense. |
Ah that does make sense, thanks! The only areas I see windrun max used are on the records page, so I'll get those updated to Thanks for taking the time to explain it, I was a little lost 😃 |
no problem. Just to be clear, I think you should use the following two aggregation types:
|
by the way, thanks for the great work on the skin. It's really fantastic. I much prefer it over the Seasons skin. |
Glad you enjoy it! Interesting; maxsum and not just sum? |
I think so. Because it's a record, I think you want the aggregation period to be one year and then take the maxsum (which is the maximum daily sum over the aggregation period). I think the skin grabs the current year daily max as the record and the all time record. Not sure how you get the all time, maybe you have to iterate over all years in the DB and get the maxsum for each year, and then take the max of that? |
The all time is given to me by weewx as well (through some of their example code), and I think that does exactly what you're describing (it's been a while since I read that section of code). If you'd like to try it out, you can edit your skins/Belchertown/records/index.html.tmpl and search for windrun and update those values. Upon your next archive interval the report should be generated with the new values. I'm going to be remote for a few hours but if you're feeling up to it let me know the results. |
No problem. I had a go and it seems to be working well. Will do a pull request and then you can have the code. |
Great! You deserve the credit |
Merged, I'll add it to development too. Thanks again |
How's this looking for you now after letting it sit a few months? I think it's wrong and I need to roll it back... Here's my Highest Daily Wind Run
|
It's working perfectly for me. I think your issue is because you probably have archive values in your DB that are cumulative, rather than for the archive period. I have a related issue in that my windrun values from prior to when I changed the DB schema to include windrun are not populated. I think you probably have to run a script over your DB to recalculate the windrun for each archive period. Also, I note that the change to this type of calculation was only made to 3.9.2 of WeeWX. If you are still using an earlier build, then it will still be adding cumulative values. In summary, I don't there is a bug, but how to handle changing from earlier builds of WeeWX to later builds, probably needs further consideration. |
Yeah you're probably right. Perhaps I didn't catch this a few months ago. In my preparation to release 1.1 I noticed it. I am on 3.9.2, so that's good. Guess I'll need to export my database to a dev machine, drop all dailies, rebuild all dailies, and only migrate back the |
@windcrusader Dropping dailies and rebuilding them is returning the same |
The problem is not with your dailies - it is with the actual archive values in the main WeeWX DB. In versions of WeeWX prior to 3.9.2 these were entered as a cumulative value, which was inconsistent with the general philosophy of WeeWX archive records. You can read more about the underlying problem and reason for the change at weewx/weewx#250. In summary, to fix your problem, what you need to do is go through every archive record in your DB and recalculate windrun. I note this is a bit of a pain to do, and I note through other reading that I was doing that you were working on adapting the "calcMissing()" tool so that it could be called anytime rather than just when exporting and reimporting database records. Maybe a good time to pull that out again? |
You're right. I spaced out on that one. The dailies are derived from the archive table. So much for trying to multitask! I think I'll try to drop the windrun column in the archive table. Then re-add it and run a Yes, I had submitted a PR for |
Spent some time on this today and I'm seeing something that seems off. Reading how
A simple MySQL query can accomplish this:
Now my highest windrun based on |
hmmm, curious. As a check, your windrun in miles should be equal to your daily average windspeed * 24. In my case, on my site, the numbers check out perfectly. I can't see anything wrong with your SQL though. It should work. 9986.7 seems way too high. My highest to date is 655 miles, which happened on a very windy day when the average windspeed was 23 knots! |
It gets even more interesting. Feeling a bit lost on this one as to why my results are so high. According to this, my highest sum windrun is on 1452038400 (Wednesday, January 6, 2016 12:00:00 AM)
To get this day range, it's 1452038400 to 1452142799 (Date and time (your time zone): Wednesday, January 6, 2016 11:59:59 PM GMT-05:00) So this query below takes that time range and figures out the average wind speed, and the average windspeed across 24 hours.
The result is 2.22 (rounded) Here's the same day's results in wind speed only
So I think what I am taking away from this is that:
Where's 9986.7 coming from? |
Reached out for help here: https://groups.google.com/forum/#!topic/weewx-development/LawxQIAp-mM |
@windymel @windcrusader FYI based on this comment, I think I'm going to revert windrun sum back to sum and not maxsum. https://groups.google.com/d/msg/weewx-development/LawxQIAp-mM/CZLPzCR0DAAJ |
maxsum is the correct way to get the max daily "sum" for a variable. As per what tkeffer said, it is used to get the "rainiest" day, or "windiest" day etc. Stupid question, but after updating your archive records with your SQL above, did you drop all your daily summaries and rebuild as per: here. |
Yes I rebuilt dailies after running the query. That's why the number changes from 42,000 to 9,000. So the skin is trying to show Highest Daily Wind Run - surely it's not 22,000 or 9,000 miles. So maxsum doesn't seem like the right value? |
I just posted an update. It may seem that my MySQL query was the problem, and I should have used
|
I think we're good here as this was a problem with my own database, and a bad investigative query. Closing again. Thanks for the help! |
Hi. It appears that the windrun record shows the maximum observed windrun in a 5 minute archive period. I think this is because in versions of weewx <= 3.9.1 the windrun calculation in the archive packet was the sum of the day's windrun. However, this was identified as an issue and inconsistent with other calculated quantities. The calculation was changed in version 3.9.2 to be the windrun for the archive period (refer [https://github.com/weewx/weewx/issues/250]) . Consequently, the code in Belchertown needs to be updated for consistency with this change.
The text was updated successfully, but these errors were encountered: