terraflow.climate_impact¶
Climate-impact pipeline orchestrator introduced in v0.5.0 (#138e). Glues
terraflow.temporal.compute_per_station_aggregations to
terraflow.climate.ClimateInterpolator and writes the sibling
climate_features.parquet artifact alongside the historical
features.parquet.
The orchestrator is auto-invoked by terraflow.pipeline.run_pipeline
when the loaded config declares both climate.temporal_aggregations
and climate.scenarios (since v0.5.0; #138f). It is also exposed as a
public function for callers that want to drive the climate-impact path
without going through the full pipeline.
Overview¶
load_timeseries_csv(path)— parse and validate the long-format station daily CSV. Required columns:station_id, lat, lon, date, temperature_c, precipitation_mm.run_climate_impact_features(cfg, run_dir, cells_df)— orchestrate the full path: compute per-station aggregations, kriging-interpolate each<rule>__<scenario>column to cell centroids, write the artifact. Returns the absolute path toclimate_features.parquet.
Artifact contract¶
| Column | Type | Meaning |
|---|---|---|
cell_id |
int | Stable within a run; matches features.parquet.cell_id |
<rule_label>__<scenario_name> |
float | One column per TemporalAggregation × Scenario pair |
Merge with features.parquet on cell_id for a complete cell-level
panel.
Quick example¶
import pandas as pd
from terraflow.pipeline import run_pipeline
df = run_pipeline("examples/demo_config_climate_impact.yml")
run_dir = df.attrs["run_dir"]
features = pd.read_parquet(f"{run_dir}/features.parquet")
climate = pd.read_parquet(f"{run_dir}/climate_features.parquet")
panel = features.merge(climate, on="cell_id")
# panel now has historical suitability + every <rule>__<scenario> column.
API Reference¶
climate_impact
¶
Climate-impact pipeline orchestration (flagship #138e).
Glues together the schema (#138a), aggregation engine (#138b), CMIP6 ingest (#138c), and hazard module (#138d) into one entry point that produces scenario-tagged cell-level columns from a long-format station time-series CSV.
The function lives in its own module so the historical single-period
run_pipeline flow stays unchanged. Downstream tools merge the new
climate_features.parquet artifact with the existing
features.parquet on cell_id.
Usage::
from terraflow.climate_impact import run_climate_impact_features
from terraflow.config import load_config
cfg = load_config("config.yml")
out_path = run_climate_impact_features(cfg, run_dir, cells_df)
load_timeseries_csv(path)
¶
Load and validate a long-format station time-series CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the CSV file. Must contain columns |
required |
Returns:
| Type | Description |
|---|---|
pd.DataFrame:
|
Validated DataFrame with |
Source code in terraflow/climate_impact.py
run_climate_impact_features(cfg, run_dir, cells_df)
¶
Compute scenario × rule cell-level derived columns and write the artifact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
PipelineConfig
|
Validated pipeline configuration with non-empty
|
required |
run_dir
|
Path
|
Run directory under |
required |
cells_df
|
DataFrame
|
Cell centroid DataFrame with at minimum |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Absolute path to the written |
Raises:
| Type | Description |
|---|---|
ValueError:
|
If the config lacks |
FileNotFoundError:
|
If the timeseries CSV does not exist. |