API reference¶
sitsfeats.feats¶
The single entry point. Dispatches on the input type: a NumPy array returns a Features, or an xarray cube returns an xarray.Dataset (see Working with data cubes).
Extract time-series metrics (features) from satellite image data.
A single entry point that dispatches on the type of data:
-
numpy.ndarray- each row is a time series. Returns aFeatureswith a stacked(n_series, n_metrics)array and the column names. -
xarray.DataArray / Dataset- a labelled data cube. Returns anxarray.Datasetwith one variable per metric, preserving spatial coordinates and attributes (chunked/Dask cubes are processed lazily). This path requires the optionalxarraydependency and accepts adimkeyword naming the time dimension (default"time").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray | DataArray | Dataset
|
Time-series data - a 2-D array (rows are series) or an xarray cube. |
required |
metrics
|
list[str]
|
Metric names. |
required |
**kwargs
|
str
|
Forwarded to the input-specific handler
(e.g. |
{}
|
Returns:
| Type | Description |
|---|---|
Features | Dataset
|
Features | xarray.Dataset: A |
Features | Dataset
|
|
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If a metric is not available. |
TypeError
|
If |
sitsfeats.Features¶
Bases: NamedTuple
Result of a feature extraction over a plain array.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
ndarray
|
Stacked metrics with shape |
names |
list[str]
|
Metric names, in column order. |
data
instance-attribute
¶
Stacked metrics with shape (n_series, n_metrics).
names
instance-attribute
¶
Metric names, in column order.
__array__(dtype=None)
¶
Expose the stacked matrix to np.asarray.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
dtype | None
|
The dtype of the returned array. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: The stacked matrix as a numpy array. |
to_dict()
¶
Return the metrics as a {name: column} mapping.
Returns:
| Type | Description |
|---|---|
dict[str, ndarray]
|
dict[str, np.ndarray]: A dictionary with metric names as keys and the corresponding columns as values. |
sitsfeats.metrics¶
List the available metrics, with their family and a short description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
str | None
|
If given, restrict the result to this family
(e.g. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
MetricTable |
MetricTable
|
A table of |
Example
from sitsfeats import metrics metrics() name group description abs_sum basic Sum of absolute values ... metrics(group="polar").names ['angle', 'area_q1', ...]
sitsfeats.registry.MetricTable¶
Bases: Sequence
An immutable, dependency-free table of MetricInfo records.
Behaves as a sequence of records (iterate, index, len, in) and
renders as an aligned table in the terminal and as an HTML table in Jupyter.
Use names to get the bare metric names (e.g., to pass to sitsfeats.feats), or
to_dict / to_pandas to export.
__slots__ = ('_records',)
class-attribute
instance-attribute
¶
Tuple of MetricInfo records.
names
property
¶
Get the metric names, in table order.
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: The metric names, in table order. |
__getitem__(index)
¶
Get a record by index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Index of the record. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MetricInfo |
MetricInfo
|
The |
__init__(records)
¶
Initialize the metric table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
Sequence[MetricInfo]
|
Sequence of |
required |
__len__()
¶
Get the number of records in the table.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The number of records in the table. |
__repr__()
¶
Return a string representation of the metric table.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
A string representation of the metric table. |
to_dict()
¶
Return the metric records as a list of dictionaries.
Returns:
| Type | Description |
|---|---|
list[dict[str, str]]
|
list[dict[str, str]]: The metric records as a list of dictionaries. |
to_pandas()
¶
Metric records as a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: The metric records as a pandas DataFrame. |
sitsfeats.registry.MetricInfo¶
sitsfeats.registry.MetricsRegistry¶
Registry of available metrics, keyed by name.
exists(name, raise_error=False)
classmethod
¶
Check if a given metric exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name. |
required |
raise_error
|
bool
|
Raise instead of returning |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
Whether the metric exists. |
group(name)
classmethod
¶
Return the family of a registered metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The family of the given metric. |
info(name)
classmethod
¶
Return the full MetricInfo record for a registered metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MetricInfo |
MetricInfo
|
The |
names()
classmethod
¶
List the names of all registered metrics.
register(name, group, description)
classmethod
¶
Register a metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Metric name. |
required |
group
|
str
|
Metric family (e.g. |
required |
description
|
str
|
One-line summary. |
required |