Skip to main content

A Python package to automate downloading water resource data from SNIRH

Project description

get-snirh

A Python package to automate the retrieval of water resource data from the Portuguese Environment Agency (SNIRH).

Installation

pip install .

Usage

Basic Example

from get_snirh import Snirh, Parameters

# Initialize the client for a specific network
# Currently supported: "piezometria" (default), "meteorologica"
snirh = Snirh(network="piezometria")

# 1. Get Stations
# Fetch all stations and filter by basin
# This uses bundled metadata for fast access
stations = snirh.stations.get_stations_with_metadata(basin_filter=['RIBEIRAS DO ALGARVE'])
print(f"Found {len(stations)} stations.")

# 2. Fetch Data
# Fetch Groundwater Level Depth for the year 2023
# Passing the stations DataFrame allows the output to include station names
df = snirh.data.get_timeseries(
    station_codes=stations.head(5), # Limit to first 5 for demo
    parameter=Parameters.GWL_DEPTH,
    start_date='01/01/2023',
    end_date='31/12/2023'
)

print(df.head())

# 3. Save to CSV
df.to_csv('algarve_gwl_2023.csv', index=False)

Testing

To run the standard unit tests (mocked):

pytest

To run the live integration tests (hits SNIRH servers):

RUN_LIVE_TESTS=1 pytest tests/test_live.py

Features & Limitations

  • Supported Networks: Currently fully supports Piezometria (Groundwater) and Meteorologica (Meteorology).
  • Station Database: Station lists are currently limited to a hardcoded local database. Remote access to the live station list is currently unresolved, so the bundled metadata files must be updated manually for now.
  • Data Retrieval: Downloads time-series data for various parameters (Rainfall, Groundwater Level, Temperature, etc.).
  • Robust Parsing: Handles SNIRH's specific CSV formats and encoding (ISO-8859-1).
  • Clean API: Simple, object-oriented interface.

Examples

Check the examples/ folder for more detailed usage scripts and notebooks.

Parameters

Available parameters in get_snirh.Parameters:

  • PRECIPITATION_DAILY
  • PRECIPITATION_MONTHLY
  • GWL_DEPTH
  • AIR_TEMP_AVG_DAILY
  • And more...

License

GNU GPLv3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

get_snirh-0.1.0.tar.gz (273.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

get_snirh-0.1.0-py3-none-any.whl (272.9 kB view details)

Uploaded Python 3

File details

Details for the file get_snirh-0.1.0.tar.gz.

File metadata

  • Download URL: get_snirh-0.1.0.tar.gz
  • Upload date:
  • Size: 273.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for get_snirh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 720d579653e64dd76cd0ac956d16fd1aac9228f637fbc30d63743ead75726838
MD5 f64d28353862e98d597b4b875cc58603
BLAKE2b-256 30df52fe0cd204f0bc45814fe19ea64bf1037e8e89a20f2aa42e7d3cbf68a672

See more details on using hashes here.

File details

Details for the file get_snirh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: get_snirh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 272.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for get_snirh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d973b87e5e2564672c9b1da741f566559e76fdc3b6ff998211d0ced229271f64
MD5 23b13c2fe8a590eca535dd3d307137ed
BLAKE2b-256 824f71aa377d0e31e15702ed3c6a09538ac5996e0f466ab112639cc32334345e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page