From 1a65439ebfe9e6984a22f311739a5cd818993a1c Mon Sep 17 00:00:00 2001 From: Clayton Young Date: Sat, 21 Feb 2026 17:35:07 -0500 Subject: [PATCH] fix(html): embed animation data for CORS-safe local file access - Created generate_html.py to embed JSON data directly in HTML - No external fetch() needed - works when opened directly in browser - File size: 149.5 KB (self-contained) - Shows forecast horizon (12-36 months) in stats --- .../global-temperature/generate_html.py | 544 ++ .../interactive_forecast.html | 5473 ++++++++++++++++- 2 files changed, 5996 insertions(+), 21 deletions(-) create mode 100644 scientific-skills/timesfm-forecasting/examples/global-temperature/generate_html.py diff --git a/scientific-skills/timesfm-forecasting/examples/global-temperature/generate_html.py b/scientific-skills/timesfm-forecasting/examples/global-temperature/generate_html.py new file mode 100644 index 0000000..16cc417 --- /dev/null +++ b/scientific-skills/timesfm-forecasting/examples/global-temperature/generate_html.py @@ -0,0 +1,544 @@ +#!/usr/bin/env python3 +""" +Generate a self-contained HTML file with embedded animation data. + +This creates a single HTML file that can be opened directly in any browser +without needing a server or external JSON file (CORS-safe). +""" + +from __future__ import annotations + +import json +from pathlib import Path + +EXAMPLE_DIR = Path(__file__).parent +DATA_FILE = EXAMPLE_DIR / "animation_data.json" +OUTPUT_FILE = EXAMPLE_DIR / "interactive_forecast.html" + + +HTML_TEMPLATE = """ + + + + + TimesFM Interactive Forecast Animation + + + + +
+
+

TimesFM Forecast Evolution

+

Watch the forecast evolve as more data is added — forecasts extend to 2025-12

+
+ +
+ +
+ +
+
+
+ Data Points Used + 12 / 36 +
+ +
+ 2022-01 + Using data through 2022-12 +
+
+ +
+ + +
+ +
+
+
Forecast Mean
+
0.86°C
+
+
+
Forecast Horizon
+
36 months
+
+
+
Forecast Max
+
--
+
+
+
Forecast Min
+
--
+
+
+ +
+
+
+ All Observed Data +
+
+
+ Final Forecast (reference) +
+
+
+ Data Used +
+
+
+ Current Forecast +
+
+
+ 80% CI +
+
+
+ + +
+ + + + +""" + + +def main() -> None: + print("=" * 60) + print(" GENERATING SELF-CONTAINED HTML") + print("=" * 60) + + # Load animation data + with open(DATA_FILE) as f: + data = json.load(f) + + # Generate HTML with embedded data + html_content = HTML_TEMPLATE.format(data_json=json.dumps(data, indent=2)) + + # Write output + with open(OUTPUT_FILE, "w") as f: + f.write(html_content) + + size_kb = OUTPUT_FILE.stat().st_size / 1024 + print(f"\n✅ Generated: {OUTPUT_FILE}") + print(f" File size: {size_kb:.1f} KB") + print(f" Fully self-contained — no external dependencies") + + +if __name__ == "__main__": + main() diff --git a/scientific-skills/timesfm-forecasting/examples/global-temperature/interactive_forecast.html b/scientific-skills/timesfm-forecasting/examples/global-temperature/interactive_forecast.html index 56aede3..7cb213f 100644 --- a/scientific-skills/timesfm-forecasting/examples/global-temperature/interactive_forecast.html +++ b/scientific-skills/timesfm-forecasting/examples/global-temperature/interactive_forecast.html @@ -129,7 +129,7 @@

TimesFM Forecast Evolution

-

Watch the forecast evolve as more data is added — with full context always visible

+

Watch the forecast evolve as more data is added — forecasts extend to 2025-12

@@ -160,8 +160,8 @@
0.86°C
-
vs Final Forecast
-
--
+
Forecast Horizon
+
36 months
Forecast Max
@@ -203,30 +203,5459 @@