Norway Fetcher

Fetcher for Norwegian river gauge data from NVE.

class rivretrieve.norway.NorwayFetcher(api_key: str | None = None)[source]

Bases: RiverDataFetcher

Fetches 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_key argument, or by setting the NVE_API_KEY environment variable in a .env file located in the rivretrieve directory. If an api_key is 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_KEY environment 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:
static get_available_variables() tuple[str, ...][source]

Returns a tuple of supported variables.

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 requested variable.

Return type:

pd.DataFrame

get_metadata() DataFrame[source]

Download and process metadata for all Norwegian hydrometric stations.