Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions simpeg_drivers-assets/uijson/tile_estimator.ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,13 @@
"main": true,
"label": "Create plot",
"value": true
},
"out_group": {
"label": "UIJson group",
"value": "",
"groupType": "{BB50AC61-A657-4926-9C82-067658E246A0}",
"visible": true,
"optional": true,
"enabled": false
}
}
5 changes: 3 additions & 2 deletions simpeg_drivers/utils/tile_estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from geoapps_utils.base import Driver, Options
from geoapps_utils.utils.numerical import fibonacci_series, fit_circle
from geoh5py.groups import SimPEGGroup, UIJsonGroup
from pydantic import field_validator
from pydantic import ConfigDict, field_validator
from scipy.interpolate import interp1d
from tqdm import tqdm

Expand All @@ -41,6 +41,8 @@ class TileParameters(Options):
Parameters for the tile estimator.
"""

model_config = ConfigDict(frozen=False, arbitrary_types_allowed=True)

default_ui_json: ClassVar[Path] = assets_path() / "uijson/tile_estimator.ui.json"
icon: str = "tilelist"

Expand Down Expand Up @@ -117,7 +119,6 @@ def run(self) -> SimPEGGroup:
"""
Run the tile estimator.
"""
_ = self.driver.inversion # Triggers creation of something
results = self.get_results()

logger.info(
Expand Down
15 changes: 9 additions & 6 deletions tests/run_tests/driver_tile_estimator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pathlib import Path

import numpy as np
from geoh5py.groups import SimPEGGroup
from geoh5py.groups import RootGroup, SimPEGGroup

from simpeg_drivers.potential_fields.magnetic_scalar.inversion import (
MagneticInversionDriver,
Expand Down Expand Up @@ -73,8 +73,10 @@ def test_tile_estimator_run(
starting_model=components.model,
)

driver = MagneticInversionDriver(params)
tile_params = TileParameters(geoh5=geoh5, simulation=driver.out_group)
driver = MagneticInversionDriver(params)
tile_params = TileParameters(geoh5=geoh5, simulation=driver.out_group)
tile_params.out_group = tile_params.ui_json.to_ui_json_group(workspace=geoh5)

uijson = tile_params.write_ui_json(tmp_path / "tile_estimator.ui.json")

estimator = TileEstimator.start(uijson)
Expand All @@ -84,15 +86,16 @@ def test_tile_estimator_run(
simpeg_group = next(
group
for group in geoh5.groups
if isinstance(group, SimPEGGroup) and group.uid != driver.out_group.uid
if isinstance(group, SimPEGGroup)
and not isinstance(group.parent, RootGroup)
)
driver = simpeg_group_to_driver(simpeg_group, geoh5)

assert driver.inversion_type == "magnetic scalar"
assert driver.params.compute.tile_spatial == 3
assert (
len(simpeg_group.children) == 2
and simpeg_group.children[0].name == "tile_estimator.png"
len(estimator.out_group.children) == 3
and estimator.out_group.children[1].name == "tile_estimator.png"
)


Expand Down
Loading