Norway Fetcher
Fetcher for Norwegian river gauge data from NVE.
- class rivretrieve.norway.NorwayFetcher(api_key: str | None = None)[source]
Bases:
RiverDataFetcherFetches river gauge data from the Norwegian Water Resources and Energy Directorate (NVE).
Data Source: NVE HydAPI (https://hydapi.nve.no/) Requires an API key. This can be provided directly to the constructor via the
api_keyargument, or by setting theNVE_API_KEYenvironment variable in a.envfile located in therivretrievedirectory. If anapi_keyis passed to the constructor, it takes precedence over the environment variable.- Parameters:
api_key (Optional[str]) – The API key for the NVE HydAPI. If None, the fetcher will attempt to load it from the
NVE_API_KEYenvironment variable.
- Supported Variables:
'discharge_daily_mean'(m³/s)'stage_daily_mean'(m)'water-temperature_daily_mean'(°C)'discharge_hourly_mean'(m³/s)'stage_hourly_mean'(m)'water-temperature_hourly_mean'(°C)'discharge_instantaneous'(m³/s)'stage_instantaneous'(m)'water-temperature_instantaneous'(°C)
- Terms of use:
For API, see https://hydapi.nve.no/UserDocumentation/#termsofuse
- static get_cached_metadata() DataFrame[source]
Retrieves a DataFrame of available Norwegian gauge IDs and metadata.
This method loads the metadata from a cached CSV file located in the
rivretrieve/cached_site_data/directory.- Returns:
A DataFrame indexed by gauge_id, containing site metadata.
- Return type:
pd.DataFrame
- get_data(gauge_id: str, variable: str, start_date: str | None = None, end_date: str | None = None) DataFrame[source]
Fetches and parses time series data for a specific gauge and variable.
- Parameters:
gauge_id – The site-specific identifier for the gauge.
variable – The variable to fetch. Must be one of the strings listed in the fetcher’s
get_available_variables()output.start_date – Optional start date for the data retrieval in ‘YYYY-MM-DD’ format.
end_date – Optional end date for the data retrieval in ‘YYYY-MM-DD’ format.
- Returns:
A pandas DataFrame indexed by datetime objects (
'time') with a single column named after the requestedvariable.- Return type:
pd.DataFrame