plaid.containers.sample¶
plaid.containers.sample
¶
Implementation of the Sample container.
plaid.containers.sample.Sample
¶
Represents a single sample. It contains data and information related to a single observation or measurement within a dataset.
By default, the sample is empty. Use :meth:Sample.load_from_dir or
:meth:Sample.load to load sample data from disk.
Note
Mesh/field/global operations are directly implemented on Sample via
inheritance from internal feature operations.
plaid.containers.sample.Sample.initialize_defaults
¶
Initialize the default manager if not already set.
plaid.containers.sample.Sample.copy
¶
Create a deep copy of the current Sample instance.
Usage of model_copy(deep=True) from Pydantic to ensure all internal data is deeply copied.
Returns:
-
Self–A new
Sampleinstance with all internal data (scalars, fields, meshes, etc.) -
Self–deeply copied to ensure full isolation from the original.
Note
This operation may be memory-intensive for large samples.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_all_features_identifiers_by_type
¶
Get all features identifiers of a given type from the sample.
Parameters:
-
feature_type(str) –Type of features to return
Returns:
-
list[str]–list[FeatureIdentifier]: A list of dictionaries containing the identifiers of a given type of all features in the sample.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_all_features_by_type
¶
Get the list of all CGNS paths of features of a given type (eg 'field', 'global', 'coordinate', etc...).
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_feature_by_path
¶
Retrieve a feature value from the sample's CGNS mesh using a CGNS-style url.
Parameters:
-
path(str) –CGNS node path relative to the mesh root (for example "BaseName/ZoneName/GridCoordinates/CoordinateX" or "BaseName/ZoneName/Solution/FieldName").
-
time(Optional[float | floating], default:None) –Time selection for the mesh. If an integer, it is interpreted via the sample time-assignment logic (see
resolve_time). If None, the default time assignment is used. Defaults to None.
Returns:
-
Feature(number | ndarray | None) –The value stored at the given CGNS path. This may be a numpy array, a scalar, or None if the node has no value.
Note
- This is a thin wrapper around CGNS.PAT.cgnsutils.getValueByPath and Sample.get_tree(time). Callers should handle a returned None when the path or value does not exist.
- For field-like features, prefer using Sample.get_field which applies additional validation and selection logic.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.add_feature
¶
Add a feature to current sample.
This method applies updates to scalars, fields, or nodes using feature identifiers, and corresponding feature data.
Parameters:
-
feature_path(str) –A feature path string.
-
feature(Feature) –Feature value corresponding to
feature_path.
Returns:
-
Self(Self) –The updated sample
Raises:
-
AssertionError–If types are inconsistent or identifiers contain unexpected keys.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.del_feature_by_path
¶
Delete a feature/node by CGNS-style path from the sample mesh tree.
Parameters:
-
path(str) –CGNS node path relative to the mesh root (for example "BaseName/ZoneName/GridCoordinates/CoordinateX" or "BaseName/ZoneName/Solution/FieldName").
-
time(Optional[int], default:None) –Time selection for the mesh. If an integer, it is interpreted via the sample time-assignment logic (see
resolve_time). If None, the default time assignment is used. Defaults to None.
Returns:
-
Feature(CGNSTree) –Updated tree after node deletion.
Note
- This method resolves the requested time and deletes the node at
pathwhen present.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.update_features_by_path
¶
Update one or several features of the sample by their identifier(s).
This method applies updates to scalars, fields, or nodes
using feature identifiers, and corresponding feature data. When in_place=False, a deep copy of the sample is created
before applying updates, ensuring full isolation from the original.
Parameters:
-
feature_identifiers(FeatureIdentifier or list of FeatureIdentifier) –One or more feature identifiers.
-
features(dict of Feature or list of Feature) –One or more features corresponding to the identifiers.
-
in_place(bool, default:False) –If True, modifies the current sample in place. If False, returns a deep copy with updated features.
Returns:
-
Self(Self) –The updated sample (either the current instance or a new copy).
Raises:
-
AssertionError–If types are inconsistent or identifiers contain unexpected keys.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.save_to_dir
¶
Save the Sample in directory path.
Parameters:
-
path(Union[str, Path]) –relative or absolute directory path.
-
overwrite(bool, default:False) –target directory overwritten if True.
-
memory_safe(bool, default:False) –use pyCGNS save in a subprocess (requires an additional pickle of the sample) if True.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.load_from_dir
classmethod
¶
Load the Sample from directory path.
This is a class method, you don't need to instantiate a Sample first.
Parameters:
-
path(Union[str, Path]) –Relative or absolute directory path.
Returns:
-
Self–Sample
Example
.. code-block:: python
from plaid import Sample
sample = Sample.load_from_dir(dir_path)
print(sample)
>>> Sample(2 scalars, 1 timestamp, 5 fields)
Note
It calls :meth:Sample.load method during execution.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.load
¶
Load the Sample from directory path.
Parameters:
-
path(Union[str, Path]) –Relative or absolute directory path.
Raises:
-
FileNotFoundError–Triggered if the provided directory does not exist.
-
FileExistsError–Triggered if the provided path is a file instead of a directory.
Example
.. code-block:: python
from plaid import Sample
sample = Sample()
sample.load(path)
print(sample)
>>> Sample(3 scalars, 1 timestamp, 3 fields)
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.__str__
¶
Return a string representation of the sample.
Returns:
-
str(str) –A string representation of the overview of sample content.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.summarize
¶
Provide detailed summary of the Sample content, showing feature names and mesh information.
This provides more detailed information than the repr method, including the name of each feature.
Returns:
-
str(str) –A detailed string representation of the sample content.
Example
.. code-block:: bash
Sample Summary:
==================================================
Scalars (8):
- Pr: 0.9729006564945664
- Q: 0.2671142611487964
- Tr: 0.9983394202616822
- angle_in: 45.5066666666667
- angle_out: 61.89519547386746
- eth_is: 0.21238326882538008
- mach_out: 0.81003
- power: 0.0019118127462776008
Meshes (1 timestamps):
Time: 0.0
Base: Base_2_2
Nodes (36421)
Tags (6): Intrado (122), Extrado (122), Inflow (121), Outflow (121), Periodic_1 (120), Periodic_2 (238)
Fields (7): ro, sdf, rou, nut, mach, roe, rov
Elements (36000)
QUAD_4 (36000)
Base: Base_1_2
Nodes (244)
Fields (1): M_iso
Elements (242)
BAR_2 (242)
Source code in plaid/containers/sample.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
plaid.containers.sample.Sample.check_completeness
¶
Check the completeness of features in this sample.
Returns:
-
str(str) –A report on feature completeness.
Example
.. code-block:: bash
Sample Completeness Check:
==============================
Has scalars: True
Has meshes: True
Total unique fields: 8
Field names: M_iso, mach, nut, ro, roe, rou, rov, sdf
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.set_default_time
¶
Set the default active time. Calls the DefaultManager to set the default time.
Parameters:
-
time(float) –The time to set as the default active time.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.set_default_base
¶
Set the default active base. Calls the DefaultManager to set the default base.
Parameters:
-
base(str) –The base name to set as the default active base.
-
time(float, default:None) –The time at which to set the default base. Defaults to None.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.set_default_zone_base
¶
Set the default active zone within a base. Calls the DefaultManager to set the default zone and base.
Parameters:
-
zone(str) –The zone name to set as the default active zone.
-
base(str) –The base name in which the zone is located.
-
time(float, default:None) –The time at which to set the default zone and base. Defaults to None.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.resolve_time
¶
Get the resolved time assignment. Calls the DefaultManager to resolve the time.
Parameters:
-
time(float, default:None) –The time to resolve. Defaults to None.
Returns:
-
float(float) –The resolved time.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.resolve_base
¶
Get the resolved base assignment. Calls the DefaultManager to resolve the base.
Parameters:
-
base(str, default:None) –The base name to resolve. Defaults to None.
-
time(float, default:None) –The time at which to resolve the base. Defaults to None.
Returns:
-
Optional[str]–Optional[str]: The resolved base name.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.resolve_zone
¶
Get the resolved zone assignment. Calls the DefaultManager to resolve the zone.
Parameters:
-
zone(str, default:None) –The zone name to resolve. Defaults to None.
-
base(str, default:None) –The base name in which the zone is located. Defaults to None.
-
time(float, default:None) –The time at which to resolve the zone. Defaults to None.
Returns:
-
Optional[str]–Optional[str]: The resolved zone name.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_all_time_values
¶
Retrieve all time steps corresponding to the meshes, if available.
Returns:
-
list[float]–list[float]: A list of all available time steps.
plaid.containers.sample.Sample.init_tree
¶
Initialize a CGNS tree structure at a specified time step or create a new one if it doesn't exist.
Parameters:
-
time(float, default:None) –The time step for which to initialize the CGNS tree structure. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
CGNSTree(list) –The initialized or existing CGNS tree structure for the specified time step.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_tree
¶
Retrieve the CGNS tree structure for a specified time step, if available.
Parameters:
-
time(float, default:None) –The time step for which to retrieve the CGNS tree structure. If a specific time is not provided, the method will display the tree structure for the default time step.
-
only_mesh(bool, default:False) –If True, features of type global and fields are removed from the sample
Returns:
-
CGNSTree(Optional[CGNSTree]) –The CGNS tree structure for the specified time step if available; otherwise, returns None.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.set_trees
¶
Set all meshes with their corresponding time step.
Parameters:
-
meshes(dict[float, CGNSTree]) –Collection of time step with its corresponding CGNSTree.
Raises:
-
KeyError–If there is already a CGNS tree set.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.add_tree
¶
Merge a CGNS tree into the tree stored at a given time.
If there is no tree at time, tree is stored directly. Otherwise, Base
nodes from tree are appended only when their name does not already exist in
the destination tree. Bases with duplicate names are ignored and a warning is
emitted.
Parameters:
-
tree(CGNSTree) –CGNS tree to add.
-
time(float, default:None) –Time step at which the tree is added. If omitted, the default time resolution is used.
-
in_place(bool, default:True) –Controls ownership of the input tree. When
True(default), the provided object may be stored/used directly. WhenFalse, the input tree is deep-copied before insertion.
Raises:
-
ValueError–If
treeis an empty list.
Returns:
-
CGNSTree(CGNSTree) –The resulting tree for the resolved
time.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.del_tree
¶
Delete the CGNS tree for a specific time.
Parameters:
-
time(float) –The time step for which to delete the CGNS tree structure.
Raises:
-
KeyError–There is no CGNS tree in this Sample / There is no CGNS tree for the provided time.
Returns:
-
CGNSTree(CGNSTree) –The deleted CGNS tree.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_topological_dim
¶
Get the topological dimension of a base node at a specific time.
Parameters:
-
base(str, default:None) –The name of the base node for which to retrieve the topological dimension. Defaults to None.
-
time(float, default:None) –The time at which to retrieve the topological dimension. Defaults to None.
Raises:
-
ValueError–If there is no base node with the specified
baseat the giventimein this sample.
Returns:
-
int(int) –The topological dimension of the specified base node at the given time.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_physical_dim
¶
Get the physical dimension of a base node at a specific time.
Parameters:
-
base(str, default:None) –The name of the base node for which to retrieve the topological dimension. Defaults to None.
-
time(float, default:None) –The time at which to retrieve the topological dimension. Defaults to None.
Raises:
-
ValueError–If there is no base node with the specified
baseat the giventimein this sample.
Returns:
-
int(int) –The topological dimension of the specified base node at the given time.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.init_base
¶
Create a Base node named base if it doesn't already exists.
Parameters:
-
topological_dim(int) –Cell dimension, see CGNS standard.
-
physical_dim(int) –Ambient space dimension, see CGNS standard.
-
base(str, default:None) –If not specified, uses
mesh_base_namespecified in Sample initialization. Defaults to None. -
time(float, default:None) –The time at which to initialize the base. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
CGNSNode(CGNSNode) –The created Base node.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.del_base
¶
Delete a CGNS base node for a specific time.
Parameters:
-
base(str) –The name of the base node to be deleted.
-
time(float) –The time step for which to delete the CGNS base node.
Raises:
-
KeyError–There is no CGNS tree in this sample / There is no CGNS tree for the provided time.
-
KeyError–If there is no base node with the given base name or time.
Returns:
-
CGNSTree(CGNSTree) –The tree at the provided time (without the deleted node)
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_base_names
¶
Return Base names.
Parameters:
-
full_path(bool, default:False) –If True, returns full paths instead of only Base names. Defaults to False.
-
unique(bool, default:False) –If True, returns unique names instead of potentially duplicated names. Defaults to False.
-
time(float, default:None) –The time at which to check for the Base. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
list[str]–list[str]:
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.has_base
¶
Check if a CGNS tree contains a Base with a given name at a specified time.
Parameters:
-
base(str) –The name of the Base to check for in the CGNS tree.
-
time(float, default:None) –The time at which to check for the Base. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
bool(bool) –Trueif the CGNS tree has a Base calledbase, else returnFalse.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.has_globals
¶
Check if a CGNS tree contains globals a given name at a specified time.
Parameters:
-
time(float, default:None) –The time at which to check for the Base. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
bool(bool) –Trueif the CGNS tree has a Base calledGlobals, else returnFalse.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_base
¶
Return Base node named base.
If base is not specified, checks that there is at most one base, else raises an error.
Parameters:
-
base(str, default:None) –The name of the Base node to retrieve. Defaults to None. Defaults to None.
-
time(float, default:None) –Time at which you want to retrieve the Base node. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
CGNSNode | None–CGNSNode or None: The Base node with the specified name or None if it is not found.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.init_zone
¶
Initialize a new zone within a CGNS base.
Parameters:
-
zone_shape(Array) –An array specifying the shape or dimensions of the zone.
-
zone_type(str, default:Unstructured_s) –The type of the zone. Defaults to CGK.Unstructured_s.
-
zone(str, default:None) –The name of the zone to initialize. If not provided, uses
mesh_zone_namespecified in Sample initialization. Defaults to None. -
base(str, default:None) –The name of the base to which the zone will be added. If not provided, the zone will be added to the currently active base. Defaults to None.
-
time(float, default:None) –The time at which to initialize the zone. If a specific time is not provided, the method will display the tree structure for the default time step.
Raises:
-
KeyError–If the specified base does not exist. You can create a base using
Sample.init_base(base).
Returns:
-
CGLNode(CGNSNode) –The newly initialized zone node within the CGNS tree.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.del_zone
¶
Delete a zone within a CGNS base.
Parameters:
-
zone(str) –The name of the zone to be deleted.
-
base(str) –The name of the base from which the zone will be deleted. If not provided, the zone will be deleted from the currently active base. Defaults to None.
-
time(float) –The time step for which to delete the zone. Defaults to None.
Raises:
-
KeyError–There is no CGNS tree in this sample / There is no CGNS tree for the provided time.
-
KeyError–If there is no base node with the given base name or time.
Returns:
-
CGNSTree(CGNSTree) –The tree at the provided time (without the deleted node)
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_zone_names
¶
Return list of Zone names in Base named base with specific time.
Parameters:
-
base(str, default:None) –Name of Base where to search Zones. If not specified, checks if there is at most one Base. Defaults to None.
-
full_path(bool, default:False) –If True, returns full paths instead of only Zone names. Defaults to False.
-
unique(bool, default:False) –If True, returns unique names instead of potentially duplicated names. Defaults to False.
-
time(float, default:None) –The time at which to check for the Zone. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
list[str]–list[str]: List of Zone names in Base named
base, empty if there is none or if the Base doesn't exist.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.has_zone
¶
Check if the CGNS tree contains a Zone with the specified name within a specific Base and time.
Parameters:
-
zone(str) –The name of the Zone to check for.
-
base(str, default:None) –The name of the Base where the Zone should be located. If not provided, the function checks all bases. Defaults to None.
-
time(float, default:None) –The time at which to check for the Zone. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
bool(bool) –Trueif the CGNS tree has a Zone calledzonein a Base calledbase, else returnFalse.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_zone
¶
Retrieve a CGNS Zone node by its name within a specific Base and time.
Parameters:
-
zone(str, default:None) –The name of the Zone node to retrieve. If not specified, checks that there is at most one zone in the base, else raises an error. Defaults to None.
-
base(str, default:None) –The Base in which to seek to zone retrieve. If not specified, checks that there is at most one base, else raises an error. Defaults to None.
-
time(float, default:None) –Time at which you want to retrieve the Zone node.
Returns:
-
CGNSNode(CGNSNode | None) –Returns a CGNS Zone node if found; otherwise, returns None.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_zone_type
¶
Get the type of a specific zone at a specified time.
Parameters:
-
zone(str, default:None) –The name of the zone whose type you want to retrieve. Default is None.
-
base(str, default:None) –The name of the base in which the zone is located. Default is None.
-
time(float, default:None) –The timestamp for which you want to retrieve the zone type. Default is 0.0.
Raises:
-
KeyError–Raised when the specified zone or base does not exist. You should first create the base/zone using
Sample.init_zone(zone, base).
Returns:
-
str(str) –The type of the specified zone as a string.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_nodal_tags
¶
Get the nodal tags for a specified base and zone at a given time.
Parameters:
-
zone(str, default:None) –The name of the zone for which element connectivity data is requested. Defaults to None, indicating the default zone.
-
base(str, default:None) –The name of the base for which element connectivity data is requested. Defaults to None, indicating the default base.
-
time(float, default:None) –The time at which element connectivity data is requested. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
dict[str, Array]–dict[str, Array]: A dictionary where keys are nodal tags names and values are NumPy arrays containing the corresponding tag indices.
-
dict[str, Array]–The NumPy arrays have shape (num_nodal_tags).
Source code in plaid/containers/sample.py
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 | |
plaid.containers.sample.Sample.get_element_tags
¶
Get the element tags for a specified base and zone at a given time.
Parameters:
-
zone(str, default:None) –The name of the zone for which element tags are requested. Defaults to None.
-
base(str, default:None) –The name of the base for which element tags are requested. Defaults to None.
-
time(float, default:None) –The time at which element tags are requested. Defaults to None.
Returns:
-
dict[str, Array]–dict[str, Array]: A dictionary where keys are element tag names and values are NumPy arrays containing the corresponding element indices (0-based).
Source code in plaid/containers/sample.py
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 | |
plaid.containers.sample.Sample.get_global
¶
Retrieve a global array by name at a specified time.
Parameters:
-
name(str) –The name of the global array to retrieve.
-
time(float, default:None) –The time step for which to retrieve the global array. If not provided, uses the default time.
Returns:
-
Optional[ScalarOrArrayOrStr]–Optional[Array]: The global array if found, otherwise None. Returns a scalar if the array has size 1.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.add_global
¶
Add or update a global array at a specified time.
Parameters:
-
name(str) –The name of the global array to add or update.
-
global_array(Array) –The array to store.
-
time(float, default:None) –The time step for which to add the global array. If not provided, uses the default time.
Note
If the "Global" base does not exist, it will be created. If an array with the same name exists, its value will be updated.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.del_global
¶
Delete a global array by name at a specified time.
Parameters:
-
name(str) –The name of the global array to delete.
-
time(float, default:None) –The time step for which to delete the global array. If not provided, uses the default time.
Raises:
-
KeyError–If the global array does not exist at the specified time.
Returns:
-
Array(Array) –The value of the deleted global array.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_global_names
¶
Return a list of all global array names at the specified time(s).
Parameters:
-
time(float, default:None) –The time step for which to retrieve global names. If not provided, returns names for all available times.
Returns:
-
list[str]–list[str]: List of global array names (excluding "Time" arrays).
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_nodes
¶
Get grid node coordinates from a specified base, zone, and time.
Parameters:
-
zone(str, default:None) –The name of the zone to search for. Defaults to None.
-
base(str, default:None) –The name of the base to search for. Defaults to None.
-
time(float, default:None) –The time value to consider when searching for the zone. If a specific time is not provided, the method will display the tree structure for the default time step.
-
name(str, default:None) –The coordinate array name to retrieve. Supported values are
CoordinateX,CoordinateY, andCoordinateZ. If not provided, all coordinates are returned.
Raises:
-
TypeError–Raised if multiple
nodes are found. Only one is expected.
Returns:
-
Optional[Array]–Optional[Array]: A NumPy array containing the grid node coordinates.
-
Optional[Array]–If no matching zone or grid coordinates are found, None is returned.
Source code in plaid/containers/sample.py
1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 | |
plaid.containers.sample.Sample.set_nodes
¶
Set the coordinates of nodes for a specified base and zone at a given time.
Parameters:
-
nodes(Array) –A numpy array containing the new node coordinates.
-
zone(str, default:None) –The name of the zone where the nodes should be updated. Defaults to None.
-
base(str, default:None) –The name of the base where the nodes should be updated. Defaults to None.
-
time(float, default:None) –The time at which the node coordinates should be updated. If a specific time is not provided, the method will display the tree structure for the default time step.
Raises:
-
KeyError–Raised if the specified base or zone do not exist. You should first create the base and zone using the
Sample.init_zone(zone,base)method.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_elements
¶
Retrieve element connectivity data for a specified zone, base, and time.
Parameters:
-
zone(str, default:None) –The name of the zone for which element connectivity data is requested. Defaults to None, indicating the default zone.
-
base(str, default:None) –The name of the base for which element connectivity data is requested. Defaults to None, indicating the default base.
-
time(float, default:None) –The time at which element connectivity data is requested. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
dict[str, Array]–dict[str, Array]: A dictionary where keys are element type names and values are NumPy arrays representing the element connectivity data.
-
dict[str, Array]–The NumPy arrays have shape (num_elements, num_nodes_per_element), and element indices are 0-based.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.get_field_names
¶
Get a set of field names associated with a specified zone, base, location, and/or time.
For each argument that is not specified, the method will search for fields in all available values for this argument.
Parameters:
-
location(str, default:None) –The desired grid location where to search for. Defaults to None. Possible values :
const:
plaid.constants.CGNS_FIELD_LOCATIONS -
zone(str, default:None) –The name of the zone to search for. Defaults to None.
-
base(str, default:None) –The name of the base to search for. Defaults to None.
-
time(float, default:None) –The specific time at which to search for. Defaults to None.
Returns:
-
list[str]–set[str]: A set containing the names of the fields that match the specified criteria.
Source code in plaid/containers/sample.py
1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 | |
plaid.containers.sample.Sample.get_field
¶
Retrieve a field with a specified name from a given zone, base, location, and time.
Parameters:
-
name(str) –The name of the field to retrieve.
-
location(str, default:'Vertex') –The location at which to retrieve the field. Defaults to 'Vertex'. Possible values :
const:
plaid.constants.CGNS_FIELD_LOCATIONS -
zone(str, default:None) –The name of the zone to search for. Defaults to None.
-
base(str, default:None) –The name of the base to search for. Defaults to None.
-
time(float, default:None) –The time value to consider when searching for the field. If a specific time is not provided, the method will display the tree structure for the default time step.
Returns:
-
Field(ndarray | None) –A set containing the names of the fields that match the specified criteria.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.add_field
¶
add_field(
name,
field,
location="Vertex",
zone=None,
base=None,
time=None,
warning_overwrite=True,
)
Add a field to a specified zone in the grid.
Parameters:
-
name(str) –The name of the field to be added.
-
field(Field) –The field data to be added. Integer arrays with dtype
np.int32ornp.int64are automatically converted tonp.float64(with a warning) for CGNS compatibility. -
location(str, default:'Vertex') –The grid location where the field will be stored. Defaults to 'Vertex'. Possible values :
const:
plaid.constants.CGNS_FIELD_LOCATIONS -
zone(str, default:None) –The name of the zone where the field will be added. Defaults to None.
-
base(str, default:None) –The name of the base where the zone is located. Defaults to None.
-
time(float, default:None) –The time associated with the field. Defaults to 0.
-
warning_overwrite(bool, default:True) –Show warning if a preexisting field is being overwritten. Defaults to True.
Raises:
-
KeyError–Raised if the specified zone does not exist in the given base.
Source code in plaid/containers/sample.py
1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 | |
plaid.containers.sample.Sample.del_field
¶
Delete a field with specified name in the mesh.
Parameters:
-
name(str) –The name of the field to be deleted.
-
location(str, default:'Vertex') –The grid location where the field is stored. Defaults to 'Vertex'. Possible values :
const:
plaid.constants.CGNS_FIELD_LOCATIONS -
zone(str, default:None) –The name of the zone from which the field will be deleted. Defaults to None.
-
base(str, default:None) –The name of the base where the zone is located. Defaults to None.
-
time(float, default:None) –The time associated with the field. Defaults to None.
Raises:
-
KeyError–Raised if the specified zone or field does not exist in the given base.
Returns:
-
CGNSTree(CGNSTree) –The tree at the provided time (without the deleted node)
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.show_tree
¶
Display the structure of the CGNS tree for a specified time.
Parameters:
-
time(float, default:None) –The time step for which you want to display the CGNS tree structure. Defaults to None. If a specific time is not provided, the method will display the tree structure for the default time step.