Fetching data¶
Available as climate_toolkit.fetch_climate_data.
climate_toolkit.fetch_data.fetch_data.fetch_data ¶
fetch_data(
source,
location_coord=None,
variables=None,
date_from=None,
date_to=None,
settings=None,
model=None,
scenario=None,
stage="preprocessed",
verbose=True,
cache_dir=None,
refresh_cache=False,
sites=None,
sites_csv=None,
station_id=None,
workers=1,
)
Fetch climate data through the pipeline (source -> transform -> preprocess).
Also exported as climate_toolkit.fetch_climate_data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str or ClimateDataset
|
Climate dataset name. Valid values (
Full dataset descriptions: see docs/datasets.md (or the "Datasets" page of the documentation site). Legacy aliases such as Earth Engine sources require prior |
required |
location_coord
|
tuple[float, float]
|
|
None
|
variables
|
list
|
|
None
|
date_from
|
date
|
Inclusive date range. Both default to today. The range is clipped to
the source's known coverage window (a warning is printed when
clipping occurs; a |
None
|
date_to
|
date
|
Inclusive date range. Both default to today. The range is clipped to
the source's known coverage window (a warning is printed when
clipping occurs; a |
None
|
settings
|
Settings
|
Loaded package settings. Auto-loaded via |
None
|
model
|
str
|
Required only for |
None
|
scenario
|
str
|
Required only for |
None
|
stage
|
(raw, transformed, preprocessed)
|
How far through the pipeline to run: |
'raw'
|
verbose
|
bool
|
Print progress and diagnostic messages while fetching. |
True
|
cache_dir
|
str or Path
|
Project-local cache root for downloaded data (reuse a stable path for fast repeat runs). If omitted, supported sources fall back to their default project-local cache layout. |
None
|
refresh_cache
|
bool
|
Bypass any saved cache files and force a cold fetch. |
False
|
sites
|
list
|
Many-site input; when given (or |
None
|
sites_csv
|
str or Path
|
Path to a CSV of sites with required columns |
None
|
station_id
|
str
|
Station identifier for station-backed sources ( |
None
|
workers
|
int
|
Bounded worker count for historical GEE/Xee fetch tasks. Mainly useful for multi-site or long-period historical runs. |
1
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
For single-site fetches at the default stage: one row per date with a
|
Examples:
Daily weather for Nairobi from NASA POWER (no Earth Engine needed):
>>> from datetime import date
>>> import climate_toolkit as ct
>>> from climate_toolkit.fetch_data.source_data.sources.utils.models import (
... ClimateVariable,
... )
>>> df = ct.fetch_climate_data(
... source="nasa_power",
... location_coord=(-1.286, 36.817),
... variables=[
... ClimateVariable.precipitation,
... ClimateVariable.max_temperature,
... ClimateVariable.min_temperature,
... ],
... date_from=date(2020, 1, 1),
... date_to=date(2020, 12, 31),
... )
NEX-GDDP projections (requires Earth Engine auth and GCP_PROJECT_ID):
>>> df = ct.fetch_climate_data(
... source="nex_gddp",
... location_coord=(-1.286, 36.817),
... variables=[ClimateVariable.precipitation,
... ClimateVariable.max_temperature],
... date_from=date(2050, 1, 1),
... date_to=date(2050, 12, 31),
... model="GFDL-ESM4",
... scenario="ssp245",
... )