Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ API Reference
fetchers/czech
fetchers/france
fetchers/japan
fetchers/norway
fetchers/poland
fetchers/portugal
fetchers/slovenia
Expand Down
5 changes: 5 additions & 0 deletions docs/fetchers/norway.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Norway Fetcher
==============

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

import matplotlib.pyplot as plt

from rivretrieve import NorwayFetcher, constants

logging.basicConfig(level=logging.INFO)

# Replace with a valid Norwegian gauge ID, e.g., "12.210.0"
gauge_ids = [
"1.200.0",
]
variables = [
constants.DISCHARGE_INSTANT,
constants.STAGE_INSTANT,
constants.WATER_TEMPERATURE_INSTANT,
]

fetcher = NorwayFetcher()

for variable in variables:
plt.figure(figsize=(12, 6))
has_data = False
for gauge_id in gauge_ids:
print(f"Fetching {variable} for {gauge_id}...")
# Fetching last 5 years for testing
data = fetcher.get_data(gauge_id=gauge_id, variable=variable, start_date="2020-01-01", end_date="2021-12-31")
if not data.empty:
print(f"Data for {gauge_id} ({variable}):")
print(data.head())
print(f"Time series from {data.index.min()} to {data.index.max()}")
plt.plot(
data.index,
data[variable],
label=f"{gauge_id} - {variable}",
marker=".",
linestyle="-",
)
plt.xlim(data.index.min(), data.index.max())
has_data = True
else:
print(f"No data found for {gauge_id} ({variable})")

if has_data:
plt.xlabel(constants.TIME_INDEX)
plt.ylabel(variable)
plt.title(f"Norway River Data ({gauge_ids[0]})")
plt.legend()
plt.grid(True)
plt.tight_layout()
plot_path = f"norway_{variable}_plot.png"
plt.savefig(plot_path)
print(f"Plot saved to {plot_path}")
else:
print(f"No data to plot for {variable}.")

print("Test finished.")
1 change: 1 addition & 0 deletions rivretrieve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .czech import CzechFetcher
from .france import FranceFetcher
from .japan import JapanFetcher
from .norway import NorwayFetcher
from .poland import PolandFetcher
from .portugal import PortugalFetcher
from .slovenia import SloveniaFetcher
Expand Down
4,877 changes: 4,877 additions & 0 deletions rivretrieve/cached_site_data/norway_sites.csv

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions rivretrieve/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

# List of temporal resolutions.
DAILY = "daily"
HOURLY = "hourly"
INSTANTANEOUS = "instantaneous"

# List of temporal aggregrations.
Expand All @@ -36,16 +37,20 @@
DISCHARGE_DAILY_MEAN = f"{DISCHARGE}_{DAILY}_{_MEAN}"
DISCHARGE_DAILY_MAX = f"{DISCHARGE}_{DAILY}_{_MAX}"
DISCHARGE_DAILY_MIN = f"{DISCHARGE}_{DAILY}_{_MIN}"
DISCHARGE_HOURLY_MEAN = f"{DISCHARGE}_{HOURLY}_{_MEAN}"
DISCHARGE_INSTANT = f"{DISCHARGE}_{INSTANTANEOUS}"

# Stage.
STAGE_DAILY_MEAN = f"{STAGE}_{DAILY}_{_MEAN}"
STAGE_DAILY_MAX = f"{STAGE}_{DAILY}_{_MAX}"
STAGE_DAILY_MIN = f"{STAGE}_{DAILY}_{_MIN}"
STAGE_HOURLY_MEAN = f"{STAGE}_{HOURLY}_{_MEAN}"
STAGE_INSTANT = f"{STAGE}_{INSTANTANEOUS}"

# Water temperature.
WATER_TEMPERATURE_DAILY_MEAN = f"{_WATER_TEMPERATURE}_{DAILY}_{_MEAN}"
WATER_TEMPERATURE_HOURLY_MEAN = f"{_WATER_TEMPERATURE}_{HOURLY}_{_MEAN}"
WATER_TEMPERATURE_INSTANT = f"{_WATER_TEMPERATURE}_{INSTANTANEOUS}"

# Precipitation
CATCHMENT_PRECIPITATION_DAILY_SUM = f"{_CATCHMENT_PRECIPITATION}_{DAILY}_{_SUM}"
Loading