plaid.containers.managers.default_manager¶
DefaultManager for managing default time/base/zone selections.
Classes¶
Minimal interface required by DefaultManager. |
|
Manages and resolves default time/base/zone selections. |
Module Contents¶
- class FeaturesBackend[source]¶
Bases:
ProtocolMinimal interface required by DefaultManager.
This allows any backend implementing these methods to be used by DefaultManager.
For example, SampleFeatures already satisfies this contract.
- get_base_names(*, time: float | None = None) list[str][source]¶
Get all available base names at a given time.
- get_zone_names(base_name: str | None = None, *, time: float | None = None) list[str][source]¶
Get all available zone names within a base at a given time.
- class DefaultManager[source]¶
Manages and resolves default time/base/zone selections.
Notes on legacy semantics: - resolve_time(None) returns the first sorted available timestamp, else 0.0. - resolve_base(None) returns None if no non-Global base exists. - resolve_zone(None) returns None if no zone exists in the resolved base.
- set_default_time(time: float) None[source]¶
Set the default time for the system.
This function sets the default time to be used for various operations in the system.
- Parameters:
time (float) – The time value to be set as the default.
- Raises:
ValueError – If the specified time does not exist in the available mesh times.
Note
Setting the default time is important for synchronizing operations with a specific time point in the system’s data.
The available mesh times can be obtained using the get_all_mesh_times method.
Example
from plaid import Sample sample = Sample("path_to_plaid_sample") print(sample) >>> Sample(2 scalars, 1 timestamp, 5 fields) print(sample.show_tree(0.5)) >>> ... # Set the default time to 0.5 seconds sample.set_default_time(0.5) # You can now use class functions with 0.5 as default time print(sample.show_tree()) # show the cgns tree at the time 0.5 >>> ...
- set_default_base(base_name: str, time: float | None = None) None[source]¶
Set the default base for the specified time (that will also be set as default if provided).
The default base is a reference point for various operations in the system.
- Parameters:
- Raises:
ValueError – If the specified base does not exist at the given time.
Note
Setting the default base and is important for synchronizing operations with a specific base in the system’s data.
The available mesh base can be obtained using the get_base_names method.
Example
from plaid import Sample sample = Sample("path_to_plaid_sample") print(sample) >>> Sample(2 scalars, 1 timestamp, 5 fields) print(sample.get_physical_dim("BaseA", 0.5)) >>> 3 # Set "BaseA" as the default base for the default time sample.set_default_base("BaseA") # You can now use class functions with "BaseA" as default base print(sample.get_physical_dim(0.5)) >>> 3 # Set "BaseB" as the default base for a specific time sample.set_default_base("BaseB", 0.5) # You can now use class functions with "BaseB" as default base and 0.5 as default time print(sample.get_physical_dim()) # Physical dim of the base "BaseB" >>> 3
- set_default_zone_base(zone_name: str, base_name: str, time: float | None = None) None[source]¶
Set the default base and active zone for the specified time (that will also be set as default if provided).
The default base and active zone serve as reference points for various operations in the system.
- Parameters:
zone_name (str) – The name of the zone to be set as the active zone.
base_name (str) – The name of the base to be set as the default.
time (float, optional) – The time at which the base and zone should be set as default. If not provided, the default base and active zone will be set with the default time.
- Raises:
ValueError – If the specified base or zone does not exist at the given time
Note
Setting the default base and zone are important for synchronizing operations with a specific base/zone in the system’s data.
The available mesh bases and zones can be obtained using the get_base_names and get_base_zones methods, respectively.
Example
from plaid import Sample sample = Sample("path_to_plaid_sample") print(sample) >>> Sample(2 scalars, 1 timestamp, 5 fields) print(sample.get_zone_type("ZoneX", "BaseA", 0.5)) >>> Structured # Set "BaseA" as the default base and "ZoneX" as the active zone for the default time sample.set_default_zone_base("ZoneX", "BaseA") # You can now use class functions with "BaseA" as default base with "ZoneX" as default zone print(sample.get_zone_type(0.5)) # type of the zone "ZoneX" of base "BaseA" >>> Structured # Set "BaseB" as the default base and "ZoneY" as the active zone for a specific time sample.set_default_zone_base("ZoneY", "BaseB", 0.5) # You can now use class functions with "BaseB" as default base with "ZoneY" as default zone and 0.5 as default time print(sample.get_zone_type()) # type of the zone "ZoneY" of base "BaseB" at 0.5 >>> Unstructured
- resolve_time(time: float | None = None) float[source]¶
Resolve which time to use for an operation.
Resolution order: - If time is provided, return it. - Else if a default time is set, return it. - Else return the first sorted available timestamp, or 0.0 if none exist.
- resolve_base(base_name: str | None = None, time: float | None = None) str | None[source]¶
Resolve which base name to use for an operation.