terraflow.model¶
Suitability scoring is a normalized weighted composite of vegetation index, mean temperature, and total rainfall. Scores in [0, 1] are mapped to ordinal labels.
Public functions¶
suitability_score(v, t, r, params)— single-cell scalar score.suitability_score_array(v, t, r, params)— vectorised NumPy version used by the pipeline.suitability_label(score)— score → ordinal class.
API Reference¶
model
¶
suitability_label(score)
¶
Bucket suitability score into qualitative labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
score
|
float
|
Suitability score in [0, 1] range. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
One of 'low', 'medium', or 'high' based on score thresholds. |
Notes
- 'low': score < 0.33
- 'medium': 0.33 <= score < 0.66
- 'high': score >= 0.66
Source code in terraflow/model.py
suitability_score(v_index, mean_temp, total_rain, params)
¶
Compute a simple suitability score in [0, 1].
Combines normalized vegetation index, temperature, and rainfall using weighted linear combination. All inputs are normalized to [0, 1] range based on the parameter min/max bounds, then combined using the weights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_index
|
float
|
Vegetation index value (typically 0-1, but can be outside range). |
required |
mean_temp
|
float
|
Mean temperature in degrees Celsius. |
required |
total_rain
|
float
|
Total rainfall in millimeters. |
required |
params
|
ModelParams
|
Model parameters containing min/max bounds and weights. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Suitability score in [0, 1] range. |
Notes
- Out-of-range inputs are clipped to [0, 1] during normalization
- Weights should sum to 1.0 for proper combination
- Final result is clipped to [0, 1] range
Source code in terraflow/model.py
suitability_score_array(v_index, mean_temp, total_rain, params)
¶
Vectorized suitability scoring over numpy arrays.
Equivalent to calling :func:suitability_score element-wise but operates
on arbitrary-shape numpy arrays. Used internally for Monte Carlo
uncertainty propagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v_index
|
ndarray
|
Vegetation index values (any shape). |
required |
mean_temp
|
ndarray
|
Mean temperature values in °C (same shape as v_index). |
required |
total_rain
|
ndarray
|
Total rainfall values in mm (same shape as v_index). |
required |
params
|
ModelParams
|
Model parameters containing min/max bounds and weights. |
required |
Returns:
| Type | Description |
|---|---|
np.ndarray:
|
Suitability scores clipped to [0, 1], same shape as inputs. |