Clear-sky beam and diffuse irradiance
64-bitThe irradiance outside the atmosphere, the beam transmittance, and the beam and diffuse irradiance at the ground.
τ_b = a₀ + a₁·exp(−k ÷ cos Z); G_on = 1367·(1 + 0.033·cos(2πn ÷ 365)); G_bn = G_on·τ_b; τ_d = 0.271 − 0.294·τ_b
The coefficients a₀, a₁ and k are quadratics in altitude with constants written to 3 or 4 digits (0.4237, 0.00821, 0.5055, 0.00595, 0.2711, 0.01858), scaled by the climate factors. The division by cos Z is guarded by returning zeros when cos Z is not positive.
export function clearSky(n, cosZ, { altitudeKm = 0, climate = 'midlat-summer' } = {}) {
const A = Math.max(0, Math.min(2.5, altitudeKm));
const [r0, r1, rk] = CLIMATES[climate] || CLIMATES['midlat-summer'];
const a0 = r0 * (0.4237 - 0.00821 * (6 - A) ** 2), a1 = r1 * (0.5055 + 0.00595 * (6.5 - A) ** 2), k = rk * (0.2711 + 0.01858 * (2.5 - A) ** 2);
const Gon = GSC * (1 + 0.033 * Math.cos(2 * Math.PI * n / 365));
if (!(cosZ > 0)) return { Gon, tauB: 0, Gbn: 0, Gbh: 0, Gdh: 0 };
const tauB = a0 + a1 * Math.exp(-k / cosZ), tauD = 0.271 - 0.294 * tauB;
return { Gon, tauB, Gbn: Gon * tauB, Gbh: Gon * tauB * cosZ, Gdh: Gon * cosZ * tauD };
}