diff --git a/backend/src/backend/primary/routers/surface/schemas.py b/backend/src/backend/primary/routers/surface/schemas.py index d679dae43..3b05993d7 100644 --- a/backend/src/backend/primary/routers/surface/schemas.py +++ b/backend/src/backend/primary/routers/surface/schemas.py @@ -38,13 +38,13 @@ class SurfaceAttributeType(str, Enum): class SurfaceMeta(BaseModel): stratigraphic_name: str stratigraphic_name_is_official: bool - stratigraphic_feature: Optional[StratigraphicFeature] + stratigraphic_feature: Optional[StratigraphicFeature] = None # Distinguish between horizon and unit attribute_name: str attribute_type: SurfaceAttributeType - iso_date_or_interval: Optional[str] + iso_date_or_interval: Optional[str] = None is_observation: bool # Can only be true for seismic surfaces - value_min: Optional[float] - value_max: Optional[float] + value_min: Optional[float] = None + value_max: Optional[float] = None class SurfaceData(BaseModel): diff --git a/backend/src/services/smda_access/stratigraphy_access.py b/backend/src/services/smda_access/stratigraphy_access.py index 08d208f90..e935e3851 100644 --- a/backend/src/services/smda_access/stratigraphy_access.py +++ b/backend/src/services/smda_access/stratigraphy_access.py @@ -31,14 +31,14 @@ def create_hierarchical_structure(strat_units: List[StratigraphicUnit]) -> List[ for unit in strat_units: if unit.strat_unit_parent and unit.strat_unit_parent in unit_by_id: parent = unit_by_id[unit.strat_unit_parent] - parent["children"].append(unit) + parent["children"].append(unit) # pylint: disable=attr-defined else: roots.append(unit) return roots -def flatten_hierarchical_structure(units: List[StratigraphicUnit], unit_by_id: Dict) -> List[StratigraphicUnit]: +def flatten_hierarchical_structure(units: List[Dict], unit_by_id: Dict) -> List[StratigraphicUnit]: """Flatten the hierarchical structure into a single list of stratigraphic units, preserving the order.""" flattened_list = [] @@ -50,9 +50,7 @@ def flatten_hierarchical_structure(units: List[StratigraphicUnit], unit_by_id: D return flattened_list -def flatten_hierarchical_structure_to_surface_name( - units: List[StratigraphicUnit], unit_by_id: Dict -) -> List[StratigraphicSurface]: +def flatten_hierarchical_structure_to_surface_name(units: List[Dict], unit_by_id: Dict) -> List[StratigraphicSurface]: """Flatten the hierarchical structure into a single list of stratigraphical top/unit/base names, preserving the order.""" flattened_list = [] @@ -67,15 +65,17 @@ def flatten_hierarchical_structure_to_surface_name( return flattened_list -def sort_stratigraphic_names_by_hierarchy(strat_units: List[StratigraphicUnit]) -> List[StratigraphicUnit]: +def sort_stratigraphic_names_by_hierarchy(strat_units: List[StratigraphicUnit]) -> List[StratigraphicSurface]: """Sort stratigraphic top/unit/base by hierarchy.""" unit_by_id = {unit.identifier: {"unit": unit, "children": []} for unit in strat_units} for unit in strat_units: if unit.strat_unit_parent and unit.strat_unit_parent in unit_by_id: - unit_by_id[unit.strat_unit_parent]["children"].append(unit) + unit_by_id[unit.strat_unit_parent]["children"].append(unit) # pylint: disable=attr-defined - roots = [data["unit"] for data in unit_by_id.values() if not data["unit"].strat_unit_parent] + roots = [ + data["unit"] for data in unit_by_id.values() if not data["unit"].strat_unit_parent + ] # pylint: disable=attr-defined sorted_units = flatten_hierarchical_structure_to_surface_name(roots, unit_by_id) return sorted_units @@ -86,8 +86,8 @@ def sort_stratigraphic_units_by_hierarchy(strat_units: List[StratigraphicUnit]) for unit in strat_units: if unit.strat_unit_parent and unit.strat_unit_parent in unit_by_id: - unit_by_id[unit.strat_unit_parent]["children"].append(unit) + unit_by_id[unit.strat_unit_parent]["children"].append(unit) # pylint: disable=attr-defined roots = [data["unit"] for data in unit_by_id.values() if not data["unit"].strat_unit_parent] - sorted_units = flatten_hierarchical_structure(roots, unit_by_id) + sorted_units = flatten_hierarchical_structure(roots, unit_by_id) # pylint: disable=attr-defined return sorted_units diff --git a/backend/src/services/sumo_access/dev_sumo_access_test_driver.py b/backend/src/services/sumo_access/dev_sumo_access_test_driver.py index 254622c56..8c8f1cf10 100644 --- a/backend/src/services/sumo_access/dev_sumo_access_test_driver.py +++ b/backend/src/services/sumo_access/dev_sumo_access_test_driver.py @@ -11,7 +11,7 @@ compute_vector_statistics, ) from .summary_access import SummaryAccess, RealizationVector, Frequency -from .surface_access import SurfaceAccess + from .sumo_explore import SumoExplore @@ -72,30 +72,6 @@ def test_summary_access(summary_access: SummaryAccess) -> None: print(vec_stats) -def test_surface_access(surf_access: SurfaceAccess) -> None: - dynamic_surf_dir = surf_access.get_dynamic_surf_dir() - print(f"{dynamic_surf_dir=}") - - static_surf_dir = surf_access.get_static_surf_dir() - print(f"{static_surf_dir=}") - - name_idx = 0 - valid_attr_indices = static_surf_dir.valid_attributes_for_name[name_idx] - surf_name = static_surf_dir.names[name_idx] - surf_attr = static_surf_dir.attributes[valid_attr_indices[0]] - surf = surf_access.get_static_surf(real_num=0, name=surf_name, attribute=surf_attr) - print(f"{type(surf)=}") - - # surf = surf_access.get_static_surf(real_num=0, name=static_surf_dir.names[0], attribute=static_surf_dir.attributes[2]) - # print(f"{type(surf)=}") - - # dyn_surf = surf_access.get_dynamic_surf(real_num=0, name=dynamic_surf_dir.names[0], attribute=dynamic_surf_dir.attributes[0], time_or_interval_str=dynamic_surf_dir.date_strings[0]) - # print(f"{type(dyn_surf)=}") - - # dyn_surf = surf_access.get_statistical_dynamic_surf(statistic_function=StatisticFunction.MEAN, name=dynamic_surf_dir.names[0], attribute=dynamic_surf_dir.attributes[0], time_or_interval_str=dynamic_surf_dir.date_strings[0]) - # print(f"{type(dyn_surf)=}") - - def main() -> None: print("## Running dev_sumo_access_test_driver") print("## =================================================") @@ -135,9 +111,6 @@ def main() -> None: # summary_access = SummaryAccess(access_token=access_token, case_uuid=sumo_case_id, iteration_name=iteration_name) # test_summary_access(summary_access) - surface_access = SurfaceAccess(access_token=access_token, case_uuid=sumo_case_id, iteration_name=iteration_name) - test_surface_access(surface_access) - # Running: # python -m src.services.sumo_access.dev_sumo_access_test_driver