fractopo.analysis.random_sampling module

Utilities for randomly Network sampling traces.

class fractopo.analysis.random_sampling.NetworkRandomSampler(trace_gdf, area_gdf, min_radius, snap_threshold, random_choice, name)

Bases: object

Randomly sample traces inside given target area.

area_gdf: GeoDataFrame
static area_gdf_should_contain_polygon(area_gdf)

Check that area_gdf contains one Polygon.

Return type:

GeoDataFrame

property max_area: float

Calculate maximum area from max_radius.

property max_radius: float

Calculate max radius from given area_gdf.

property min_area: float

Calculate minimum area from min_radius.

min_radius: float
name: str
random_area()

Calculate random area in area range.

Range is calculated from [min_radius, max_radius[.

Return type:

float

random_choice: Union[RandomChoice, str]
static random_choice_should_be_enum(random_choice)

Check that random_choice is valid.

Return type:

RandomChoice

random_network_sample(determine_branches_nodes=True)

Get random Network sample with a random target area.

Returns the network, the sample circle centroid and circle radius.

Return type:

RandomSample

classmethod random_network_sampler(network, min_radius, random_choice=RandomChoice.radius)

Initialize NetworkRandomSampler for random sampling.

Assumes that Network target area is a single Polygon circle.

random_radius()

Calculate random radius in range [min_radius, max_radius[.

Return type:

float

random_target_circle()

Get random target area and its centroid and radius.

The target area is always within the original target area.

Return type:

Tuple[Polygon, Point, float]

snap_threshold: float
property target_area_centroid: Point

Get target area centroid.

property target_circle: Polygon

Target circle Polygon from area_gdf.

trace_gdf: GeoDataFrame
static trace_gdf_should_contain_traces(trace_gdf)

Check that trace_gdf contains LineString traces.

Return type:

GeoDataFrame

static value_should_be_positive(min_radius)

Check that value is positive.

Return type:

float

class fractopo.analysis.random_sampling.RandomChoice(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Choose between random area or radius.

The choice is relevant because area is polynomially correlated with radius.

area = 'area'
radius = 'radius'
class fractopo.analysis.random_sampling.RandomSample(network_maybe, target_centroid, radius, name)

Bases: object

Dataclass for sampling results.

name: str
network_maybe: Optional[Network]
radius: float
target_centroid: Point