Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ API Reference
fetchers/slovenia
fetchers/southafrica
fetchers/spain
fetchers/switzerland
fetchers/uk_ea
fetchers/uk_nrfa
fetchers/usa
fetchers/usa
5 changes: 5 additions & 0 deletions docs/fetchers/switzerland.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Switzerland Fetcher
===================

.. automodule:: rivretrieve.switzerland
:members:
39 changes: 39 additions & 0 deletions examples/plot_switzerland_historical.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import logging

import matplotlib.pyplot as plt

from rivretrieve import SwitzerlandFetcher, constants

logging.basicConfig(level=logging.INFO)

gauge_id = "2016"
variable = constants.DISCHARGE_DAILY_MEAN
start_date = "2020-01-01"
end_date = "2020-01-31"

fetcher = SwitzerlandFetcher()
data = fetcher.get_data(
gauge_id=gauge_id,
variable=variable,
start_date=start_date,
end_date=end_date,
)

if data.empty:
print(f"No data found for gauge {gauge_id}, variable {variable}")
else:
print(data.head())
print(f"Fetched {len(data)} rows from {data.index.min()} to {data.index.max()}")

plt.figure(figsize=(12, 6))
plt.plot(data.index, data[variable], label=f"{gauge_id} - {variable}", linewidth=1.8)
plt.xlabel(constants.TIME_INDEX)
plt.ylabel("Discharge (m3/s)")
plt.title(f"Switzerland historical series for gauge {gauge_id}")
plt.grid(True, alpha=0.3)
plt.legend()
plt.tight_layout()

output_path = "switzerland_historical_plot.png"
plt.savefig(output_path, dpi=150)
print(f"Saved plot to {output_path}")
36 changes: 36 additions & 0 deletions examples/test_switzerland_fetcher.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import logging

import matplotlib.pyplot as plt

from rivretrieve import SwitzerlandFetcher, constants

logging.basicConfig(level=logging.INFO)

gauge_id = "2016"
variables = [
constants.DISCHARGE_DAILY_MEAN,
constants.WATER_TEMPERATURE_DAILY_MEAN,
]
start_date = "2026-02-01"
end_date = "2026-02-07"

fetcher = SwitzerlandFetcher()

for variable in variables:
data = fetcher.get_data(gauge_id=gauge_id, variable=variable, start_date=start_date, end_date=end_date)
if data.empty:
print(f"No data found for {gauge_id} ({variable})")
continue

print(data.head())
plt.figure(figsize=(12, 6))
plt.plot(data.index, data[variable], label=f"{gauge_id} - {variable}")
plt.xlabel(constants.TIME_INDEX)
plt.ylabel(variable)
plt.title(f"Switzerland River Data ({gauge_id})")
plt.legend()
plt.grid(True)
plt.tight_layout()
plot_path = f"switzerland_{variable}_plot.png"
plt.savefig(plot_path)
print(f"Plot saved to {plot_path}")
1 change: 1 addition & 0 deletions rivretrieve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .slovenia import SloveniaFetcher
from .southafrica import SouthAfricaFetcher
from .spain import SpainFetcher
from .switzerland import SwitzerlandFetcher
from .uk_ea import UKEAFetcher
from .uk_nrfa import UKNRFAFetcher
from .usa import USAFetcher
Expand Down
247 changes: 247 additions & 0 deletions rivretrieve/cached_site_data/switzerland_sites.csv

Large diffs are not rendered by default.

Loading
Loading