Point Sampling
The PointSampler class
PointSampler(geom_object, sampling_strategy, field_generator=None)
summary
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_object
|
Mesh
|
description |
required |
sampling_strategy
|
SamplingStrategy
|
description |
required |
field_generator
|
FieldGenerator
|
description. Defaults to None. |
None
|
sample(n_points, on_ratio=0.01)
Sample a given number of points according to the provided sampling strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
number of points to sample. |
required |
on_ratio
|
float
|
ratio of sampled points that are taken on the geometry rather than around it. Defaults to 0.01. |
0.01
|
Returns:
| Name | Type | Description |
|---|---|---|
Tuple |
(ndarray, ndarray)
|
An array of sampled points and an array of the field value at these points. |
sample_geometry(n_points)
Sample a given number of points on the geometrical object provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_points
|
int
|
number of points to sample |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: array of sampled points |
Sampling strategies
CombinedStrategy(strategies, weights=None, shuffle=True)
Bases: SamplingStrategy
Combines different sampling strategies into one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
strategies
|
list
|
list of SamplingStrategy objects to call for sampling. |
required |
weights
|
list
|
relative weights of the sampling strategies. Weights [1,2] means that twice as many points will be sampled from the second strategy. If not provided, sampling is uniform. Defaults to None. |
None
|
shuffle
|
bool
|
Whether to shuffle the output points |
True
|
Raises:
| Type | Description |
|---|---|
Exception
|
Fails if weights are not all positive. |
Gaussian(geom_object, stdv)
Bases: SamplingStrategy
Multivariate Gaussian sampling with zero mean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_object
|
Mesh
|
geometry to sample. Only the |
required |
stdv
|
float
|
Standard variation of the Gaussian distribution. |
required |
NearGeometryGaussian(geom_object, stdv=0.01)
Bases: SamplingStrategy
Sample points around a given object by first sampling points on the object and add a Gaussian noise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_object
|
Mesh
|
geometry to sample. |
required |
stdv
|
float
|
Standard variation of the Gaussian distribution. Defaults to 1e-2. |
0.01
|
Raises:
| Type | Description |
|---|---|
Exception
|
Fails if the function is unable to sample the given geometrical object. |
UniformBox(geom_object, domain=None)
Bases: SamplingStrategy
Uniform sampling in an axis-aligned bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_object
|
Mesh
|
geometry to sample. Only the |
required |
domain
|
AABB
|
bounding box to consider for sampling. If not provided, will take [-1.5, 1.5]^n as default. Defaults to None. |
None
|