Attribute

class silvimetric.resources.attribute.Attribute(name: str, dtype)

Bases: object

Represents point data from a PDAL execution that has been binned, and provides the information necessary to transfer that data to the database.

entry_name() str

Return TileDB attribute name.

static from_dict(data: dict) Attribute

Make an Attribute from a JSON like object

static from_string(data: str) Attribute

Create Attribute from string or dict version of it.

Parameters:

data – Stringified or json object of attribute

Raises:

TypeError – Incorrect type of incoming data, must be string or dict

Returns:

Return derived Attribute

make_array(data, copy=False)
schema() Attr

Create the tiledb schema for this attribute. :return: TileDB attribute schema

to_json() object
dtype: pandas.api.extensions.register_extension_dtype

SilviMetric representation of array of numpy dtype

name

Name of the attribute, eg. Intensity.

Metric

class silvimetric.resources.metric.Metric(name: str, dtype: dtype, method: Callable[[pandas.DataFrame, Any], pandas.DataFrame], dependencies: list[Self] = [], filters: List[Callable[[pandas.DataFrame, Any | None], pandas.DataFrame]] = [], attributes: List[Attribute] = [])

Bases: object

A Metric is a TileDB entry representing derived cell data. There is a base set of metrics available through Silvimetric, or you can create your own. A Metric object has all the information necessary to facilitate the derivation of data as well as its insertion into the database.

add_filter(fn: Callable[[pandas.DataFrame, Any | None], pandas.DataFrame], desc: str)

Add filter method to list of filters to run before calling main method.

do(data: pandas.DataFrame, *args) pandas.DataFrame

Run metric and filters. Use previously run metrics to avoid running the same thing multiple times.

entry_name(attr: str) str

Name for use in TileDB and extract file generation.

static from_dict(data: dict) Metric
static from_string(data: str) Self
run_filters(data: pandas.DataFrame) pandas.DataFrame
sanitize_and_run(d, *args)
schema(attr: Attribute) Any

Create schema for TileDB creation.

Parameters:

attrsilvimetric.resources.entry.Atttribute

Returns:

TileDB Attribute

to_json() dict[str, any]
attributes

List of Attributes this Metric applies to. If empty it’s used for all Attributes

dependencies

Metrics this is dependent on.

dtype

Numpy data type.

filters

List of user-defined filters to perform before performing method.

name

Metric name. eg. mean

silvimetric.resources.metric.get_methods(data: pandas.DataFrame | Delayed, metrics: Metric | list[Metric], uuid=None) list[Delayed]

Create Metric dependency graph by iterating through desired metrics and their dependencies, creating Delayed objects that can be run later.

silvimetric.resources.metric.run_metrics(data: pandas.DataFrame, metrics: Metric | list[Metric]) pandas.DataFrame

Collect Metric dependency graph and run it, then merge the results together.