climaclass 0.1.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.
climaclass/__init__.py ADDED
@@ -0,0 +1,66 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """climaclass - classical climate classification from monthly climatologies.
5
+
6
+ Three classical schemes, one tiny input record, zero heavy dependencies:
7
+
8
+ >>> from climaclass import MonthlyClimate, classify
9
+ >>> rome = MonthlyClimate(
10
+ ... temp=[8, 9, 11, 14, 18, 22, 25, 25, 21, 17, 12, 9],
11
+ ... precip=[80, 75, 70, 65, 50, 35, 20, 30, 70, 110, 110, 95],
12
+ ... )
13
+ >>> classify(rome)["koppen"].code
14
+ 'Csa'
15
+
16
+ Each classifier consumes a :class:`MonthlyClimate` and returns a
17
+ :class:`ClassificationResult`. The library is pure Python; the optional
18
+ SYMFLUENCE integration lives in :mod:`climaclass.integrations.symfluence` and is
19
+ only imported when you ask for it.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ from typing import Dict
25
+
26
+ from . import holdridge, koppen, thornthwaite
27
+ from ._types import ClassificationResult, MonthlyClimate
28
+
29
+ __version__ = "0.1.0"
30
+
31
+ __all__ = [
32
+ "MonthlyClimate",
33
+ "ClassificationResult",
34
+ "classify",
35
+ "koppen",
36
+ "holdridge",
37
+ "thornthwaite",
38
+ ]
39
+
40
+ _SCHEMES = {
41
+ "koppen": koppen.classify,
42
+ "holdridge": holdridge.classify,
43
+ "thornthwaite": thornthwaite.classify,
44
+ }
45
+
46
+
47
+ def classify(climate: MonthlyClimate, schemes=None) -> Dict[str, ClassificationResult]:
48
+ """Run one or more classification schemes on a climatology.
49
+
50
+ Args:
51
+ climate: The 12-month climatology to classify.
52
+ schemes: Iterable of scheme names to run. Defaults to all three
53
+ (``"koppen"``, ``"holdridge"``, ``"thornthwaite"``).
54
+
55
+ Returns:
56
+ Mapping of scheme name -> :class:`ClassificationResult`.
57
+ """
58
+ if schemes is None:
59
+ schemes = _SCHEMES.keys()
60
+ out: Dict[str, ClassificationResult] = {}
61
+ for name in schemes:
62
+ try:
63
+ out[name] = _SCHEMES[name](climate)
64
+ except KeyError as exc:
65
+ raise ValueError(f"Unknown scheme: {name!r}. Choose from {sorted(_SCHEMES)}") from exc
66
+ return out
climaclass/_types.py ADDED
@@ -0,0 +1,100 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """Shared input/output data structures for :mod:`climaclass`.
5
+
6
+ The whole library is built around one small, explicit input record -
7
+ :class:`MonthlyClimate` - a 12-month climatology of temperature and
8
+ precipitation. Every classifier consumes that record and returns a typed
9
+ result, so the schemes stay interchangeable and trivially testable.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from dataclasses import dataclass
15
+ from typing import Optional, Sequence
16
+
17
+ # Calendar constants. Index 0 == January, 11 == December throughout the package.
18
+ DAYS_IN_MONTH = (31, 28.25, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
19
+ # Day-of-year for the middle of each month (used for Thornthwaite day-length).
20
+ MID_MONTH_DOY = (16, 46, 75, 106, 136, 167, 197, 228, 259, 289, 320, 350)
21
+
22
+
23
+ def _validate_12(name: str, values: Sequence[float]) -> tuple:
24
+ vals = tuple(float(v) for v in values)
25
+ if len(vals) != 12:
26
+ raise ValueError(f"{name} must have 12 monthly values (Jan..Dec), got {len(vals)}")
27
+ return vals
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class MonthlyClimate:
32
+ """A 12-month climatology for a single location or catchment.
33
+
34
+ Args:
35
+ temp: Monthly mean air temperature [degC], January..December.
36
+ precip: Monthly total precipitation [mm], January..December.
37
+ tmin: Optional monthly mean daily-minimum temperature [degC]. When
38
+ absent it is approximated from ``temp`` where a scheme needs it.
39
+ tmax: Optional monthly mean daily-maximum temperature [degC].
40
+ latitude: Optional latitude [degrees, north positive]. Only used to
41
+ refine the Thornthwaite day-length correction and to disambiguate
42
+ the hemisphere; classification works without it.
43
+ """
44
+
45
+ temp: Sequence[float]
46
+ precip: Sequence[float]
47
+ tmin: Optional[Sequence[float]] = None
48
+ tmax: Optional[Sequence[float]] = None
49
+ latitude: Optional[float] = None
50
+
51
+ def __post_init__(self) -> None:
52
+ object.__setattr__(self, "temp", _validate_12("temp", self.temp))
53
+ object.__setattr__(self, "precip", _validate_12("precip", self.precip))
54
+ if self.tmin is not None:
55
+ object.__setattr__(self, "tmin", _validate_12("tmin", self.tmin))
56
+ if self.tmax is not None:
57
+ object.__setattr__(self, "tmax", _validate_12("tmax", self.tmax))
58
+
59
+ # --- convenient derived quantities (shared by several classifiers) ---
60
+
61
+ @property
62
+ def mat(self) -> float:
63
+ """Mean annual temperature [degC]."""
64
+ return sum(self.temp) / 12.0
65
+
66
+ @property
67
+ def map(self) -> float:
68
+ """Mean annual precipitation [mm]."""
69
+ return sum(self.precip)
70
+
71
+ @property
72
+ def hemisphere(self) -> str:
73
+ """``"north"`` or ``"south"``, inferred from the seasonal temperature cycle.
74
+
75
+ If ``latitude`` is given it wins; otherwise the warmer half-year decides.
76
+ """
77
+ if self.latitude is not None:
78
+ return "north" if self.latitude >= 0 else "south"
79
+ apr_sep = sum(self.temp[3:9]) / 6.0
80
+ oct_mar = sum(self.temp[9:12] + self.temp[0:3]) / 6.0
81
+ return "north" if apr_sep >= oct_mar else "south"
82
+
83
+
84
+ @dataclass(frozen=True)
85
+ class ClassificationResult:
86
+ """A single scheme's verdict.
87
+
88
+ Args:
89
+ scheme: ``"koppen"`` | ``"holdridge"`` | ``"thornthwaite"``.
90
+ code: Compact symbol (e.g. ``"Csb"``, ``"B"``).
91
+ zone: Integer index into the scheme's canonical legend (or ``None``).
92
+ name: Human-readable label (e.g. ``"Tropical rainforest"``).
93
+ details: Scheme-specific intermediate values, for transparency/QA.
94
+ """
95
+
96
+ scheme: str
97
+ code: str
98
+ zone: Optional[int]
99
+ name: str
100
+ details: dict
@@ -0,0 +1,140 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """Holdridge life-zone classification from a 12-month climatology.
5
+
6
+ Follows Holdridge (1967), *Life Zone Ecology*. A life zone is the intersection
7
+ of three logarithmic axes:
8
+
9
+ * **Mean annual biotemperature** (degC) - mean of monthly temperatures each
10
+ clamped to [0, 30]. Sets the latitudinal/altitudinal belt.
11
+ * **Mean annual precipitation** (mm).
12
+ * **Potential evapotranspiration ratio**, ``PET_ratio = 58.93 * biotemp / precip``.
13
+ Sets the humidity province.
14
+
15
+ This mirrors the variables computed in the original Earth-Engine notebook
16
+ (``biotemperature``, ``pAnn``, ``PETR``) but evaluates them per-climatology in
17
+ pure Python rather than over a global image.
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ from ._types import ClassificationResult, MonthlyClimate
23
+
24
+ # Biotemperature breakpoints (degC) -> belt name, ordered cold..hot.
25
+ # Each (upper_bound, belt) means: belt applies while biotemp < upper_bound.
26
+ _BELTS = (
27
+ (1.5, "Polar"),
28
+ (3.0, "Subpolar"),
29
+ (6.0, "Boreal"),
30
+ (12.0, "Cool temperate"),
31
+ (18.0, "Warm temperate"),
32
+ (24.0, "Subtropical"),
33
+ (float("inf"), "Tropical"),
34
+ )
35
+
36
+ # Humidity provinces by PET ratio, ordered wet..dry. Index used to look up the
37
+ # zone name within a belt. (upper_bound, province) means province applies while
38
+ # PET_ratio < upper_bound.
39
+ _PROVINCES = (
40
+ (0.25, "superhumid"),
41
+ (0.50, "perhumid"),
42
+ (1.00, "humid"),
43
+ (2.00, "subhumid"),
44
+ (4.00, "semiarid"),
45
+ (8.00, "arid"),
46
+ (16.0, "perarid"),
47
+ (float("inf"), "superarid"),
48
+ )
49
+
50
+ # Per-belt life-zone names, indexed by humidity province (0 = wettest).
51
+ # Encodes the Holdridge hexagon; truncated rows repeat the driest realised zone.
52
+ _ZONES = {
53
+ "Polar": [
54
+ "Polar desert", "Polar desert", "Polar desert", "Polar desert",
55
+ "Polar desert", "Polar desert", "Polar desert", "Polar desert",
56
+ ],
57
+ "Subpolar": [
58
+ "Subpolar rain tundra", "Subpolar wet tundra", "Subpolar moist tundra",
59
+ "Subpolar dry tundra", "Subpolar dry tundra", "Subpolar desert",
60
+ "Subpolar desert", "Subpolar desert",
61
+ ],
62
+ "Boreal": [
63
+ "Boreal rain forest", "Boreal wet forest", "Boreal moist forest",
64
+ "Boreal dry scrub", "Boreal desert", "Boreal desert",
65
+ "Boreal desert", "Boreal desert",
66
+ ],
67
+ "Cool temperate": [
68
+ "Cool temperate rain forest", "Cool temperate wet forest",
69
+ "Cool temperate moist forest", "Cool temperate steppe",
70
+ "Cool temperate desert scrub", "Cool temperate desert",
71
+ "Cool temperate desert", "Cool temperate desert",
72
+ ],
73
+ "Warm temperate": [
74
+ "Warm temperate rain forest", "Warm temperate wet forest",
75
+ "Warm temperate moist forest", "Warm temperate dry forest",
76
+ "Warm temperate thorn steppe", "Warm temperate desert scrub",
77
+ "Warm temperate desert", "Warm temperate desert",
78
+ ],
79
+ "Subtropical": [
80
+ "Subtropical rain forest", "Subtropical wet forest",
81
+ "Subtropical moist forest", "Subtropical dry forest",
82
+ "Subtropical thorn woodland", "Subtropical desert scrub",
83
+ "Subtropical desert", "Subtropical desert",
84
+ ],
85
+ "Tropical": [
86
+ "Tropical rain forest", "Tropical wet forest", "Tropical moist forest",
87
+ "Tropical dry forest", "Tropical very dry forest",
88
+ "Tropical thorn woodland", "Tropical desert scrub", "Tropical desert",
89
+ ],
90
+ }
91
+
92
+ # Stable integer codes: belt_index * 10 + province_index, plus 1 (1-based).
93
+ _BELT_ORDER = [b for _, b in _BELTS]
94
+
95
+
96
+ def biotemperature(climate: MonthlyClimate) -> float:
97
+ """Mean annual biotemperature [degC]: mean of monthly temps clamped to [0, 30]."""
98
+ clamped = [min(max(x, 0.0), 30.0) for x in climate.temp]
99
+ return sum(clamped) / 12.0
100
+
101
+
102
+ def _belt(biotemp: float) -> tuple:
103
+ for idx, (upper, name) in enumerate(_BELTS):
104
+ if biotemp < upper:
105
+ return idx, name
106
+ return len(_BELTS) - 1, _BELTS[-1][1]
107
+
108
+
109
+ def _province(pet_ratio: float) -> tuple:
110
+ for idx, (upper, name) in enumerate(_PROVINCES):
111
+ if pet_ratio < upper:
112
+ return idx, name
113
+ return len(_PROVINCES) - 1, _PROVINCES[-1][1]
114
+
115
+
116
+ def classify(climate: MonthlyClimate) -> ClassificationResult:
117
+ """Classify a 12-month climatology into a Holdridge life zone."""
118
+ biotemp = biotemperature(climate)
119
+ precip = climate.map
120
+ # PET ratio is undefined for zero precipitation; treat as maximally arid.
121
+ pet_ratio = (58.93 * biotemp / precip) if precip > 0 else float("inf")
122
+
123
+ belt_idx, belt_name = _belt(biotemp)
124
+ prov_idx, prov_name = _province(pet_ratio)
125
+ name = _ZONES[belt_name][prov_idx]
126
+ code = belt_idx * 10 + prov_idx + 1
127
+
128
+ return ClassificationResult(
129
+ scheme="holdridge",
130
+ code=name,
131
+ zone=code,
132
+ name=name,
133
+ details={
134
+ "biotemperature": round(biotemp, 2),
135
+ "annual_precip": round(precip, 1),
136
+ "PET_ratio": round(pet_ratio, 3) if pet_ratio != float("inf") else None,
137
+ "belt": belt_name,
138
+ "humidity_province": prov_name,
139
+ },
140
+ )
@@ -0,0 +1,9 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """Optional integrations for :mod:`climaclass`.
5
+
6
+ Nothing here is imported by the core package. Each integration pulls in its
7
+ host framework lazily, so installing ``climaclass`` never drags in SYMFLUENCE
8
+ (and vice versa).
9
+ """
@@ -0,0 +1,155 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """SYMFLUENCE attribute-processor adapter for :mod:`climaclass`.
5
+
6
+ This module lets SYMFLUENCE emit Koppen-Geiger, Holdridge and Thornthwaite
7
+ classes as catchment attributes (``climate.koppen_*`` etc.), computed from the
8
+ same WorldClim monthly rasters SYMFLUENCE already acquires for its climate
9
+ attributes - no Earth Engine, no new data dependency.
10
+
11
+ It is intentionally decoupled:
12
+
13
+ * The pure mapping helper :func:`record_to_attributes` has no SYMFLUENCE
14
+ dependency and can be unit-tested standalone.
15
+ * :class:`ClimateClassificationProcessor` only resolves the SYMFLUENCE base
16
+ class at import time; if SYMFLUENCE is absent the class still imports (its
17
+ base degrades to ``object``) so ``import climaclass`` never fails.
18
+
19
+ Install for use inside SYMFLUENCE with::
20
+
21
+ pip install "climaclass[symfluence]"
22
+
23
+ and register it as an attribute processor (see the project README).
24
+ """
25
+
26
+ from __future__ import annotations
27
+
28
+ from typing import Any, Dict, List, Optional, Sequence
29
+
30
+ from .. import classify
31
+ from .._types import MonthlyClimate
32
+
33
+ # Resolve the SYMFLUENCE base class lazily/defensively so importing this module
34
+ # never hard-fails when SYMFLUENCE is not installed.
35
+ try: # pragma: no cover - exercised only with SYMFLUENCE present
36
+ from symfluence.data.preprocessing.attribute_processors.base import (
37
+ BaseAttributeProcessor as _Base,
38
+ )
39
+
40
+ HAVE_SYMFLUENCE = True
41
+ except Exception: # noqa: BLE001 - any import failure means "not available"
42
+ _Base = object
43
+ HAVE_SYMFLUENCE = False
44
+
45
+
46
+ def record_to_attributes(
47
+ temp: Sequence[float],
48
+ precip: Sequence[float],
49
+ *,
50
+ latitude: Optional[float] = None,
51
+ prefix: str = "",
52
+ ) -> Dict[str, Any]:
53
+ """Classify one HRU's climatology into flat ``climate.*`` attribute keys.
54
+
55
+ Args:
56
+ temp: 12 monthly mean temperatures [degC], Jan..Dec.
57
+ precip: 12 monthly total precipitation [mm], Jan..Dec.
58
+ latitude: Optional latitude to refine Thornthwaite PET.
59
+ prefix: Optional key prefix for distributed domains. SYMFLUENCE expects
60
+ ``"HRU_{id}_"`` so keys read ``HRU_3_climate.koppen_code``.
61
+
62
+ Returns:
63
+ Dict of attribute name -> value, ready to merge into a results dict.
64
+ """
65
+ climate = MonthlyClimate(temp=temp, precip=precip, latitude=latitude)
66
+ results = classify(climate)
67
+ k, h, t = results["koppen"], results["holdridge"], results["thornthwaite"]
68
+ return {
69
+ f"{prefix}climate.koppen_code": k.code,
70
+ f"{prefix}climate.koppen_zone": k.zone,
71
+ f"{prefix}climate.koppen_name": k.name,
72
+ f"{prefix}climate.holdridge_zone": h.code,
73
+ f"{prefix}climate.holdridge_code": h.zone,
74
+ f"{prefix}climate.holdridge_belt": h.details.get("belt"),
75
+ f"{prefix}climate.thornthwaite_code": t.code,
76
+ f"{prefix}climate.thornthwaite_moisture_index": t.details.get("moisture_index"),
77
+ f"{prefix}climate.thornthwaite_moisture_province": t.details.get("moisture_province"),
78
+ }
79
+
80
+
81
+ class ClimateClassificationProcessor(_Base):
82
+ """SYMFLUENCE attribute processor that adds climate-classification attributes.
83
+
84
+ Reads 12 monthly WorldClim mean-temperature (``tavg``) and precipitation
85
+ (``prec``) rasters, reduces them over the catchment (lumped) or each HRU
86
+ (distributed) with zonal statistics, and classifies the resulting
87
+ climatology with all three schemes.
88
+ """
89
+
90
+ #: SYMFLUENCE auto-discovery hooks (kept here so the framework side stays thin).
91
+ name = "climate_classification"
92
+ provides = ("climate.koppen_code", "climate.holdridge_zone", "climate.thornthwaite_code")
93
+
94
+ def process(self) -> Dict[str, Any]:
95
+ if not HAVE_SYMFLUENCE: # pragma: no cover - guard for standalone import
96
+ raise RuntimeError(
97
+ "ClimateClassificationProcessor requires SYMFLUENCE. "
98
+ "Install with: pip install 'climaclass[symfluence]'"
99
+ )
100
+
101
+ results: Dict[str, Any] = {}
102
+ worldclim_path = self._get_data_path( # type: ignore[attr-defined]
103
+ "ATTRIBUTES_WORLDCLIM_PATH", "data/attributes/climate/worldclim"
104
+ )
105
+ if not worldclim_path.exists():
106
+ self.logger.warning(f"WorldClim path not found, skipping classification: {worldclim_path}")
107
+ return results
108
+
109
+ temp = self._monthly_zonal(worldclim_path, "tavg")
110
+ precip = self._monthly_zonal(worldclim_path, "prec")
111
+ if temp is None or precip is None:
112
+ self.logger.warning("Missing tavg/prec WorldClim rasters; skipping classification")
113
+ return results
114
+
115
+ # temp/precip are lists of 12-length climatologies, one per zone.
116
+ for zone_idx, (t12, p12) in enumerate(zip(temp, precip)):
117
+ if any(v is None for v in t12) or any(v is None for v in p12):
118
+ continue
119
+ prefix = "" if len(temp) == 1 else self._hru_prefix(zone_idx)
120
+ results.update(record_to_attributes(t12, p12, prefix=prefix))
121
+ return results
122
+
123
+ # --- helpers -----------------------------------------------------------
124
+
125
+ def _monthly_zonal(self, worldclim_path, var: str) -> Optional[List[List[Optional[float]]]]:
126
+ """Return per-zone 12-month means for ``var`` via zonal statistics."""
127
+ import geopandas as gpd # lazy, per SYMFLUENCE convention
128
+ from rasterstats import zonal_stats
129
+
130
+ files = sorted(worldclim_path.glob(f"wc2.1_30s_{var}_*.tif"))
131
+ if len(files) < 12:
132
+ return None
133
+
134
+ catchment = gpd.read_file(self.catchment_path) # type: ignore[attr-defined]
135
+ n_zones = len(catchment)
136
+ monthly: List[List[Optional[float]]] = [[None] * 12 for _ in range(n_zones)]
137
+ for month_idx, raster in enumerate(files[:12]):
138
+ stats = zonal_stats(str(self.catchment_path), str(raster), stats=["mean"]) # type: ignore[attr-defined]
139
+ for zone_idx, s in enumerate(stats):
140
+ monthly[zone_idx][month_idx] = s.get("mean")
141
+ return monthly
142
+
143
+ def _hru_prefix(self, zone_idx: int) -> str:
144
+ """Build the per-HRU attribute key prefix using the configured HRU id field."""
145
+ import geopandas as gpd
146
+
147
+ hru_field = self._get_config_value( # type: ignore[attr-defined]
148
+ lambda: self.config.paths.catchment_hruid, default="HRU_ID", dict_key="CATCHMENT_SHP_HRUID"
149
+ )
150
+ catchment = gpd.read_file(self.catchment_path) # type: ignore[attr-defined]
151
+ try:
152
+ hru_id = catchment.iloc[zone_idx][hru_field]
153
+ except Exception: # noqa: BLE001
154
+ hru_id = zone_idx
155
+ return f"HRU_{hru_id}_"
climaclass/koppen.py ADDED
@@ -0,0 +1,162 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """Koppen-Geiger climate classification from a 12-month climatology.
5
+
6
+ Implements the widely used formulation of Peel, Finlayson & McMahon (2007,
7
+ *HESS*) and the numeric legend (1..30) of Beck et al. (2018, *Sci. Data*),
8
+ which is the same legend rendered by the original Earth-Engine notebook this
9
+ package grew out of. Pure-Python: no NumPy, no Earth Engine.
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ from typing import Sequence
15
+
16
+ from ._types import ClassificationResult, MonthlyClimate
17
+
18
+ # Beck et al. (2018) numeric legend: code string -> integer zone.
19
+ KOPPEN_LEGEND = {
20
+ "Af": 1, "Am": 2, "Aw": 3,
21
+ "BWh": 4, "BWk": 5, "BSh": 6, "BSk": 7,
22
+ "Csa": 8, "Csb": 9, "Csc": 10,
23
+ "Cwa": 11, "Cwb": 12, "Cwc": 13,
24
+ "Cfa": 14, "Cfb": 15, "Cfc": 16,
25
+ "Dsa": 17, "Dsb": 18, "Dsc": 19, "Dsd": 20,
26
+ "Dwa": 21, "Dwb": 22, "Dwc": 23, "Dwd": 24,
27
+ "Dfa": 25, "Dfb": 26, "Dfc": 27, "Dfd": 28,
28
+ "ET": 29, "EF": 30,
29
+ }
30
+
31
+ KOPPEN_NAMES = {
32
+ "Af": "Tropical rainforest", "Am": "Tropical monsoon", "Aw": "Tropical savannah",
33
+ "BWh": "Hot desert", "BWk": "Cold desert", "BSh": "Hot steppe", "BSk": "Cold steppe",
34
+ "Csa": "Hot-summer Mediterranean", "Csb": "Warm-summer Mediterranean",
35
+ "Csc": "Cold-summer Mediterranean",
36
+ "Cwa": "Humid subtropical (dry winter)", "Cwb": "Subtropical highland (dry winter)",
37
+ "Cwc": "Cold subtropical highland (dry winter)",
38
+ "Cfa": "Humid subtropical", "Cfb": "Temperate oceanic", "Cfc": "Subpolar oceanic",
39
+ "Dsa": "Hot-summer Mediterranean continental", "Dsb": "Warm-summer Mediterranean continental",
40
+ "Dsc": "Mediterranean subarctic", "Dsd": "Mediterranean subarctic (severe winter)",
41
+ "Dwa": "Hot-summer humid continental (dry winter)",
42
+ "Dwb": "Warm-summer humid continental (dry winter)",
43
+ "Dwc": "Subarctic (dry winter)", "Dwd": "Severe-winter subarctic (dry winter)",
44
+ "Dfa": "Hot-summer humid continental", "Dfb": "Warm-summer humid continental",
45
+ "Dfc": "Subarctic", "Dfd": "Severe-winter subarctic",
46
+ "ET": "Tundra", "EF": "Ice cap",
47
+ }
48
+
49
+ # Northern-hemisphere summer = Apr..Sep (indices 3..8); winter = Oct..Mar.
50
+ _NH_SUMMER = (3, 4, 5, 6, 7, 8)
51
+ _NH_WINTER = (9, 10, 11, 0, 1, 2)
52
+
53
+
54
+ def _seasonal_indices(hemisphere: str) -> tuple:
55
+ """Return (summer_months, winter_months) as 0-based index tuples."""
56
+ if hemisphere == "north":
57
+ return _NH_SUMMER, _NH_WINTER
58
+ return _NH_WINTER, _NH_SUMMER
59
+
60
+
61
+ def classify(climate: MonthlyClimate) -> ClassificationResult:
62
+ """Classify a 12-month climatology into a Koppen-Geiger zone."""
63
+ t = climate.temp
64
+ p = climate.precip
65
+ mat = climate.mat
66
+ map_ = climate.map
67
+
68
+ t_cold = min(t)
69
+ t_hot = max(t)
70
+ t_mon10 = sum(1 for x in t if x >= 10.0)
71
+ p_dry = min(p)
72
+
73
+ summer, winter = _seasonal_indices(climate.hemisphere)
74
+ p_summer = sum(p[i] for i in summer)
75
+ p_winter = sum(p[i] for i in winter)
76
+ p_s_dry = min(p[i] for i in summer)
77
+ p_w_dry = min(p[i] for i in winter)
78
+ p_s_wet = max(p[i] for i in summer)
79
+ p_w_wet = max(p[i] for i in winter)
80
+
81
+ # Aridity threshold P_th (Peel et al. 2007).
82
+ if p_winter >= 0.7 * map_:
83
+ p_th = 2.0 * mat
84
+ elif p_summer >= 0.7 * map_:
85
+ p_th = 2.0 * mat + 28.0
86
+ else:
87
+ p_th = 2.0 * mat + 14.0
88
+
89
+ details = {
90
+ "MAT": round(mat, 2), "MAP": round(map_, 1),
91
+ "Tcold": round(t_cold, 2), "Thot": round(t_hot, 2),
92
+ "Tmon10": t_mon10, "Pdry": round(p_dry, 1),
93
+ "Pthreshold": round(p_th, 2), "hemisphere": climate.hemisphere,
94
+ }
95
+
96
+ # --- Main class. Aridity (B) is tested first and overrides A/C/D; E is the
97
+ # cold residual. This ordering reproduces cold deserts (BWk) as mapped
98
+ # by Beck et al. (2018). ---
99
+ if map_ < 10.0 * p_th:
100
+ code = _arid(map_, p_th, mat)
101
+ elif t_cold >= 18.0:
102
+ code = _tropical(p_dry, map_)
103
+ elif t_hot > 10.0 and t_cold > 0.0:
104
+ code = "C" + _cd_second(p_s_dry, p_w_wet, p_w_dry, p_s_wet) + _c_third(t_hot, t_mon10)
105
+ elif t_hot > 10.0 and t_cold <= 0.0:
106
+ code = "D" + _cd_second(p_s_dry, p_w_wet, p_w_dry, p_s_wet) + _d_third(t_hot, t_mon10, t_cold)
107
+ else:
108
+ code = "ET" if t_hot >= 0.0 else "EF"
109
+
110
+ return ClassificationResult(
111
+ scheme="koppen",
112
+ code=code,
113
+ zone=KOPPEN_LEGEND.get(code),
114
+ name=KOPPEN_NAMES.get(code, code),
115
+ details=details,
116
+ )
117
+
118
+
119
+ def _arid(map_: float, p_th: float, mat: float) -> str:
120
+ second = "W" if map_ < 5.0 * p_th else "S"
121
+ third = "h" if mat >= 18.0 else "k"
122
+ return "B" + second + third
123
+
124
+
125
+ def _tropical(p_dry: float, map_: float) -> str:
126
+ if p_dry >= 60.0:
127
+ return "Af"
128
+ if p_dry >= 100.0 - map_ / 25.0:
129
+ return "Am"
130
+ return "Aw"
131
+
132
+
133
+ def _cd_second(p_s_dry: float, p_w_wet: float, p_w_dry: float, p_s_wet: float) -> str:
134
+ """Second letter for C/D climates: s (dry summer), w (dry winter) or f."""
135
+ dry_summer = p_s_dry < 40.0 and p_s_dry < p_w_wet / 3.0
136
+ dry_winter = p_w_dry < p_s_wet / 10.0
137
+ if dry_summer and not dry_winter:
138
+ return "s"
139
+ if dry_winter and not dry_summer:
140
+ return "w"
141
+ # If both criteria trip, assign by the wetter season (Peel et al. 2007).
142
+ if dry_summer and dry_winter:
143
+ return "s" if p_w_wet >= p_s_wet else "w"
144
+ return "f"
145
+
146
+
147
+ def _c_third(t_hot: float, t_mon10: int) -> str:
148
+ if t_hot >= 22.0:
149
+ return "a"
150
+ if t_mon10 >= 4:
151
+ return "b"
152
+ return "c"
153
+
154
+
155
+ def _d_third(t_hot: float, t_mon10: int, t_cold: float) -> str:
156
+ if t_hot >= 22.0:
157
+ return "a"
158
+ if t_mon10 >= 4:
159
+ return "b"
160
+ if t_cold <= -38.0:
161
+ return "d"
162
+ return "c"
@@ -0,0 +1,125 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # Copyright (c) 2024-2026 Darri Eythorsson
3
+
4
+ """Thornthwaite climate classification from a 12-month climatology.
5
+
6
+ Implements the Thornthwaite (1948) potential-evapotranspiration model and the
7
+ moisture index. Potential evapotranspiration (PET) is computed from monthly
8
+ mean temperature via the classic heat-index formula, with the high-temperature
9
+ correction for T >= 26.5 degC and an optional latitude-based day-length
10
+ adjustment. Classification uses:
11
+
12
+ * **Moisture index** ``Im = 100 * (P - PET) / PET`` (the 1955 single-index form)
13
+ -> humidity province (A perhumid .. E arid).
14
+ * **Thermal efficiency** = annual PET [mm] -> thermal province (A' .. E').
15
+
16
+ Pure Python; ``latitude`` only refines the day-length correction.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import math
22
+
23
+ from ._types import DAYS_IN_MONTH, MID_MONTH_DOY, ClassificationResult, MonthlyClimate
24
+
25
+ # Moisture index thresholds (Im), wet..dry: (lower_bound, code, name).
26
+ _MOISTURE = (
27
+ (100.0, "A", "Perhumid"),
28
+ (80.0, "B4", "Humid (B4)"),
29
+ (60.0, "B3", "Humid (B3)"),
30
+ (40.0, "B2", "Humid (B2)"),
31
+ (20.0, "B1", "Humid (B1)"),
32
+ (0.0, "C2", "Moist subhumid"),
33
+ (-33.3, "C1", "Dry subhumid"),
34
+ (-66.7, "D", "Semiarid"),
35
+ (float("-inf"), "E", "Arid"),
36
+ )
37
+
38
+ # Thermal-efficiency thresholds (annual PET, mm), warm..cold.
39
+ _THERMAL = (
40
+ (1140.0, "A'", "Megathermal"),
41
+ (997.0, "B'4", "Mesothermal (B'4)"),
42
+ (855.0, "B'3", "Mesothermal (B'3)"),
43
+ (712.0, "B'2", "Mesothermal (B'2)"),
44
+ (570.0, "B'1", "Mesothermal (B'1)"),
45
+ (427.0, "C'2", "Microthermal (C'2)"),
46
+ (285.0, "C'1", "Microthermal (C'1)"),
47
+ (142.0, "D'", "Tundra"),
48
+ (float("-inf"), "E'", "Frost"),
49
+ )
50
+
51
+
52
+ def heat_index(temp: tuple) -> float:
53
+ """Annual heat index I = sum((T/5)^1.514) over months with T > 0."""
54
+ return sum((x / 5.0) ** 1.514 for x in temp if x > 0.0)
55
+
56
+
57
+ def _alpha(i: float) -> float:
58
+ return 6.75e-7 * i**3 - 7.71e-5 * i**2 + 1.792e-2 * i + 0.49239
59
+
60
+
61
+ def _daylength_factor(latitude: float, month: int) -> float:
62
+ """Correction factor (N/12)*(days/30) for the Thornthwaite PET adjustment."""
63
+ phi = math.radians(latitude)
64
+ decl = 0.409 * math.sin(2.0 * math.pi / 365.0 * MID_MONTH_DOY[month] - 1.39)
65
+ x = -math.tan(phi) * math.tan(decl)
66
+ x = max(-1.0, min(1.0, x)) # clamp for polar day/night
67
+ omega = math.acos(x)
68
+ daylight_hours = 24.0 / math.pi * omega
69
+ return (daylight_hours / 12.0) * (DAYS_IN_MONTH[month] / 30.0)
70
+
71
+
72
+ def monthly_pet(climate: MonthlyClimate) -> list:
73
+ """Monthly potential evapotranspiration [mm], Thornthwaite (1948)."""
74
+ temp = climate.temp
75
+ i = heat_index(temp)
76
+ a = _alpha(i)
77
+ pet = []
78
+ for m, t in enumerate(temp):
79
+ if t <= 0.0:
80
+ unadjusted = 0.0
81
+ elif t < 26.5:
82
+ unadjusted = 16.0 * (10.0 * t / i) ** a if i > 0 else 0.0
83
+ else:
84
+ # High-temperature branch: PET saturates (Willmott et al. 1985).
85
+ unadjusted = -415.85 + 32.24 * t - 0.43 * t * t
86
+ if climate.latitude is not None:
87
+ unadjusted *= _daylength_factor(climate.latitude, m)
88
+ pet.append(max(unadjusted, 0.0))
89
+ return pet
90
+
91
+
92
+ def _lookup(table: tuple, value: float) -> tuple:
93
+ for lower, code, name in table:
94
+ if value >= lower:
95
+ return code, name
96
+ return table[-1][1], table[-1][2]
97
+
98
+
99
+ def classify(climate: MonthlyClimate) -> ClassificationResult:
100
+ """Classify a 12-month climatology by Thornthwaite moisture & thermal indices."""
101
+ pet = monthly_pet(climate)
102
+ annual_pet = sum(pet)
103
+ precip = climate.map
104
+
105
+ moisture_index = 100.0 * (precip - annual_pet) / annual_pet if annual_pet > 0 else float("inf")
106
+
107
+ m_code, m_name = _lookup(_MOISTURE, moisture_index)
108
+ t_code, t_name = _lookup(_THERMAL, annual_pet)
109
+
110
+ code = f"{m_code}{t_code}"
111
+ name = f"{m_name} / {t_name}"
112
+
113
+ return ClassificationResult(
114
+ scheme="thornthwaite",
115
+ code=code,
116
+ zone=None,
117
+ name=name,
118
+ details={
119
+ "moisture_index": round(moisture_index, 1) if moisture_index != float("inf") else None,
120
+ "annual_PET": round(annual_pet, 1),
121
+ "annual_precip": round(precip, 1),
122
+ "moisture_province": m_name,
123
+ "thermal_province": t_name,
124
+ },
125
+ )
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: climaclass
3
+ Version: 0.1.0
4
+ Summary: Classical climate classification (Koppen-Geiger, Holdridge, Thornthwaite) from monthly climatologies - pure Python, no Earth Engine required.
5
+ Project-URL: Homepage, https://github.com/DarriEy/Climate_Classifications
6
+ Project-URL: Source, https://github.com/DarriEy/Climate_Classifications
7
+ Author: Darri Eythorsson
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ License-File: NOTICE
11
+ Keywords: classification,climate,climatology,holdridge,hydrology,koppen,thornthwaite
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
16
+ Requires-Python: >=3.9
17
+ Provides-Extra: dev
18
+ Requires-Dist: numpy; extra == 'dev'
19
+ Requires-Dist: pytest>=7; extra == 'dev'
20
+ Requires-Dist: ruff>=0.1; extra == 'dev'
21
+ Provides-Extra: symfluence
22
+ Requires-Dist: geopandas>=0.12; extra == 'symfluence'
23
+ Requires-Dist: rasterstats>=0.18; extra == 'symfluence'
24
+ Description-Content-Type: text/markdown
25
+
26
+ # climaclass
27
+
28
+ **Classical climate classification from monthly climatologies — pure Python, no Earth Engine required.**
29
+
30
+ `climaclass` turns a 12-month climatology of temperature and precipitation into a
31
+ climate class under three classical schemes:
32
+
33
+ | Scheme | Reference | Output |
34
+ |--------|-----------|--------|
35
+ | **Köppen–Geiger** | Peel et al. (2007); legend of Beck et al. (2018) | code (`Csb`) + zone 1–30 |
36
+ | **Holdridge life zones** | Holdridge (1967) | life-zone name + belt/province |
37
+ | **Thornthwaite** | Thornthwaite (1948) | moisture + thermal province |
38
+
39
+ It grew out of the [`Climate_Classifications`](https://github.com/DarriEy/Climate_Classifications)
40
+ Earth-Engine notebooks, but reimplements the *algorithms* as dependency-free
41
+ Python so they run anywhere — a laptop, a CI job, or inside a hydrological model
42
+ pipeline — without a Google Earth Engine account.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install climaclass # core: zero dependencies
48
+ pip install "climaclass[symfluence]" # + SYMFLUENCE attribute-processor plugin
49
+ ```
50
+
51
+ ## Use
52
+
53
+ ```python
54
+ from climaclass import MonthlyClimate, classify
55
+
56
+ reykjavik = MonthlyClimate(
57
+ temp=[0.1, 0.4, 0.9, 3.3, 6.8, 9.4, 10.9, 10.5, 7.7, 4.5, 1.7, 0.4], # °C, Jan..Dec
58
+ precip=[76, 72, 82, 58, 44, 50, 52, 62, 67, 86, 73, 79], # mm, Jan..Dec
59
+ latitude=64.1,
60
+ )
61
+
62
+ results = classify(reykjavik)
63
+ print(results["koppen"].code) # 'Cfc' (subpolar oceanic)
64
+ print(results["holdridge"].name) # e.g. 'Boreal moist forest'
65
+ print(results["thornthwaite"].code) # moisture/thermal province code
66
+ print(results["koppen"].details) # MAT, MAP, Pthreshold, ... for QA
67
+ ```
68
+
69
+ Run a single scheme directly:
70
+
71
+ ```python
72
+ from climaclass import koppen
73
+ koppen.classify(reykjavik).zone # 16 (Beck et al. legend)
74
+ ```
75
+
76
+ ### Input
77
+
78
+ Everything keys off one small record, `MonthlyClimate`:
79
+
80
+ - `temp` — 12 monthly **mean** temperatures (°C), January → December *(required)*
81
+ - `precip` — 12 monthly **total** precipitation (mm), January → December *(required)*
82
+ - `latitude` — optional; refines Thornthwaite PET day-length and fixes hemisphere
83
+ - `tmin` / `tmax` — optional, reserved for future scheme variants
84
+
85
+ ## SYMFLUENCE plugin
86
+
87
+ The optional `symfluence` extra ships an attribute processor that emits climate
88
+ classes as catchment attributes (`climate.koppen_code`, `climate.holdridge_zone`,
89
+ `climate.thornthwaite_code`, …), computed from the **WorldClim** monthly rasters
90
+ SYMFLUENCE already acquires — so there is no new data dependency and no Earth
91
+ Engine in the loop. It is registered via the `symfluence.attribute_processors`
92
+ entry point and can be used as a regionalization / PUB grouping variable.
93
+
94
+ The integration is fully decoupled: importing `climaclass` never imports
95
+ SYMFLUENCE, and the pure mapping helper `record_to_attributes(temp, precip)` is
96
+ testable on its own.
97
+
98
+ ## Develop
99
+
100
+ ```bash
101
+ pip install -e ".[dev]"
102
+ pytest -q
103
+ ruff check src/
104
+ ```
105
+
106
+ ## License
107
+
108
+ Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE). The
109
+ classification algorithms were prototyped in the author's
110
+ `Climate_Classifications` Earth-Engine notebooks and relicensed by the
111
+ copyright holder.
@@ -0,0 +1,13 @@
1
+ climaclass/__init__.py,sha256=ynQebYMVh72NbhKwuEAm8xfdsLXjKcp0VoGirvPg5Xk,1999
2
+ climaclass/_types.py,sha256=FCS6nFb4hsEXhmKx9_2QlqrxDN0-mcST2gM-IfrJI-U,3739
3
+ climaclass/holdridge.py,sha256=7PGNps0TjhDnQeebd_NwfL1wenwe5Pejyrm6F4dR6Vw,5102
4
+ climaclass/koppen.py,sha256=e5lA1ZU79ZYTBlKVflrHfasbocLv4AXY9bx4h7Xsm90,5683
5
+ climaclass/thornthwaite.py,sha256=u-7vJ80urNnKB4On6ByHSxz7TKSTcWNZ_pD5a58AGNU,4295
6
+ climaclass/integrations/__init__.py,sha256=p6Olc_nkLJuhlgS8vWpiydu7erswCZ56ZV2He1LCVDA,307
7
+ climaclass/integrations/symfluence.py,sha256=Kw3xmnzBpABbCOeRmc2HrP2Nj6R7j_t13-fqhhIOaJ8,6662
8
+ climaclass-0.1.0.dist-info/METADATA,sha256=vFPDwm5o_1JQgj5oPFkS0WrNsgqFSb3gieTaN1D6jlM,4267
9
+ climaclass-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
10
+ climaclass-0.1.0.dist-info/entry_points.txt,sha256=DBRgJhrjsRsg2o9FlXNjYFRX7phA6WcjFQ5Zofh9IUI,125
11
+ climaclass-0.1.0.dist-info/licenses/LICENSE,sha256=Bb4OTVdNvJJ-JZSWB_tbpHnobJzSRUv-TugVl_E68vs,11351
12
+ climaclass-0.1.0.dist-info/licenses/NOTICE,sha256=Y5zFcnG7UBwm_rNCL-H92cHWoRp-Ep1TEAuu41XBfqg,861
13
+ climaclass-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [symfluence.attribute_processors]
2
+ climate_classification = climaclass.integrations.symfluence:ClimateClassificationProcessor
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2024-2026 Darri Eythorsson
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,17 @@
1
+ climaclass
2
+ Copyright 2024-2026 Darri Eythorsson
3
+
4
+ This product includes software developed by Darri Eythorsson.
5
+
6
+ The classification algorithms reimplement the methods previously prototyped in
7
+ the author's Climate_Classifications project (Google Earth Engine notebooks),
8
+ relicensed by the copyright holder under the Apache License, Version 2.0.
9
+
10
+ Scientific references:
11
+ - Peel, M. C., Finlayson, B. L., & McMahon, T. A. (2007). Updated world map
12
+ of the Koppen-Geiger climate classification. HESS, 11, 1633-1644.
13
+ - Beck, H. E., et al. (2018). Present and future Koppen-Geiger climate
14
+ classification maps at 1-km resolution. Scientific Data, 5, 180214.
15
+ - Holdridge, L. R. (1967). Life Zone Ecology. Tropical Science Center.
16
+ - Thornthwaite, C. W. (1948). An approach toward a rational classification of
17
+ climate. Geographical Review, 38(1), 55-94.