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_feature_paths_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.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.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
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
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
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | |
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
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 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 | |
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
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 | |
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
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 | |
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
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 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 | |
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.
Source code in plaid/containers/sample.py
plaid.containers.sample.Sample.update_feature_by_path
¶
Update a feature value in the CGNS tree by its path.
Parameters:
-
path(str) –The path to the feature node in the CGNS tree.
-
value(ndarray) –The new value to be set at the specified path.
-
time(float, default:None) –The time associated with the feature. Defaults to None, which will use the default time.
Raises:
-
KeyError–Raised if the specified path does not exist in the CGNS tree.