# HG changeset patch
# User Paul Fisher
# Date 1743537892 14400
# Node ID 4af79d69b12eff556ea0d00e4daf38bf7190ed80
# Parent 5cc8ce54ad845d5b9d329e31ac113178c895cbc1
Use units better suited for science.
diff -r 5cc8ce54ad84 -r 4af79d69b12e weather_server/static/graph.js
--- a/weather_server/static/graph.js Tue Apr 01 15:54:42 2025 -0400
+++ b/weather_server/static/graph.js Tue Apr 01 16:04:52 2025 -0400
@@ -10,11 +10,15 @@
define("math", ["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
- exports.dewPointC = exports.cToF = void 0;
+ exports.dewPointC = exports.cToK = exports.cToF = void 0;
function cToF(tempC) {
return tempC * 9 / 5 + 32;
}
exports.cToF = cToF;
+ function cToK(tempC) {
+ return tempC + 273.15;
+ }
+ exports.cToK = cToK;
const MAGNUS_B = 17.62;
const MAGNUS_C = 243.12;
function gammaFn(tempC, rhPct) {
@@ -48,8 +52,8 @@
return;
root.classList.remove('plain');
root.classList.add('fancy');
- const tempsF = readings.map(s => [s.sample_time, math_1.cToF(s.temp_c)]);
- const dewPointsF = readings.map(s => [s.sample_time, math_1.cToF(math_1.dewPointC(s.temp_c, s.rh_pct))]);
+ const tempsF = readings.map(s => [s.sample_time, (0, math_1.cToK)(s.temp_c)]);
+ const dewPointsF = readings.map(s => [s.sample_time, (0, math_1.cToK)((0, math_1.dewPointC)(s.temp_c, s.rh_pct))]);
setUpElement(tempElement, [startTS, nowTS], tempsF);
setUpElement(dewPointElement, [startTS, nowTS], dewPointsF);
});
diff -r 5cc8ce54ad84 -r 4af79d69b12e weather_server/static/graph.js.map
--- a/weather_server/static/graph.js.map Tue Apr 01 15:54:42 2025 -0400
+++ b/weather_server/static/graph.js.map Tue Apr 01 16:04:52 2025 -0400
@@ -1,1 +1,1 @@
-{"version":3,"file":"graph.js","sourceRoot":"","sources":["../typescript/app/math.ts","../typescript/app/graph.ts"],"names":[],"mappings":";;;;;;;;;;;;;IACA,SAAgB,IAAI,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AAO,MAAM,CAAC;IAClB,CAAC;IAID,SAAS,YAAY,CAAC,CAAS;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACtC,CAAC","sourcesContent":["/** Converts Celsius to Fahrenheit. */\nexport function cToF(tempC: number): number {\n return tempC * 9 / 5 + 32;\n}\n\nconst MAGNUS_B = 17.62;\nconst MAGNUS_C = 243.12;\n\n/** The gamma function to calculate dew point. */\nfunction gammaFn(tempC: number, rhPct: number): number {\n return Math.log(rhPct / 100) + MAGNUS_B * tempC / (MAGNUS_C + tempC);\n}\n\n/** Calculates the dew point. */\nexport function dewPointC(tempC: any, rhPct: any): number {\n const gamma = gammaFn(tempC, rhPct);\n return MAGNUS_C * gamma / (MAGNUS_B - gamma);\n}\n","import { WeatherResponse } from './apis';\nimport { cToF, dewPointC } from './math';\n\n/** The amount of time we will draw on the graph. */\nconst HISTORY_SECONDS = 60 * 60 * 4;\n/** The amount of buffer room we will request before HISTORY_SECONDS. */\nconst BUFFER_SECONDS = 300;\n\n/**\n * Sets up everything.\n * @param tempElement The element where temperature data is.\n * @param dewPointElement The element where the dew point is.\n */\nexport async function setUp(\n root: HTMLElement,\n tempElement: HTMLElement,\n dewPointElement: HTMLElement) {\n const nowTS = new Date().getTime() / 1000;\n const startTS = nowTS - HISTORY_SECONDS;\n const query = new URL('?', location.href);\n query.pathname = query.pathname + '/recent';\n query.searchParams.set('seconds', String(HISTORY_SECONDS + BUFFER_SECONDS));\n const results = await fetch(query.href);\n if (!results.ok) return;\n const data: WeatherResponse = await results.json();\n const readings = data.readings;\n if (readings.length === 0) return;\n root.classList.remove('plain');\n root.classList.add('fancy');\n\n const tempsF =\n readings.map(s => [s.sample_time, cToF(s.temp_c)] as Point);\n const dewPointsF = readings.map(\n s => [s.sample_time, cToF(dewPointC(s.temp_c, s.rh_pct))] as Point);\n setUpElement(tempElement, [startTS, nowTS], tempsF);\n setUpElement(dewPointElement, [startTS, nowTS], dewPointsF);\n}\n\ntype Point = [number, number];\n\n/**\n * Sets up charting for this element.\n * @param element The element to put a graph in.\n * @param timeRange The `[start, end]` of the time range.\n * @param data The data to chart.\n */\nfunction setUpElement(\n element: HTMLElement, timeRange: [number, number], data: Point[]) {\n if (data.length === 0) return;\n const chart = new Chart(element, timeRange, data);\n chart.resize();\n addEventListener('resize', () => chart.resize());\n}\n\n/** The number of degrees that the graph shows vertically. */\nconst Y_DEGREE_RANGE = 12;\n\nconst LINE_WIDTH_PX = 2;\nconst GRID_WIDTH_PX = 0.5;\n\nconst FONT_SIZE = '40px';\n\nclass Chart {\n private readonly canvas: HTMLCanvasElement;\n private readonly unit: string;\n /**\n * Creates a new chart.\n * @param element The parent element to create `
@@ -29,9 +29,9 @@
- {{- last_reading.dew_point_f|int -}}
+ {{- last_reading.dew_point_k|int -}}
- °F
+ K
diff -r 5cc8ce54ad84 -r 4af79d69b12e weather_server/types.py
--- a/weather_server/types.py Tue Apr 01 15:54:42 2025 -0400
+++ b/weather_server/types.py Tue Apr 01 16:04:52 2025 -0400
@@ -13,6 +13,10 @@
return c * 9 / 5 + 32
+def c_to_k(c: float) -> float:
+ return c + 273.15
+
+
# Values from Sontag1990 via Wikipedia:
# https://en.wikipedia.org/wiki/Dew_point
_MAGNUS_B = 17.62
@@ -41,6 +45,10 @@
@property
def temp_f(self) -> float:
return c_to_f(self.temp_c)
+
+ @property
+ def temp_k(self) -> float:
+ return c_to_k(self.temp_k)
@property
def dew_point_c(self) -> float:
@@ -50,6 +58,10 @@
@property
def dew_point_f(self) -> float:
return c_to_f(self.dew_point_c)
+
+ @property
+ def dew_point_k(self) -> float:
+ return c_to_k(self.dew_point_c)
@classmethod
def from_dict(cls: t.Type[T], d: t.Dict[str, t.Any]) -> T:
diff -r 5cc8ce54ad84 -r 4af79d69b12e weather_server/typescript/app/graph.ts
--- a/weather_server/typescript/app/graph.ts Tue Apr 01 15:54:42 2025 -0400
+++ b/weather_server/typescript/app/graph.ts Tue Apr 01 16:04:52 2025 -0400
@@ -1,5 +1,5 @@
import { WeatherResponse } from './apis';
-import { cToF, dewPointC } from './math';
+import { cToK, dewPointC } from './math';
/** The amount of time we will draw on the graph. */
const HISTORY_SECONDS = 60 * 60 * 4;
@@ -29,9 +29,9 @@
root.classList.add('fancy');
const tempsF =
- readings.map(s => [s.sample_time, cToF(s.temp_c)] as Point);
+ readings.map(s => [s.sample_time, cToK(s.temp_c)] as Point);
const dewPointsF = readings.map(
- s => [s.sample_time, cToF(dewPointC(s.temp_c, s.rh_pct))] as Point);
+ s => [s.sample_time, cToK(dewPointC(s.temp_c, s.rh_pct))] as Point);
setUpElement(tempElement, [startTS, nowTS], tempsF);
setUpElement(dewPointElement, [startTS, nowTS], dewPointsF);
}
diff -r 5cc8ce54ad84 -r 4af79d69b12e weather_server/typescript/app/math.ts
--- a/weather_server/typescript/app/math.ts Tue Apr 01 15:54:42 2025 -0400
+++ b/weather_server/typescript/app/math.ts Tue Apr 01 16:04:52 2025 -0400
@@ -3,6 +3,11 @@
return tempC * 9 / 5 + 32;
}
+/** Converts Celsius to Kelvin. */
+export function cToK(tempC: number): number {
+ return tempC + 273.15;
+}
+
const MAGNUS_B = 17.62;
const MAGNUS_C = 243.12;