lsapy.SuitabilityCriteria#
- class lsapy.SuitabilityCriteria(name, indicator, func=None, weight=1, category=None, long_name=None, description=None, comment=None, attrs=None, is_computed=False)[source]#
A data structure for suitability criteria.
Suitability criteria are used to compute the suitability of a location from an indicator and based on a set of rules defined by a suitability function. The suitability criteria can be weighted and categorized defining how it will be aggregated with other criteria.
- Parameters:
name (str) – Name of the suitability criteria.
indicator (xr.DataArray) – Indicator on which the criteria is based.
func (SuitabilityFunction, optional) – Suitability function describing how the suitability of the criteria is computed.
weight (int | float, optional) – Weight of the criteria used in the aggregation process if a weighted aggregation method is used. The default is 1.
category (str, optional) – Category of the criteria. The default is None.
long_name (str, optional) – A long name for the criteria. The default is None. If provided, it will be stored as an attribute.
description (str, optional) – A description for the criteria. The default is None. If provided, it will be stored as an attribute.
comment (str, optional) – Additional information about the criteria. The default is None. If provided, it will be stored as an attribute.
attrs (Mapping[Any, Any], optional) – Arbitrary metadata to store with the criteria, in addition to the attributes long_name, description, and comment. The default is None.
is_computed (bool, optional) – If the indicator data already contains the computed suitability values. Default is False.
Examples
Here is an example using the sample soil data with the drainage class (DRC) as indicator for the criteria.
>>> from lsapy.utils import open_data >>> from lsapy.functions import SuitabilityFunction >>> from xclim.indicators.atmos import growing_degree_days
>>> drainage = open_data("land", variables="drainage") >>> sc = SuitabilityCriteria( ... name="drainage_class", ... long_name="Drainage Class Suitability", ... weight=3, ... category="soilTerrain", ... indicator=drainage, ... func=SuitabilityFunction(name="discrete", params={"rules": {0: 0, 1: 0.1, 2: 0.5, 3: 0.9, 4: 1}}), ... )
Here is another example using the sample climate data with the growing degree days (GDD) as indicator for the criteria computing using the xclim package.
>>> tas = open_data("climate", variables="tas") >>> gdd = growing_degree_days(tas, thresh="10 degC", freq="YS-JUL") >>> sc = SuitabilityCriteria( ... name="growing_degree_days", ... long_name="Growing Degree Days Suitability", ... weight=1, ... category="climate", ... indicator=gdd, ... func=SuitabilityFunction(name="vetharaniam2022_eq5", params={"a": -1.41, "b": 801}), ... )
- __init__(name, indicator, func=None, weight=1, category=None, long_name=None, description=None, comment=None, attrs=None, is_computed=False)[source]#
Methods
__init__(name, indicator[, func, weight, ...])compute(**kwargs)Compute the suitability of the criteria.
Attributes
attrsDictionary of the suitability criteria attributes.