3.0.2
Fix the Why It Feels calcs
This commit is contained in:
+20
-8
@@ -330,15 +330,27 @@ export function computeWhyFeelsLike(row, env) {
|
||||
const { Ta, Tmrt, va, eh, precip, snow } = row;
|
||||
const r1 = (v) => Math.round(v * 10) / 10;
|
||||
|
||||
// Radiation - mean radiant temp above or below air temp.
|
||||
const sunAndSky = r1(Tmrt - Ta);
|
||||
// Environment-adjusted air temp (same as used in buildHourlyRows).
|
||||
const TaEnv = Ta + (env ? env.taOffset : 0);
|
||||
|
||||
// Wind - UTCI with actual wind vs calm, holding Tmrt = Ta and RH neutral.
|
||||
const ehNeutral = vaporPressureHpa(Ta, 50);
|
||||
const wind = r1(utciApprox(Ta, Ta, va, ehNeutral) - utciApprox(Ta, Ta, 0, ehNeutral));
|
||||
// Sequential UTCI isolation — all deltas are in the same UTCI-polynomial
|
||||
// space so they add up: Ta + environment + sunAndSky + wind + humidity
|
||||
// + precipitation ≈ SunSoak (utciAdj), within rounding.
|
||||
//
|
||||
// Tmrt already has env radiation scaling (dirFactor/difFactor/globFactor)
|
||||
// baked in from buildHourlyRows, so each delta automatically reflects
|
||||
// the active Solar Model without any extra work here.
|
||||
const ehNeutral = vaporPressureHpa(TaEnv, 50);
|
||||
const base = utciApprox(TaEnv, TaEnv, 0, ehNeutral); // ≈ TaEnv
|
||||
|
||||
// Humidity - actual vapour pressure vs neutral RH 50%, no wind or sun.
|
||||
const humidity = r1(utciApprox(Ta, Ta, 0, eh) - utciApprox(Ta, Ta, 0, ehNeutral));
|
||||
// Radiation: effect of actual Tmrt vs no-radiation baseline (wind=0, RH=50%).
|
||||
const sunAndSky = r1(utciApprox(TaEnv, Tmrt, 0, ehNeutral) - base);
|
||||
|
||||
// Wind: cooling effect of actual wind with solar present (RH still neutral).
|
||||
const wind = r1(utciApprox(TaEnv, Tmrt, va, ehNeutral) - utciApprox(TaEnv, Tmrt, 0, ehNeutral));
|
||||
|
||||
// Humidity: actual vapour pressure vs neutral RH 50%, with solar and wind.
|
||||
const humidity = r1(utciApprox(TaEnv, Tmrt, va, eh) - utciApprox(TaEnv, Tmrt, va, ehNeutral));
|
||||
|
||||
// Environment modifier - explicit temperature offset from the env config.
|
||||
const environment = env ? r1(env.taOffset) : 0;
|
||||
@@ -346,7 +358,7 @@ export function computeWhyFeelsLike(row, env) {
|
||||
// Precipitation soak penalty - negative or zero.
|
||||
const precipitation = precipPenalty(precip, snow, va);
|
||||
|
||||
return { sunAndSky, wind, humidity, environment, precipitation };
|
||||
return { base: r1(base), sunAndSky, wind, humidity, environment, precipitation };
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user