PointGroup#

class PointGroup[source]#

Bases: TransformableEntity, EntityBase

PointGroup class for defining many monitor points under a single name.

Example

Import a set of probe locations from a CSV export. This is what the class is for: a file of experimental probe coordinates becomes one entity instead of one entity per row.

>>> group = fl.PointGroup.from_csv(
...     "probes.csv",
...     name="Rake A",
...     unit=fl.u.mm,
...     coordinate_columns=("x_coord", "y_coord", "z_coord"),
... )
>>> fl.ProbeOutput(name="probes", entities=[group], output_fields=["Cp"])

Or list the coordinates directly:

>>> fl.PointGroup(
...     name="Rake A",
...     locations=[[0.0, 0.0, 0.0], [0.0, 0.0, 1.0]] * fl.u.m,
... )

Attributes

locations: Length.Vector3Array#

The coordinates of the points in the group.

Properties

id: str#

Returns private_attribute_id of the entity.

Additional Constructors

classmethod from_csv(file_path, *, name, unit, coordinate_columns=None, delimiter=',')[source]#

Build a PointGroup from the coordinates in a CSV file.

The shape of the file is stated by the caller, never guessed. Pass coordinate_columns and the first row is read as a header from which exactly those three columns are taken; omit it and the file is read as headerless rows of exactly three columns. Columns that are not selected are ignored, so an export carrying a name or id column needs no preparation.

Exact duplicate coordinates are dropped in first-occurrence order and reported as a UserWarning, since a repeated probe location yields nothing.

Parameters:
  • file_path (str) – Path to the CSV file. Read as utf-8-sig, so a spreadsheet export that starts with a byte-order mark is read the same as plain UTF-8.

  • name (str) – Name of the resulting group. Monitor keys are {name}_{index}.

  • unit (unyt.Unit) – Unit of every coordinate in the file, for example fl.u.mm. The file carries no unit of its own, so this is required.

  • coordinate_columns (tuple[str, str, str], optional) – Header names of the x, y and z columns, which must be three distinct names. Columns the header repeats but these do not name are never read. Omit for a headerless file.

  • delimiter (str, default ",") – Field separator, for exports that use ; or a tab.

Returns:

A group holding one point per surviving row.

Return type:

PointGroup

Example

>>> fl.PointGroup.from_csv(
...     "probes.csv",
...     name="Rake A",
...     unit=fl.u.mm,
...     coordinate_columns=("x_coord", "y_coord", "z_coord"),
... )

A headerless file of exactly three columns needs nothing but the unit:

>>> fl.PointGroup.from_csv("bare.csv", name="Rake A", unit=fl.u.mm)