fractopo.analysis.subsampling module

Utilities for Network subsampling.

fractopo.analysis.subsampling.aggregate_chosen(chosen: list[dict[str, float | int | ~numbers.Real | str]], default_aggregator: ~collections.abc.Callable = <function mean_aggregation>) dict[str, Any]

Aggregate a collection of subsampled circles for params.

Weights averages by the area of each subsampled circle.

fractopo.analysis.subsampling.area_weighted_index_choice(idxs: list[int], areas: list[float | int | Real], compressor: list[bool]) int

Make area-weighted choce from list of indexes.

fractopo.analysis.subsampling.choose_sample_from_group(group: list[dict[str, float | int | Real | str]]) dict[str, float | int | Real | str]

Choose single sample from group DataFrame.

fractopo.analysis.subsampling.collect_indexes_of_base_circles(idxs: list[int], how_many: int, areas: list[float | int | Real]) list[int]

Collect indexes of base circles, area-weighted and randomly.

fractopo.analysis.subsampling.create_sample(sampler: NetworkRandomSampler) dict[str, float | int | Real | str] | None

Sample with NetworkRandomSampler and return Network description.

fractopo.analysis.subsampling.gather_subsample_descriptions(subsample_results: list[dict[str, float | int | Real | str] | None]) list[dict[str, float | int | Real | str]]

Gather results from a list of subsampling ProcessResults.

fractopo.analysis.subsampling.group_gathered_subsamples(subsamples: list[dict[str, float | int | Real | str]], groupby_column: str = 'Name') dict[str, list[dict[str, float | int | Real | str]]]

Group gathered subsamples.

By default groups by Name column.

>>> subsamples = [
...     {"param": 2.0, "Name": "myname"},
...     {"param": 2.0, "Name": "myname"},
... ]
>>> group_gathered_subsamples(subsamples)
{'myname': [{'param': 2.0, 'Name': 'myname'}, {'param': 2.0, 'Name': 'myname'}]}
fractopo.analysis.subsampling.groupby_keyfunc(item: dict[str, float | int | Real | str], groupby_column: str = 'Name') str

Use groupby_column to group values.

fractopo.analysis.subsampling.random_sample_of_circles(grouped: dict[str, list[dict[str, float | int | Real | str]]], circle_names_with_diameter: dict[str, float | int | Real], min_circles: int = 1, max_circles: int | None = None) list[dict[str, float | int | Real | str]]

Get a random sample of circles from grouped subsampled data.

Both the amount of overall circles and which circles within each group is random. Data is grouped by target area name.

fractopo.analysis.subsampling.subsample_networks(networks: Sequence[Network], min_radii: float | int | Real | dict[str, float | int | Real], random_choice: RandomChoice = RandomChoice.radius, samples: int = 1) list[dict[str, float | int | Real | str] | None]

Subsample given Sequence of Networks.