Mercurial > personal > weather-server
comparison weather_server/static/graph.js @ 41:4af79d69b12e v0.2.0
Use units better suited for science.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Tue, 01 Apr 2025 16:04:52 -0400 |
| parents | beedfa8eaa3f |
| children | d200755e0930 |
comparison
equal
deleted
inserted
replaced
| 40:5cc8ce54ad84 | 41:4af79d69b12e |
|---|---|
| 8 }); | 8 }); |
| 9 }; | 9 }; |
| 10 define("math", ["require", "exports"], function (require, exports) { | 10 define("math", ["require", "exports"], function (require, exports) { |
| 11 "use strict"; | 11 "use strict"; |
| 12 Object.defineProperty(exports, "__esModule", { value: true }); | 12 Object.defineProperty(exports, "__esModule", { value: true }); |
| 13 exports.dewPointC = exports.cToF = void 0; | 13 exports.dewPointC = exports.cToK = exports.cToF = void 0; |
| 14 function cToF(tempC) { | 14 function cToF(tempC) { |
| 15 return tempC * 9 / 5 + 32; | 15 return tempC * 9 / 5 + 32; |
| 16 } | 16 } |
| 17 exports.cToF = cToF; | 17 exports.cToF = cToF; |
| 18 function cToK(tempC) { | |
| 19 return tempC + 273.15; | |
| 20 } | |
| 21 exports.cToK = cToK; | |
| 18 const MAGNUS_B = 17.62; | 22 const MAGNUS_B = 17.62; |
| 19 const MAGNUS_C = 243.12; | 23 const MAGNUS_C = 243.12; |
| 20 function gammaFn(tempC, rhPct) { | 24 function gammaFn(tempC, rhPct) { |
| 21 return Math.log(rhPct / 100) + MAGNUS_B * tempC / (MAGNUS_C + tempC); | 25 return Math.log(rhPct / 100) + MAGNUS_B * tempC / (MAGNUS_C + tempC); |
| 22 } | 26 } |
| 46 const readings = data.readings; | 50 const readings = data.readings; |
| 47 if (readings.length === 0) | 51 if (readings.length === 0) |
| 48 return; | 52 return; |
| 49 root.classList.remove('plain'); | 53 root.classList.remove('plain'); |
| 50 root.classList.add('fancy'); | 54 root.classList.add('fancy'); |
| 51 const tempsF = readings.map(s => [s.sample_time, math_1.cToF(s.temp_c)]); | 55 const tempsF = readings.map(s => [s.sample_time, (0, math_1.cToK)(s.temp_c)]); |
| 52 const dewPointsF = readings.map(s => [s.sample_time, math_1.cToF(math_1.dewPointC(s.temp_c, s.rh_pct))]); | 56 const dewPointsF = readings.map(s => [s.sample_time, (0, math_1.cToK)((0, math_1.dewPointC)(s.temp_c, s.rh_pct))]); |
| 53 setUpElement(tempElement, [startTS, nowTS], tempsF); | 57 setUpElement(tempElement, [startTS, nowTS], tempsF); |
| 54 setUpElement(dewPointElement, [startTS, nowTS], dewPointsF); | 58 setUpElement(dewPointElement, [startTS, nowTS], dewPointsF); |
| 55 }); | 59 }); |
| 56 } | 60 } |
| 57 exports.setUp = setUp; | 61 exports.setUp = setUp; |
