Direction of the maximum wind value

167 views
Skip to first unread message

Remy Lavabre

unread,
Jun 3, 2021, 11:38:42 AM6/3/21
to weewx-user
Good morning all,

To have the maximum wind gust over a period this works very well and also gives the time and date of this wind gust:

        <td class="label">Win Gust Max</td>
        #for $archive in $archive_data
        <td class="data new_row hilo_$archive[0]"><font color = "DarkRed">
          <span title="$archive[1].wind.maxtime">
            $archive[1].wind.gustdir.ordinal_compass ($archive[1].wind.gustdir.format(add_label=False)$unit.label.windDir)
            - $archive[1].wind.max.format(add_label=False)</span><br>
            <span class="timestamp">$archive[1].wind.maxtime</span>
        </td>


Over the same period, I get the maximum wind value (not the gust) with the following formula:

          <span title="$archive[1].windSpeed.maxtime">
            $archive[1].windSpeed.max.format(add_label=False)</span><br>
            <span class="timestamp">$archive[1].windSpeed.maxtime</span><br>

My problem is that I cannot recover the direction of the wind during this maximum :

$archive[1].windDir.ordinal_compass ( $archive[1].windSpeed.max  ) does not work ! :-(

How should I do it?
Thank you


Tom Keffer

unread,
Jun 3, 2021, 4:41:54 PM6/3/21
to weewx-user
You could do something like (NOT TESTED):

#set t = $month.windSpeed.maxtime
<p>The max wind speed this month is $month.windSpeed.max from direction $current(timestamp=$t).windDir at time $t.</p>



--
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 weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/85fa1519-24ba-45a0-bc45-20bf18a9b9ben%40googlegroups.com.

Remy Lavabre

unread,
Jun 4, 2021, 4:07:09 AM6/4/21
to weewx-user
Thanks for the quick response! And it actually works :-)))

Two slight corrections are however to be made to work fine :

-1 / You forgot the "$" at timestamp. We must read $current($timestamp=$t).windDir instead of $current(timestamp=$t).windDir
-2 / The time format must be in raw to work. We must read #set t = $month.windSpeed.maxtime.raw instead of #set t = $month.windSpeed.maxtime

Aside from that it was a perfect solution !! Thanks again Tom

WindnFog

unread,
Jun 5, 2021, 3:13:48 PM6/5/21
to weewx-user
I embellished this a bit by adding the temperature ranges:

        #set t = $month.outTemp.mintime.raw
        #import time
        #set mnth=time.strftime("%B", time.localtime(t))
        #set str_t=time.strftime("%d %b at %H:%M", time.localtime(t))
        <p>Minimum temp for $mnth was $month.outTemp.min on $str_t
        <br/>
        #set t = $month.outTemp.maxtime.raw
        #set str_t=time.strftime("%d %b at %H:%M", time.localtime(t))
        Maximum temp for $mnth was $month.outTemp.max on $str_t
        <br/>
        #set t = $month.windSpeed.maxtime.raw
        #set str_t=time.strftime("%d %b at %H:%M", time.localtime(t))
        Maximum 10-min avg. wind speed for $mnth was $month.windSpeed.max
        <br/>
       (From the $current($timestamp=$t).windDir.ordinal_compass on $str_t)</p>

- Paul VE1DX

Tom Keffer

unread,
Jun 5, 2021, 3:32:48 PM6/5/21
to weewx-user
You're making this a lot more complicated than it needs to be. Try this:

#set $mnth=$month.dateTime.format("%B")
<p>Minimum temp for $mnth was $month.outTemp.min on $month.outTemp.mintime.format("%d %b at %H:%M")
<br/>
Maximum temp for $mnth was $month.outTemp.max on $month.outTemp.maxtime.format("%d %b at %H:%M")
<br/>
Maximum 10-min avg. wind speed for $mnth was $month.windSpeed.max
<br/>
#set t = $month.windSpeed.maxtime
(From the $current($timestamp=$t.raw).windDir.ordinal_compass on $t.format("%d %b at %H:%M"))</p>

Take a look through all the formatting options in the Customizing Guide. There's no need to do strftime manipulations.

Paul Dunphy

unread,
Jun 5, 2021, 3:46:35 PM6/5/21
to weewx...@googlegroups.com
    Thanks, Tom.  I always take the longest path between two point!

- Paul VE1DX
You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/w8QBuJtV6Tc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAPq0zEB2b1DJ%2BOPZkURqjoyuRUSnkG4OLRNqM6iKSH%2BOm2xGQA%40mail.gmail.com.

Remy Lavabre

unread,
Jun 6, 2021, 11:21:07 AM6/6/21
to weewx-user
In the same genre but for the rain (not rain rate) ... Is it possible to recover in Seasons on a period, the day of the maximum rain (the $day.rain.sum maximum) ?

          <span class="timestamp">$archive[1].rain.maxtime</span><br>
          $archive[1].rain.max.format(add_label=False)</td>
          <span class="timestamp">$archive[1].rain.maxtime</span><br>

Gives the day and time of the maximum value of rain in the loop packets ... OK no problem, but it does not give me the day with the maximum rain... :-( 


          $archive[1].rain.sum.format(add_label=False)</td>

Gives the total rainfall over the period ... OK not always the maximum rain day... :-(

How to get the maxi day rainfall over the period considered ??

Thank-you...

WindnFog

unread,
Jun 7, 2021, 10:47:17 AM6/7/21
to weewx-user
I think the fundamental flaw in doing this with rain is the "maximum time."  I stand to be corrected, but the maximum temperature, wind speed, etc., is something that is measured at a point in time.  I believe in the case of weewx, to the one-second granularity.  E.g., the highest daily (or monthly) reading might occur on "02 Jun at 15:41:22."  In reading the Customizing Guide (https://www.weewx.com/docs/customizing.htm), as Tom suggested to me, I don't see a way to get the sum and the day.

The rain total and date you seek are available in the NOAA-YYYY-MM.txt file under the Rain column.  A kludge would be to write a batch script of Python script that runs as a cron job between the update interval to extract the value and put it in your index.html.tmpl file.  There may be a way to do it similar to the way that temperature min and max are determined, but the lack of response from the weewx experts suggests that it's not simple.

- Paul VE1DX

Remy Lavabre

unread,
Jun 7, 2021, 11:40:54 AM6/7/21
to weewx-user
However, the total rainfall for each day is recorded in the SQL database :
In the "archive_day_rain" section, there are the fields "dateTime" which corresponds to the current date,
"min" which is obviously always zero,
max which most certainly corresponds to the maximum packet loop,
and "sum" which corresponds most certainly in the cumulative of the day.

WindnFog

unread,
Jul 2, 2021, 11:07:22 AM7/2/21
to weewx-user
It's also in the NOAA files that are updated every 5 minutes.  The following works with two caveats. First, there may be a "built-in" more straightforward way to do it within weewx AND my Python programming is in its infancy. Second, if you do this in python 2.7 instead of Python 3.x, you'll have to change the print statements and anything else to fit version 3's syntax changes.

(1) Save the following code in a file called find_high_rain_day.py, and run it once an hour sometime after minute 5   with cron in a bash script that includes python3 find_high_rain_day.py

import pandas as pd
import calendar
import datetime

now = datetime.datetime.now()
n = calendar.monthrange(now.year, now.month)[1]
mname = now.strftime("%b")

# Define the column locations and give them unique names. It doesn't matter
# what they are called except for two. We only use DAY and RAIN

headings = ['DAY','B','C','D','E','F','G','H',
            'RAIN','J','K','L','M']
colspecs = [(1, 3), (7, 11), (13, 18), (20, 25), (28, 32), (34, 39),
            (41, 45), (47, 53), (54, 60), (64, 67), (69, 74), (76, 81),
            (84, 88)]

import glob
import os

list_of_files = glob.glob('/var/www/html/weewx/NOAA/*')
latest_file = max(list_of_files, key=os.path.basename)

df = pd.read_fwf(latest_file,names=headings,header=0, colspecs=colspecs,skiprows=12,nrows=n)

maxrain = df['RAIN'].max()   # maximum value in rain column
i = df['RAIN'].idxmax()      # row index for day with max rain
maxrainday = df['DAY'][i]    # day for max rain

import sys
sys.stdout = open('/etc/weewx/skins/Standard/high_rain.txt', 'w')
if maxrainday < 10:
  prefix = '0'
else:
  prefix = ''
print(maxrain," cm on ",prefix,maxrainday," ",mname,sep="", end=" ")
sys.stdout.close()



This will generate a file "/etc/weewx/skins/Standard/high_rain.txt"

(2) Put the following line in your /etc/weewx/skins/Standard/index.html.tmpl file wherever you want the monthly day with the most rain listed on your website:

 #include raw "/etc/weewx/skins/Standard/high_rain.txt"


I tested it on my Raspberry Pi and it seemed to work OK.  YMMV.

- Paul VE1DX
Reply all
Reply to author
Forward
0 new messages