plaid.containers.managers.default_manager ========================================= .. py:module:: plaid.containers.managers.default_manager .. autoapi-nested-parse:: DefaultManager for managing default time/base/zone selections. Classes ------- .. autoapisummary:: plaid.containers.managers.default_manager.FeaturesBackend plaid.containers.managers.default_manager.DefaultManager Module Contents --------------- .. py:class:: FeaturesBackend Bases: :py:obj:`Protocol` Minimal interface required by DefaultManager. This allows any backend implementing these methods to be used by DefaultManager. For example, SampleFeatures already satisfies this contract. .. py:method:: get_all_time_values() -> list[float] Get all available time values in the mesh. .. py:method:: get_base_names(*, time: Optional[float] = None) -> list[str] Get all available base names at a given time. .. py:method:: get_zone_names(base_name: Optional[str] = None, *, time: Optional[float] = None) -> list[str] Get all available zone names within a base at a given time. .. py:method:: has_base(base_name: str, time: Optional[float] = None) -> bool Check if a base exists at a given time. .. py:method:: has_zone(zone_name: str, base_name: Optional[str] = None, time: Optional[float] = None) -> bool Check if a zone exists within a base at a given time. .. py:class:: DefaultManager 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. .. py:method:: set_default_time(time: float) -> None Set the default time for the system. This function sets the default time to be used for various operations in the system. :param time: The time value to be set as the default. :type time: float :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. .. rubric:: Example .. code-block:: python 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 >>> ... .. py:method:: set_default_base(base_name: str, time: Optional[float] = None) -> None 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. :param base_name: The name of the base to be set as the default. :type base_name: str :param time: The time at which the base should be set as default. If not provided, the default base and active zone will be set with the default time. :type time: float, optional :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. .. rubric:: Example .. code-block:: python 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 .. py:method:: set_default_zone_base(zone_name: str, base_name: str, time: Optional[float] = None) -> None 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. :param zone_name: The name of the zone to be set as the active zone. :type zone_name: str :param base_name: The name of the base to be set as the default. :type base_name: str :param time: 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. :type time: float, optional :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. .. rubric:: Example .. code-block:: python 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 .. py:method:: resolve_time(time: Optional[float] = None) -> float 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. :param time: The time to resolve. Defaults to None. :type time: float, optional :returns: The resolved time. :rtype: float .. py:method:: resolve_base(base_name: Optional[str] = None, time: Optional[float] = None) -> Optional[str] Resolve which base name to use for an operation. :param base_name: The base name to resolve. Defaults to None. :type base_name: str, optional :param time: The time at which to resolve the base. Defaults to None. :type time: float, optional :returns: The resolved base name. :rtype: Optional[str] :raises KeyError: If multiple bases exist and no default is set. .. py:method:: resolve_zone(zone_name: Optional[str] = None, base_name: Optional[str] = None, time: Optional[float] = None) -> Optional[str] Resolve which zone name to use for an operation. :param zone_name: The zone name to resolve. Defaults to None. :type zone_name: str, optional :param base_name: The base name in which the zone is located. Defaults to None. :type base_name: str, optional :param time: The time at which to resolve the zone. Defaults :type time: float, optional Returns:: Optional[str]: The resolved zone name. :raises KeyError: If multiple zones exist and no default is set.