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