WernerKr / weewx-sunrainduration

Evaluates solar radiation and rain and thus generates the corresponding duration
GNU General Public License v3.0
0 stars 1 forks source link

weewx-sunrainduration

Evaluates solar radiation and rain and thus generates the corresponding duration

sunduration based on https://github.com/Jterrettaz/sunduration/blob/master/sunduration.py

  sunshinetime = Value when sunshine duration is recorded in W/m²
  sunshineDur   = Sunshine duration value in the archive interval in seconds
  rainDur       = rain duration value in the archive interval in seconds
  hailDur       = rain duration value (Ecowitt-Piezo) in the archive interval in seconds
  sunshineDur2 = Sunshine duration value in the archive interval in seconds for 2. DAVIS station (e.g. live or console)
  rainDur2     = Rain duration value in the archive interval in seconds for 2. DAVIS station (e.g. live or console)

    weewx.conf:

[StdReport]
 [[Defaults]]
  [[[Units]]]
   [[[[Groups]]]]
       group_deltatime = hour

[StdWXCalculate]
     [[WXXTypes]]
         [[[maxSolarRad]]]
             algorithm = rs
             atc = 0.9
[Engine]
  [[Services]]
     process_services = ..., weewx.wxservices.StdWXCalculate, user.sunrainduration.SunshineDuration

[RadiationDays]
    min_sunshine = 120    # Entry of extension radiationhours.py, if is installed (= limit value)
    sunshine_coeff = 0.91 # Factor from which value sunshine is counted - the higher the later
    sunshine_min = 18     # below this value (W/m²), sunshine is not taken into account.
    sunshine_loop = 1     # use for sunshine loop packet (or archive: sunshine_loop = 0)
    rainDur_loop = 0      # use for rain duration loop packet - default is not  
    hailDur_loop = 0      # use for piezo-rain duration loop packet - default is not
    sunshine_log = 0      # should not be logged when sunshine is recorded
    rainDur_log = 0       # no logging for rain duration
    hailDur_log = 0       # no logging for piezo-rain duration
    rain2 = 0             # no rain2 available (Davis Live, Davis Console)
    sunshine2 = 0         # no shunhine2 available (Davis Live, Davis Console) 
    sunshine2_loop = 1
    rainDur2_loop = 0
    sunshine2_log = 0
    rainDur2_log = 0

The "atc = 0.9" and "sunshine_coeff = 0.91" have to be adjusted for your own location.
With this adjustment, the sunshine duration values are very accurate and also work for other stations (e.g. Ecowitt), 
not just VantagePro.
add_sunrain.sh: Weewx (v4.5.0 to V4.10.2)

 #!/bin/bash
 sudo echo "y" | wee_database --config=/etc/weewx/weewx.conf --add-column=sunshinetime --type=REAL
 sudo echo "y" | wee_database --config=/etc/weewx/weewx.conf --add-column=sunshineDur --type=REAL
 sudo echo "y" | wee_database --config=/etc/weewx/weewx.conf --add-column=rainDur --type=REAL
 # for Ecowitt Stations and two rain sensors (WS90 and WH40)
 sudo echo "y" | wee_database --config=/etc/weewx/weewx.conf --add-column=hailDur --type=REAL
 # only for second station (like VantagePro and VantageVUE)
 sudo echo "y" | wee_database --config=/etc/weewx/weewx.conf --add-column=sunshineDur2 --type=REAL
 sudo echo "y" | wee_database --config=/etc/weewx/weewx.conf --add-column=rainDur2 --type=REAL

 Weewx V5.0 or newer:
 #sudo echo "y" | weectl database add-column sunshine_time
 weectl database add-column sunshinetime --type=REAL --config=/etc/weewx/weewx.conf -y
 weectl database add-column sunshineDur --type=REAL --config=/etc/weewx/weewx.conf -y
 weectl database add-column rainDur --type=REAL --config=/etc/weewx/weewx.conf -y
 #weectl database add-column hailDur --type=REAL --config=/etc/weewx/weewx.conf -y
 #weectl database add-column sunshineDur2 --type=REAL --config=/etc/weewx/weewx.conf -y
 #weectl database add-column rainDur2 --type=REAL --config=/etc/weewx/weewx.conf -y     

    extension.py: ( not more needed - now in sunrainduration.py included )

     import weewx.units
     weewx.units.obs_group_dict['sunshinetime'] = 'group_radiation'
     weewx.units.obs_group_dict['hailDur'] = 'group_deltatime'
     weewx.units.obs_group_dict['sunshineDur2'] = 'group_deltatime'
     weewx.units.obs_group_dict['rainDur2'] = 'group_deltatime'

image

   [[[dayradiation]]]
        color = "#e8e81b"
            [[[[maxSolarRad]]]]
        color = "#a7a7aa"
            [[[[sunshinetime]]]]
        color = "red"
              label = Sonnenschein
            [[[[radiation]]]]
        fill_color = "#ecf402"
        plot_type = bar

   [[[daysunshine]]]
           color = "#ea078b"
           plot_type = bar
        yscale = 0.0, 15, 2.5
           [[[[sunshineDur]]]]
        data_type = sunshineDur / 60
              y_label = "Minuten"
              label = Sonnenschein

image

image

[[solarRadGraph3]]
    title = Solarstrahlung und Dauer
    time_length = day_ago_to_now
    time_ago = 2
    [[[radiation]]]
       name = Solarstrahlung
       zIndex = 1
       color = "#ffc83f"
    [[[maxSolarRad]]]
        name = Theor. Max Solarstrahlung
        type = area
        color = "#f7f2b4"
        yAxis_label = "W/m2"
   [[[sunshinetime]]]
        name = Sonnenschein
        color = "#ea078b"
        yAxis_label = "Solarstrahlung W/m2"
   [[[sunshineDur]]]
       aggregate_type = sum
       type = column  
       yAxis = 1
       yAxis_min = 0
       yAxis_softMax = 3
       color = "#eae7c5"
       zIndex = 2

For the rain duration history or sun duration history in the Belchertown skin you need my modified belchertown.py file

image

    [[chart3Jahr]]
     time_length = year_ago_to_now
        title = Regen Jahr
        type = line
        [[[rainRate]]]
            yAxis = 1
        [[[rainTotal]]]
            name = Regen gesamt

chart

[[Regendauer]]
     time_length = year_ago_to_now
    [[[rainDur]]]
        aggregate_type = sum
     type = column
        yAxis_min = 0
        yAxis_softMax = 14
        color = "blue"
   [[[rainDurTotal]]]
         yAxis = 1
         yAxis_min = 0
         color = red
         yAxis_label = "Regendauer in Std."
         name = Regendauerverlauf
         zIndex = 2

dieser-monat

 [[Sonnenschein]]
    [[[sunshineDur]]]
        aggregate_type = sum
    type = column
        yAxis_min = 0
        yAxis_softMax = 10
        color = "yellow"
   [[[sunshineDurTotal]]]
         yAxis = 1
         yAxis_min = 0
         color = red
         yAxis_label = "Sonnenscheindauer in Std"
         name = Sonnenscheindauerverlauf
         zIndex = 2

sonnendauer

   [[sonne]]
    title = Sonnendauer
         aggregate_interval = 3600
    [[[sunshineDur]]]
        aggregate_type = sum
        type = column
        yAxis_min = 0
        yAxis_softMax = 3
        color = "#eae7c5"
         yAxis_label_unit = "Stunden"
   [[[sunshineDurTotal]]]
         yAxis = 1
         yAxis_min = 0
         color = red
         yAxis_label = "Sonnenscheindauer in Std"
         name = Sonnenscheindauerverlauf
         zIndex = 2

2024-05-23 18_49_39-Window



  Bootstrap History:
   [[sunshineDur]]
       obs_type = sunshineDur
       colors = sunshineDur, hour
       aggregate_type = sum
       units = h
       summary_column = true
       summary_heading = Std.

   [[rainDur]]
       obs_type = rainDur
       colors = rainDur, hour
       aggregate_type = sum
       units = h
       summary_column = true
       summary_heading = Std.