Skip to content

Commit

Permalink
Interpolation/Summary: Add dataset to DataFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Jan 24, 2025
1 parent a069124 commit 69c7104
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Stripes: Replace matplotlib by plotly
- Explorer: Add download button for plot
- Split up plotting extras into `plotting` and `matplotlib`
- Interpolation/Summary: Add dataset to DataFrame

### Refactor
- Update docker image extras
Expand Down
5 changes: 5 additions & 0 deletions tests/core/timeseries/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def df_interpolated_empty():
return pl.DataFrame(
schema={
Columns.STATION_ID.value: pl.String,
Columns.DATASET.value: pl.String,
Columns.PARAMETER.value: pl.String,
Columns.DATE.value: pl.Datetime(time_zone="UTC"),
Columns.VALUE.value: pl.Float64,
Expand All @@ -50,6 +51,7 @@ def test_interpolation_temperature_air_mean_2m_hourly_by_coords(default_settings
[
{
"station_id": "f674568e",
"dataset": "temperature_air",
"parameter": "temperature_air_mean_2m",
"date": dt.datetime(2022, 1, 2, tzinfo=ZoneInfo("UTC")),
"value": 4.56,
Expand All @@ -74,6 +76,7 @@ def test_interpolation_temperature_air_mean_2m_daily_by_station_id(default_setti
[
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": dt.datetime(1986, 10, 31, tzinfo=ZoneInfo("UTC")),
"value": 6.37,
Expand All @@ -82,6 +85,7 @@ def test_interpolation_temperature_air_mean_2m_daily_by_station_id(default_setti
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": dt.datetime(1986, 11, 1, tzinfo=ZoneInfo("UTC")),
"value": 8.7,
Expand Down Expand Up @@ -117,6 +121,7 @@ def test_interpolation_precipitation_height_minute_10(default_settings):
[
{
"station_id": "f674568e",
"dataset": "precipitation",
"parameter": "precipitation_height",
"date": dt.datetime(2021, 10, 5, tzinfo=ZoneInfo("UTC")),
"value": 0.03,
Expand Down
4 changes: 4 additions & 0 deletions tests/core/timeseries/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_summary_temperature_air_mean_2m_daily(default_settings):
[
{
"station_id": "7ac6c582",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": selected_dates[0],
"value": 0.5,
Expand All @@ -36,6 +37,7 @@ def test_summary_temperature_air_mean_2m_daily(default_settings):
},
{
"station_id": "7ac6c582",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": selected_dates[1],
"value": -5.5,
Expand All @@ -44,6 +46,7 @@ def test_summary_temperature_air_mean_2m_daily(default_settings):
},
{
"station_id": "7ac6c582",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": selected_dates[2],
"value": -2.7,
Expand Down Expand Up @@ -73,6 +76,7 @@ def test_not_summarizable_parameter(default_settings):
expected_df = pl.DataFrame(
schema={
Columns.STATION_ID.value: pl.String,
Columns.DATASET.value: pl.String,
Columns.PARAMETER.value: pl.String,
Columns.DATE.value: pl.Datetime(time_zone="UTC"),
Columns.VALUE.value: pl.Float64,
Expand Down
10 changes: 10 additions & 0 deletions tests/ui/cli/test_cli_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def test_cli_interpolate():
assert response["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.37,
Expand All @@ -37,6 +38,7 @@ def test_cli_interpolate():
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -203,6 +205,7 @@ def test_cli_interpolate_geojson():
"values": [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.37,
Expand All @@ -212,6 +215,7 @@ def test_cli_interpolate_geojson():
{
"station_id": "6754d04d",
"date": "1986-11-01T00:00:00+00:00",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"value": 8.7,
"distance_mean": 0.0,
Expand Down Expand Up @@ -246,6 +250,7 @@ def test_cli_interpolate_interpolation_station_distance():
assert response["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": None,
Expand All @@ -254,6 +259,7 @@ def test_cli_interpolate_interpolation_station_distance():
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -286,6 +292,7 @@ def test_cli_interpolate_dont_use_nearby_station():
assert response["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.37,
Expand All @@ -294,6 +301,7 @@ def test_cli_interpolate_dont_use_nearby_station():
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -326,6 +334,7 @@ def test_cli_interpolate_custom_units():
assert response["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 43.47,
Expand All @@ -334,6 +343,7 @@ def test_cli_interpolate_custom_units():
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 47.66,
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/cli/test_cli_summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_cli_summarize():
assert response["values"] == [
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.6,
Expand All @@ -36,6 +37,7 @@ def test_cli_summarize():
},
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -96,6 +98,7 @@ def test_cli_summarize_geojson():
"values": [
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.6,
Expand All @@ -104,6 +107,7 @@ def test_cli_summarize_geojson():
},
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -139,6 +143,7 @@ def test_cli_summarize_custom_units():
assert response["values"] == [
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 43.88,
Expand All @@ -147,6 +152,7 @@ def test_cli_summarize_custom_units():
},
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 47.66,
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/test_restapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ def test_interpolate_dwd(client):
assert response.json()["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.37,
Expand All @@ -410,6 +411,7 @@ def test_interpolate_dwd(client):
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand All @@ -436,6 +438,7 @@ def test_interpolate_dwd_lower_interpolation_distance(client):
assert response.json()["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": None,
Expand All @@ -444,6 +447,7 @@ def test_interpolate_dwd_lower_interpolation_distance(client):
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand All @@ -470,6 +474,7 @@ def test_interpolate_dwd_dont_use_nearby_station(client):
assert response.json()["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.37,
Expand All @@ -478,6 +483,7 @@ def test_interpolate_dwd_dont_use_nearby_station(client):
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -507,6 +513,7 @@ def test_interpolate_dwd_custom_unit(client):
assert response.json()["values"] == [
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 43.47,
Expand All @@ -515,6 +522,7 @@ def test_interpolate_dwd_custom_unit(client):
},
{
"station_id": "6754d04d",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 47.66,
Expand All @@ -540,6 +548,7 @@ def test_summarize_dwd(client):
assert response.json()["values"] == [
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 6.6,
Expand All @@ -548,6 +557,7 @@ def test_summarize_dwd(client):
},
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 8.7,
Expand Down Expand Up @@ -577,6 +587,7 @@ def test_summarize_dwd_custom_unit(client):
assert response.json()["values"] == [
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-10-31T00:00:00+00:00",
"value": 43.88,
Expand All @@ -585,6 +596,7 @@ def test_summarize_dwd_custom_unit(client):
},
{
"station_id": "a87291a8",
"dataset": "climate_summary",
"parameter": "temperature_air_mean_2m",
"date": "1986-11-01T00:00:00+00:00",
"value": 47.66,
Expand Down
Loading

0 comments on commit 69c7104

Please sign in to comment.