ibfoamrig.core.Sampler#
- class ibfoamrig.core.Sampler(centres, values, *, names=None, ids=None, neighbours=8)[source]#
Bases:
objectEvaluates cell-centered values at arbitrary points.
- Variables:
names – Names of the sampled value columns.
dimensions – Number of axes along which the cell centres vary.
neighbours – Number of cell centres used by the
"linear"method.
- classmethod from_data(data, fields=None, *, neighbours=8)[source]#
Builds a sampler over the cells of a
FieldData.- Parameters:
- Returns:
A sampler whose value columns are named after the fields and whose
nearestreturnscellI.- Raises:
TypeError – If
fieldsis a single string.ValueError – If no fields are selected or a field is missing.
- Return type:
- at(points, *, method='linear', max_distance=None)[source]#
Samples the values at the given points.
- Parameters:
points (Points) – Sample points. If a frame is given, all its columns are kept and the sampled values are appended.
method (Method) – Interpolation method, see the module description.
max_distance (float | None) – If given, samples whose nearest cell centre is farther away are set to NaN. Use to avoid extraplating outside the domain or across holes.
- Returns:
The points (or the input frame) with one column per value.
- Raises:
ValueError – If the points are malformed,
methodis unknown, or a value name is already a column of the input frame.- Return type:
- line(start, end, count=200, *, method='linear', max_distance=None)[source]#
Samples the values at evenly spaced points along a line segment.
- Parameters:
start (Point) – First end point
(x , y, z).end (Point) – Second end point
(x, y, z).count (int) – Number of points, including both end points.
method (Method) – Interpolation method, see the module description.
max_distance (float | None) – If given, samples whose nearest cell centre is farther away are set to NaN.
- Returns:
A frame with
s, x, y, zand one column per value.- Raises:
ValueError – If
countis below 2,startandendcoincide, ormethodis unknown.- Return type: