Skip to main content

Load data from the UK Hydology API

Project description

Hydrology API

This package was build for my own use, please feel free to use it but it may have bugs

This package loads data from the UK Hydrology API. The API provides:

  • River Level, Flow and Water Quality Data
  • Rainfall Data
  • Groundwater Level Data

This package currently only provides access to the River Level, Flow, and Rainfall. Data is returned as a polars DataFrame. After the first request of a given dataset, the data is cached for up to a week.

Example

>>> from hydrology import HydrologyApi, Measure
>>> from datetime import datetime
>>> api = HydrologyApi()
>>> 
>>> # Get all stations that record the water level along the River Wear in Durham
>>> stations = api.get_stations(Measure.MeasureType.LEVEL, river="River Wear")
>>> 
>>> df = api.get_measures(
>>>     [
>>>       Measure(station_id, Measure.MeasureType.LEVEL) for station_id in stations["station_id"]
>>>     ],
>>>     stations,
>>>     start_date=datetime(2020, 1, 1),
>>> )
>>> 
>>> df.head()
shape: (5, 6)
┌────────────────┬────────────────┬────────────────┬───────────────┬───────────────┬───────────────┐
 timestamp       Durham New      Sunderland      Chester Le     Witton Park    Stanhope      
 ---             Elvet Bridge    Bridge          Street         level-i-900-m  level-i-900-m 
 datetime[μs]    level-         level-i-900-   level-i-900-  ---            ---           
                 ---             ---             ---            f32            f32           
                 f32             f32             f32                                         
╞════════════════╪════════════════╪════════════════╪═══════════════╪═══════════════╪═══════════════╡
 2020-01-01      0.372           0.417           0.465          0.465          0.344         
 00:00:00                                                                                    
 2020-01-01      0.379           0.418           0.465          0.465          0.344         
 00:15:00                                                                                    
 2020-01-01      0.378           0.417           0.464          0.465          0.344         
 00:30:00                                                                                    
 2020-01-01      0.371           0.417           0.464          0.465          0.344         
 00:45:00                                                                                    
 2020-01-01      0.367           0.417           0.467          0.465          0.344         
 01:00:00                                                                                    
└────────────────┴────────────────┴────────────────┴───────────────┴───────────────┴───────────────┘

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

hydrology-4.0.2.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

hydrology-4.0.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file hydrology-4.0.2.tar.gz.

File metadata

  • Download URL: hydrology-4.0.2.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for hydrology-4.0.2.tar.gz
Algorithm Hash digest
SHA256 f11b7da8c634e18df6460b2eec0720296112d736fa4b0757cc1365ad188a714e
MD5 ddf6511e7275a22abfc0275a55cbd97f
BLAKE2b-256 e066e41e15c5dc3c166eafa6b1c62ca28126715a00ae7ed8ec3754ea84f24b79

See more details on using hashes here.

File details

Details for the file hydrology-4.0.2-py3-none-any.whl.

File metadata

  • Download URL: hydrology-4.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for hydrology-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 435d4945dca70282214e3b043811a55075e9634f0bce2e2f4f77868031fc992d
MD5 6a45da714464a745dcc71da42bd23c92
BLAKE2b-256 5ad714431c3a89adb88c9d04339fab137562e4b41e8827730889b1ef4fbc3b28

See more details on using hashes here.

Supported by

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