- New Schaad.OpenData.Weather project: MeteoSwissClient reads the
10-minute CSV of the five SwissMetNet stations in Thurgau every 10
minutes (station list once a day) and backfills the last 7 days from
the yearly file when the cache has less than 6 days
- History kept as JSON per day (60 days); a failing station does not
stop the others
- API: /api/weather/meta, /stations (current values, 1 h/24 h rain,
24 h min/max, strongest gust), /stations/{abbr}/history
- Combined map: "Wetter (live)" layer with station badges (temperature,
24 h rain or wind), wind arrows, rain marker, station panel with
hourly 7-day chart, overview and municipality context entries
- Docs: docs/datasets/wetter.md, overview in docs/datasets.md,
CLAUDE.md; Docker and appsettings wiring
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2 KiB
C#
55 lines
2 KiB
C#
using Schaad.OpenData.Weather.Analysis;
|
|
using Schaad.OpenData.Weather.Storage;
|
|
using static Schaad.OpenData.Tests.WeatherTestData;
|
|
|
|
namespace Schaad.OpenData.Tests;
|
|
|
|
public class WeatherAnalysisTestShould
|
|
{
|
|
[Fact]
|
|
public void SummarizeLastHourAndDayWhenBuildingStations()
|
|
{
|
|
var snapshot = new WeatherSnapshot(
|
|
[Station(), Station("STK", "Steckborn")],
|
|
[
|
|
Reading("GUT", Now.AddDays(-2), temperature: -5, precipitation: 9),
|
|
Reading("GUT", Now.AddHours(-20), temperature: 3, precipitation: 1.2, windGust: 61),
|
|
Reading("GUT", Now.AddMinutes(-50), temperature: 7, precipitation: 0.3),
|
|
Reading("GUT", Now.AddMinutes(-10), temperature: 8.6, precipitation: 0.1, windGust: 50.8),
|
|
Reading("GUT", Now, temperature: 8.4, precipitation: 0, windGust: null),
|
|
],
|
|
Now,
|
|
Now);
|
|
|
|
var stations = WeatherAnalysis.BuildStations(snapshot);
|
|
|
|
stations.Select(s => s.Abbr).ShouldBe(["GUT", "STK"]);
|
|
var gut = stations[0];
|
|
gut.Time.ShouldBe(Now);
|
|
gut.Temperature.ShouldBe(8.4);
|
|
gut.WindGust.ShouldBe(50.8);
|
|
gut.Precipitation1h.ShouldBe(0.4);
|
|
gut.Precipitation24h.ShouldBe(1.6);
|
|
gut.TemperatureMin24h.ShouldBe(3);
|
|
gut.TemperatureMax24h.ShouldBe(8.6);
|
|
gut.WindGustMax24h.ShouldBe(61);
|
|
gut.HistoryFrom.ShouldBe(Now.AddDays(-2));
|
|
var stk = stations[1];
|
|
stk.Time.ShouldBeNull();
|
|
stk.Precipitation24h.ShouldBeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnReadingsOfStationSinceStartWhenBuildingHistory()
|
|
{
|
|
var snapshot = new WeatherSnapshot(
|
|
[Station()],
|
|
[Reading("GUT", Now.AddDays(-8)), Reading("GUT", Now.AddDays(-1), temperature: 5), Reading("STK", Now)],
|
|
Now,
|
|
Now);
|
|
|
|
var history = WeatherAnalysis.BuildHistory(snapshot, "GUT", Now.AddDays(-7));
|
|
|
|
history.ShouldBe([new WeatherHistoryPoint(Now.AddDays(-1), 5, 0, 10, 20)]);
|
|
}
|
|
}
|