Where does the crt extension get the value for SolarMax?

16 views
Skip to first unread message

Peter Fletcher

unread,
Dec 1, 2025, 4:44:08 PM (5 days ago) Dec 1
to weewx-development
The extension works out whether the sun is shining (one of the fields in Cumulus's realtime.txt file) by comparing SolarMax - another field in the file, which appears to be the calculated solar radiation if the sun were out at the current time and location in a cloudless sky - with the current solar radiation value from the latest data, but I can't see where the value of SolarMax comes from. From the code, it looks as if it comes from database data, but there is no such field in the database. Where is it calculated, and how could one access its value from another plugin, if one were to wish to?

John Smith

unread,
Dec 1, 2025, 8:19:15 PM (5 days ago) Dec 1
to Peter Fletcher, weewx-development
Wouldn't it just be the max solar value for a given time period?

On Tue, 2 Dec 2025 at 08:44, 'Peter Fletcher' via weewx-development <weewx-de...@googlegroups.com> wrote:
The extension works out whether the sun is shining (one of the fields in Cumulus's realtime.txt file) by comparing SolarMax - another field in the file, which appears to be the calculated solar radiation if the sun were out at the current time and location in a cloudless sky - with the current solar radiation value from the latest data, but I can't see where the value of SolarMax comes from. From the code, it looks as if it comes from database data, but there is no such field in the database. Where is it calculated, and how could one access its value from another plugin, if one were to wish to?

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-development/8e6d0976-3edf-42b7-bb6a-7123cfcb210en%40googlegroups.com.

Peter Fletcher

unread,
Dec 1, 2025, 10:14:33 PM (4 days ago) Dec 1
to weewx-development
No. The logic of the crt code implies that it is a theoretical max value, and the actual values reported in realtime.txt are consistent with this.

John Smith

unread,
Dec 1, 2025, 11:19:44 PM (4 days ago) Dec 1
to Peter Fletcher, weewx-development
On Tue, 2 Dec 2025 at 14:14, 'Peter Fletcher' via weewx-development <weewx-de...@googlegroups.com> wrote:
No. The logic of the crt code implies that it is a theoretical max value, and the actual values reported in realtime.txt are consistent with this.

What's it based on, latitude? 

John Kline

unread,
Dec 1, 2025, 11:38:07 PM (4 days ago) Dec 1
to Peter Fletcher, weewx-development
maxSolarRad defaults to hardware preferred.  Assuming it is not supplied by the driver, it is calculated in wxxtypes.py

The function is below.  Note that the default for maxSolarRad_algo is ‘rs’.

    def calc_maxSolarRad(self, key, data, db_manager):
        altitude_m = weewx.units.convert(self.altitude_vt, 'meter')[0]
        if self.maxSolarRad_algo == 'bras':
            val = weewx.wxformulas.solar_rad_Bras(self.latitude_f, self.longitude_f, altitude_m,
                                                  data['dateTime'], self.nfac)
        elif self.maxSolarRad_algo == 'rs':
            val = weewx.wxformulas.solar_rad_RS(self.latitude_f, self.longitude_f, altitude_m,
                                                data['dateTime'], self.atc)
        else:
            raise weewx.ViolatedPrecondition("Unknown solar algorithm '%s'"
                                             % self.maxSolarRad_algo)
        return ValueTuple(val, 'watt_per_meter_squared', 'group_radiation')

wxformulas.py: solar_rad_RS:
   from weewx.almanac import Almanac
    if atc < 0.7 or atc > 0.91:
        atc = 0.8
    if ts is None:
        ts = time.time()
    sr = 0.0
    try:
        alm = Almanac(ts, lat, lon, altitude_m)
        el = alm.sun.alt  # solar elevation degrees from horizon
        R = alm.sun.earth_distance
        z = altitude_m
        nrel = 1367.0  # NREL solar constant, W/m^2
        sinal = math.sin(math.radians(el))
        if sinal >= 0:  # sun must be above horizon
            rm = math.pow((288.0 - 0.0065 * z) / 288.0, 5.256) \
                 / (sinal + 0.15 * math.pow(el + 3.885, -1.253))
            toa = nrel * sinal / (R * R)
            sr = toa * math.pow(atc, rm)
    except (AttributeError, ValueError, OverflowError):
        sr = None
    return sr

On Dec 1, 2025, at 8:19 PM, John Smith <deltafo...@gmail.com> wrote:


On Tue, 2 Dec 2025 at 14:14, 'Peter Fletcher' via weewx-development <weewx-de...@googlegroups.com> wrote:
No. The logic of the crt code implies that it is a theoretical max value, and the actual values reported in realtime.txt are consistent with this.

What's it based on, latitude? 

--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.

John Smith

unread,
Dec 2, 2025, 12:21:49 AM (4 days ago) Dec 2
to John Kline, Peter Fletcher, weewx-development
Any idea what the difference between the 2 formulas in weeWX would be?

wxformulas.py links to a page with an excel spreadsheet which seems to use macros instead of just formulas, but LibreOffice blocked them on security grounds. The spreadsheet seems to have 4 models

Searching for solar radiation maximum "bras" didn't exactly turn up anything relevant...

John Kline

unread,
Dec 2, 2025, 11:35:56 AM (4 days ago) Dec 2
to John Smith, Peter Fletcher, weewx-development
Search for:

Ryan-Stolzenbach vs. Bras for estimating clear sky solar radiation

On Dec 1, 2025, at 9:21 PM, John Smith <deltafo...@gmail.com> wrote:



John Smith

unread,
Dec 2, 2025, 7:14:30 PM (4 days ago) Dec 2
to John Kline, Peter Fletcher, weewx-development
Searching for those terms also ended in dead ends for a few different reasons, without easy to understand summaries, most were links to women's underwear, so I resorted to asking ChatGPT which told me both methods are old (1970s-1980s) and it suggested using REST2 (Gueymard, 2008) as a more accurate method which has been implemented in pvlib.


Reply all
Reply to author
Forward
0 new messages