From 951eb71b83dc6457a845d45aae2007d4a3e8fdc5 Mon Sep 17 00:00:00 2001 From: grizzly Date: Sat, 23 Aug 2025 22:15:45 -0400 Subject: [PATCH] change to full-day weather and update icons --- document.typ | 75 ++++++++++++++++++++++++-------- icons/clear_day.svg | 9 ++++ icons/clear_night.svg | 19 ++++++++ icons/cloudy_day_night.svg | 9 ++++ icons/drizzle_day_night.svg | 24 ++++++++++ icons/fog_day_night.svg | 14 ++++++ icons/hail_day_night.svg | 39 +++++++++++++++++ icons/haze_day.svg | 14 ++++++ icons/haze_night.svg | 14 ++++++ icons/partly_cloudy_day.svg | 14 ++++++ icons/partly_cloudy_night.svg | 14 ++++++ icons/rain_day_night.svg | 34 +++++++++++++++ icons/sleet_day_night.svg | 34 +++++++++++++++ icons/snow_day_night.svg | 34 +++++++++++++++ icons/sunrise.svg | 19 ++++++++ icons/sunset.svg | 19 ++++++++ icons/thunder_day_night.svg | 14 ++++++ icons/thunderstorm_day_night.svg | 34 +++++++++++++++ icons/wind_day_night.svg | 14 ++++++ update.sh | 5 +-- 20 files changed, 430 insertions(+), 22 deletions(-) create mode 100644 icons/clear_day.svg create mode 100644 icons/clear_night.svg create mode 100644 icons/cloudy_day_night.svg create mode 100644 icons/drizzle_day_night.svg create mode 100644 icons/fog_day_night.svg create mode 100644 icons/hail_day_night.svg create mode 100644 icons/haze_day.svg create mode 100644 icons/haze_night.svg create mode 100644 icons/partly_cloudy_day.svg create mode 100644 icons/partly_cloudy_night.svg create mode 100644 icons/rain_day_night.svg create mode 100644 icons/sleet_day_night.svg create mode 100644 icons/snow_day_night.svg create mode 100644 icons/sunrise.svg create mode 100644 icons/sunset.svg create mode 100644 icons/thunder_day_night.svg create mode 100644 icons/thunderstorm_day_night.svg create mode 100644 icons/wind_day_night.svg diff --git a/document.typ b/document.typ index af6d004..ea27728 100644 --- a/document.typ +++ b/document.typ @@ -1,26 +1,63 @@ #set page(width: 65mm, height: 86mm) #let today = datetime.today() #let weather = json("weather.json") -#let icon = none -#if weather.current.weather_code == 0{ - icon = image("icons/sun.svg", width:3em) -} - - -#align(center)[ - #text(size:2em, weight: "bold")[#today.display("[weekday] [month repr:long] [year]")] - - -#v(1fr) - -#grid( - columns: (1fr,2fr), - align: (center+horizon, left+horizon), - [#icon],[#text(size:3em)[#weather.current.temperature_2m #weather.current_units.temperature_2m]] +#let icons_map = ( + "0": "icons/clear_day.svg", + "1": "icons/clear_day.svg", + "2": "icons/partly_cloudy_day.svg", + "3": "icons/partly_cloudy_day.svg", + "45": "icons/haze_day.svg", + "48": "icons/haze_day.svg", + "51": "icons/rain_day_night.svg", + "53": "icons/rain_day_night.svg", + "55": "icons/rain_day_night.svg", + "56": "icons/sleet_day_night.svg", + "57": "icons/sleet_day_night.svg", + "61": "icons/rain_day_night.svg", + "63": "icons/rain_day_night.svg", + "65": "icons/rain_day_night.svg", + "66": "icons/sleet_day_night.svg", + "67": "icons/sleet_day_night.svg", + "71": "icons/snow_day_night.svg", + "73": "icons/snow_day_night.svg", + "75": "icons/snow_day_night.svg", + "77": "icons/snow_day_night.svg", + "80": "icons/rain_day_night.svg", + "81": "icons/rain_day_night.svg", + "82": "icons/rain_day_night.svg", + "85": "icons/snow_day_night.svg", + "86": "icons/snow_day_night.svg", + "95": "icons/thunder_day_night.svg", + "96": "icons/hail_day_night.svg", + "99": "icons/hail_day_night.svg", ) -#v(1fr) -#read("event.txt") -#v(1fr) +#let decimate_array(a,n:2) = { + let ret = () + for (i,v) in a.enumerate(){ + if calc.rem-euclid(i,n) == 0{ + ret.push(v) + } + } + return ret +} + +#align(center)[ + #text(size:1.3em, weight: "bold")[#today.display("[weekday] [month repr:long] [year]")] + +#let times = () +#for i in range(24){ + times.push(datetime(hour:i,minute:0,second:0)) +} +#let times = times.map(x=>x.display("[hour]")) +#let codes = weather.hourly.weather_code.map(x => image(icons_map.at(str(x)), height:1em)) +#let temps = weather.hourly.temperature_2m +#let values = decimate_array(times.zip(codes,temps),n: 2) + + +#grid( + columns: (1fr,1fr,1fr), + ..values.flatten().map(x => text(size:1.3em)[#x]) +) ] diff --git a/icons/clear_day.svg b/icons/clear_day.svg new file mode 100644 index 0000000..c45f4e5 --- /dev/null +++ b/icons/clear_day.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/icons/clear_night.svg b/icons/clear_night.svg new file mode 100644 index 0000000..bd6e8d0 --- /dev/null +++ b/icons/clear_night.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/icons/cloudy_day_night.svg b/icons/cloudy_day_night.svg new file mode 100644 index 0000000..abf0b66 --- /dev/null +++ b/icons/cloudy_day_night.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/icons/drizzle_day_night.svg b/icons/drizzle_day_night.svg new file mode 100644 index 0000000..73a1fea --- /dev/null +++ b/icons/drizzle_day_night.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/fog_day_night.svg b/icons/fog_day_night.svg new file mode 100644 index 0000000..7fde5ed --- /dev/null +++ b/icons/fog_day_night.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/hail_day_night.svg b/icons/hail_day_night.svg new file mode 100644 index 0000000..ebfb1a8 --- /dev/null +++ b/icons/hail_day_night.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/haze_day.svg b/icons/haze_day.svg new file mode 100644 index 0000000..0e7a910 --- /dev/null +++ b/icons/haze_day.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/haze_night.svg b/icons/haze_night.svg new file mode 100644 index 0000000..bf16523 --- /dev/null +++ b/icons/haze_night.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/partly_cloudy_day.svg b/icons/partly_cloudy_day.svg new file mode 100644 index 0000000..6465114 --- /dev/null +++ b/icons/partly_cloudy_day.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/partly_cloudy_night.svg b/icons/partly_cloudy_night.svg new file mode 100644 index 0000000..2e99eed --- /dev/null +++ b/icons/partly_cloudy_night.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/rain_day_night.svg b/icons/rain_day_night.svg new file mode 100644 index 0000000..85e7dde --- /dev/null +++ b/icons/rain_day_night.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/sleet_day_night.svg b/icons/sleet_day_night.svg new file mode 100644 index 0000000..ec856b6 --- /dev/null +++ b/icons/sleet_day_night.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/snow_day_night.svg b/icons/snow_day_night.svg new file mode 100644 index 0000000..ac86c29 --- /dev/null +++ b/icons/snow_day_night.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/sunrise.svg b/icons/sunrise.svg new file mode 100644 index 0000000..3f6067e --- /dev/null +++ b/icons/sunrise.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/icons/sunset.svg b/icons/sunset.svg new file mode 100644 index 0000000..041c13b --- /dev/null +++ b/icons/sunset.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/icons/thunder_day_night.svg b/icons/thunder_day_night.svg new file mode 100644 index 0000000..b7f7dc5 --- /dev/null +++ b/icons/thunder_day_night.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/icons/thunderstorm_day_night.svg b/icons/thunderstorm_day_night.svg new file mode 100644 index 0000000..3d04fe4 --- /dev/null +++ b/icons/thunderstorm_day_night.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/icons/wind_day_night.svg b/icons/wind_day_night.svg new file mode 100644 index 0000000..e785556 --- /dev/null +++ b/icons/wind_day_night.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/update.sh b/update.sh index 93772e0..912e382 100755 --- a/update.sh +++ b/update.sh @@ -1,6 +1,5 @@ -echo "Get Wikipedia fact..." -wget -qO- "https://api.wikimedia.org/feed/v1/wikipedia/en/onthisday/events/$(date +%m)/$(date +%d)" | \ -jq -r '.events[0] | "\(.year): \(.text)"' > event.txt +echo "Get weather data..." +wget -O weather.json "https://api.open-meteo.com/v1/forecast?latitude=43.4516&longitude=-80.4925&hourly=temperature_2m,weather_code&start_date=2025-08-23&end_date=2025-08-23&timezone=America/Toronto" echo "Generate document..." ./typst compile --format png document.typ echo "Convert to image..."