aihydro-data 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aihydro_data/__init__.py +150 -0
- aihydro_data/_pipeline.py +843 -0
- aihydro_data/_version.py +2 -0
- aihydro_data/cache/__init__.py +321 -0
- aihydro_data/cache/manifest.py +162 -0
- aihydro_data/cli.py +74 -0
- aihydro_data/contracts.py +250 -0
- aihydro_data/exceptions.py +89 -0
- aihydro_data/geometry/__init__.py +161 -0
- aihydro_data/geometry/batch.py +92 -0
- aihydro_data/geometry/measures.py +58 -0
- aihydro_data/help_topics/__init__.py +20 -0
- aihydro_data/help_topics/auth.md +72 -0
- aihydro_data/help_topics/batch.md +64 -0
- aihydro_data/help_topics/caching.md +57 -0
- aihydro_data/help_topics/deprecations.md +45 -0
- aihydro_data/help_topics/errors.md +51 -0
- aihydro_data/help_topics/fallback.md +57 -0
- aihydro_data/help_topics/first_fetch.md +50 -0
- aihydro_data/help_topics/products.md +94 -0
- aihydro_data/mcp/__init__.py +815 -0
- aihydro_data/products/__init__.py +92 -0
- aihydro_data/products/dem.py +248 -0
- aihydro_data/products/et.py +305 -0
- aihydro_data/products/landcover.py +222 -0
- aihydro_data/products/optical.py +313 -0
- aihydro_data/products/precipitation.py +331 -0
- aihydro_data/products/soil.py +124 -0
- aihydro_data/products/soil_moisture.py +73 -0
- aihydro_data/products/streamflow.py +256 -0
- aihydro_data/products/temperature.py +332 -0
- aihydro_data/products/vegetation.py +155 -0
- aihydro_data/routing/__init__.py +75 -0
- aihydro_data/routing/detect.py +57 -0
- aihydro_data/routing/policy.py +149 -0
- aihydro_data/routing/regions.py +90 -0
- aihydro_data/sampling/__init__.py +29 -0
- aihydro_data/sampling/catchment.py +321 -0
- aihydro_data/sampling/chunked.py +200 -0
- aihydro_data/skills/__init__.py +15 -0
- aihydro_data/sources/__init__.py +11 -0
- aihydro_data/sources/_common.py +55 -0
- aihydro_data/sources/_gee_vendored/__init__.py +23 -0
- aihydro_data/sources/_gee_vendored/auth.py +365 -0
- aihydro_data/sources/_gee_vendored/cli.py +115 -0
- aihydro_data/sources/_gee_vendored/contracts.py +259 -0
- aihydro_data/sources/_gee_vendored/map_layers.py +158 -0
- aihydro_data/sources/_gee_vendored/presets.py +138 -0
- aihydro_data/sources/_gee_vendored/timeseries.py +143 -0
- aihydro_data/sources/_retry.py +145 -0
- aihydro_data/sources/base.py +102 -0
- aihydro_data/sources/cds_glofas.py +448 -0
- aihydro_data/sources/direct_api.py +546 -0
- aihydro_data/sources/gee/__init__.py +398 -0
- aihydro_data/sources/gee/_composite.py +327 -0
- aihydro_data/sources/gee/_download.py +315 -0
- aihydro_data/sources/geoglows_retro.py +312 -0
- aihydro_data/sources/hyriver.py +402 -0
- aihydro_data/sources/openmeteo_flood.py +201 -0
- aihydro_data/sources/stac.py +383 -0
- aihydro_data/transforms/__init__.py +53 -0
- aihydro_data/transforms/cloud_mask.py +191 -0
- aihydro_data/transforms/indices.py +524 -0
- aihydro_data/viz/__init__.py +108 -0
- aihydro_data/viz/_common.py +91 -0
- aihydro_data/viz/_compare.py +200 -0
- aihydro_data/viz/auto.py +198 -0
- aihydro_data/viz/hydrology.py +327 -0
- aihydro_data/viz/spatial.py +159 -0
- aihydro_data-0.2.0.dist-info/METADATA +566 -0
- aihydro_data-0.2.0.dist-info/RECORD +75 -0
- aihydro_data-0.2.0.dist-info/WHEEL +5 -0
- aihydro_data-0.2.0.dist-info/entry_points.txt +8 -0
- aihydro_data-0.2.0.dist-info/licenses/LICENSE +19 -0
- aihydro_data-0.2.0.dist-info/top_level.txt +1 -0
aihydro_data/__init__.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"""
|
|
2
|
+
aihydro-data — global hydrology dataverse.
|
|
3
|
+
|
|
4
|
+
A variable-centric, multi-source, region-aware fetch library that unifies
|
|
5
|
+
Google Earth Engine, STAC catalogues, HyRiver, and direct HTTP APIs behind
|
|
6
|
+
one contract.
|
|
7
|
+
|
|
8
|
+
Public API:
|
|
9
|
+
|
|
10
|
+
fetch(variable, geometry, start, end, mode="auto", product=None)
|
|
11
|
+
— fetch a single variable for a single geometry/time window
|
|
12
|
+
fetch_batch(variable, geometries, start, end, max_workers=4)
|
|
13
|
+
— parallel fetch over a dict / GeoDataFrame / list of geometries
|
|
14
|
+
list_products(variable=None, region=None)
|
|
15
|
+
— discover what data is available
|
|
16
|
+
get_product(product_id)
|
|
17
|
+
— get a ProductSpec by id
|
|
18
|
+
cache_status()
|
|
19
|
+
— disk cache summary (size, entry count)
|
|
20
|
+
cache_invalidate(cache_key)
|
|
21
|
+
— remove a specific cached result
|
|
22
|
+
|
|
23
|
+
Design notes:
|
|
24
|
+
- Each variable lives in `products/<variable>.py` and declares an ordered
|
|
25
|
+
list of ProductSpec entries (the routing fallback chain).
|
|
26
|
+
- Each backend (GEE, STAC, HyRiver, direct HTTP) lives in `sources/`.
|
|
27
|
+
- Region detection + per-region product policy live in `routing/`.
|
|
28
|
+
- Every failure returns a structured error envelope (code/recovery/
|
|
29
|
+
next_tools) — see contracts.FetchError. Agents read those fields to
|
|
30
|
+
self-recover instead of failing silently.
|
|
31
|
+
- Results are disk-cached at ~/.aihydro/cache/data/ with a provenance
|
|
32
|
+
manifest sidecar. Disable per-call with cache=False.
|
|
33
|
+
|
|
34
|
+
See pyproject.toml extras for optional backend installs:
|
|
35
|
+
pip install aihydro-data[gee] # Google Earth Engine
|
|
36
|
+
pip install aihydro-data[stac] # Planetary Computer / Element84
|
|
37
|
+
pip install aihydro-data[hyriver] # CONUS via HyRiver stack
|
|
38
|
+
pip install aihydro-data[all] # everything
|
|
39
|
+
"""
|
|
40
|
+
from __future__ import annotations
|
|
41
|
+
|
|
42
|
+
from aihydro_data._version import __version__
|
|
43
|
+
|
|
44
|
+
# Public symbols are imported lazily in fetch.py to avoid forcing optional
|
|
45
|
+
# deps at import time (e.g. someone with only [hyriver] shouldn't crash
|
|
46
|
+
# because `import aihydro_data` tried to load earthengine-api).
|
|
47
|
+
from aihydro_data.contracts import (
|
|
48
|
+
FetchError,
|
|
49
|
+
FetchRequest,
|
|
50
|
+
FetchResult,
|
|
51
|
+
ProductSpec,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
__all__ = [
|
|
55
|
+
"__version__",
|
|
56
|
+
"fetch",
|
|
57
|
+
"fetch_batch",
|
|
58
|
+
"list_products",
|
|
59
|
+
"get_product",
|
|
60
|
+
"cache_status",
|
|
61
|
+
"cache_invalidate",
|
|
62
|
+
"ProductSpec",
|
|
63
|
+
"FetchRequest",
|
|
64
|
+
"FetchResult",
|
|
65
|
+
"FetchError",
|
|
66
|
+
# Transforms (v0.2.0 — torchgeo cherry-pick)
|
|
67
|
+
"compute_index",
|
|
68
|
+
"list_indices",
|
|
69
|
+
"mask_clouds",
|
|
70
|
+
"INDEX_REGISTRY",
|
|
71
|
+
# Sampling (v0.2.0 — torchgeo cherry-pick)
|
|
72
|
+
"CatchmentGridSampler",
|
|
73
|
+
"CatchmentRandomSampler",
|
|
74
|
+
"chunked_raster_apply",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def compute_index(*args, **kwargs):
|
|
79
|
+
"""Lazy proxy to aihydro_data.transforms.indices.compute_index."""
|
|
80
|
+
from aihydro_data.transforms.indices import compute_index as _ci
|
|
81
|
+
return _ci(*args, **kwargs)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def list_indices(*args, **kwargs):
|
|
85
|
+
"""Lazy proxy to aihydro_data.transforms.indices.list_indices."""
|
|
86
|
+
from aihydro_data.transforms.indices import list_indices as _li
|
|
87
|
+
return _li(*args, **kwargs)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def mask_clouds(*args, **kwargs):
|
|
91
|
+
"""Lazy proxy to aihydro_data.transforms.cloud_mask.mask_clouds."""
|
|
92
|
+
from aihydro_data.transforms.cloud_mask import mask_clouds as _mc
|
|
93
|
+
return _mc(*args, **kwargs)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def chunked_raster_apply(*args, **kwargs):
|
|
97
|
+
"""Lazy proxy to aihydro_data.sampling.chunked.chunked_raster_apply."""
|
|
98
|
+
from aihydro_data.sampling.chunked import chunked_raster_apply as _cra
|
|
99
|
+
return _cra(*args, **kwargs)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def __getattr__(name):
|
|
103
|
+
# Lazy-import heavy classes so we don't pay xarray / rasterio import cost
|
|
104
|
+
# at `import aihydro_data` time.
|
|
105
|
+
if name == "INDEX_REGISTRY":
|
|
106
|
+
from aihydro_data.transforms.indices import INDEX_REGISTRY
|
|
107
|
+
return INDEX_REGISTRY
|
|
108
|
+
if name == "CatchmentGridSampler":
|
|
109
|
+
from aihydro_data.sampling.catchment import CatchmentGridSampler
|
|
110
|
+
return CatchmentGridSampler
|
|
111
|
+
if name == "CatchmentRandomSampler":
|
|
112
|
+
from aihydro_data.sampling.catchment import CatchmentRandomSampler
|
|
113
|
+
return CatchmentRandomSampler
|
|
114
|
+
raise AttributeError(f"module 'aihydro_data' has no attribute {name!r}")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def fetch(*args, **kwargs):
|
|
118
|
+
"""Lazy proxy to aihydro_data._pipeline.fetch — see that function's docstring."""
|
|
119
|
+
from aihydro_data._pipeline import fetch as _fetch
|
|
120
|
+
return _fetch(*args, **kwargs)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def fetch_batch(*args, **kwargs):
|
|
124
|
+
"""Lazy proxy to aihydro_data._pipeline.fetch_batch — parallel multi-geometry fetch."""
|
|
125
|
+
from aihydro_data._pipeline import fetch_batch as _fb
|
|
126
|
+
return _fb(*args, **kwargs)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def list_products(*args, **kwargs):
|
|
130
|
+
"""Lazy proxy to aihydro_data.products.list_products."""
|
|
131
|
+
from aihydro_data.products import list_products as _list
|
|
132
|
+
return _list(*args, **kwargs)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def get_product(*args, **kwargs):
|
|
136
|
+
"""Lazy proxy to aihydro_data.products.get_product."""
|
|
137
|
+
from aihydro_data.products import get_product as _get
|
|
138
|
+
return _get(*args, **kwargs)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def cache_status() -> dict:
|
|
142
|
+
"""Return disk cache summary — size, entry count, per-entry details."""
|
|
143
|
+
from aihydro_data.cache import cache_status as _cs
|
|
144
|
+
return _cs()
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def cache_invalidate(ck: str) -> bool:
|
|
148
|
+
"""Remove a cached result by cache key. Returns True if anything was deleted."""
|
|
149
|
+
from aihydro_data.cache import cache_invalidate as _ci
|
|
150
|
+
return _ci(ck)
|