generate_distribution#

generate_distribution(domain, population=None, include_boundaries=None, exclude_boundaries=None, boundary_exclude_distance=0, kernel_radius=150, kernel_sigma=50, mesh_step=10, kernel_function=None, add_contribution_as_labels=False, contribution_label_name='Distribution values', visualise_output=False, visualise_heatmap_kwargs={})#

Generate a spatial distribution heatmap for a given domain.

Parameters:
domainDomain

A muspan domain object.

populationquery-like

A population of objects or a query to select them.

include_boundariesarray-like, query-like, or None, optional

Boundaries to include in the analysis. Defaults to None.

exclude_boundariesarray-like, query-like, or None, optional

Boundaries to exclude from the analysis. Defaults to None.

boundary_exclude_distancefloat, optional

Distance from the boundary to exclude objects, by default 0.

kernel_radiusfloat, optional

Radius of the kernel, by default 150.

kernel_sigmafloat, optional

Standard deviation of the default Gaussian kernel, by default 50. This will be used if kernel_function is None.

mesh_stepfloat, optional

Step size for the mesh grid, by default 10.

kernel_functioncallable, optional

Custom kernel function. If None, a Gaussian kernel is used.

add_contribution_as_labelsbool, optional

Whether to add contributions as labels to the domain objects, by default False.

contribution_label_namestr, optional

Name of the contribution label, by default ‘Distribution values’.

visualise_outputbool, optional

Whether to visualize the output heatmap, by default False.

visualise_heatmap_kwargsdict, optional

Additional keyword arguments for the visualization function.

Returns:
heatmapndarray

The generated heatmap as a 2D numpy array.

Raises:
ValueError

If kernel_radius is less than mesh_step. If kernel_function is not None or a callable.