Skip to content

Commit 15a84b5

Browse files
committed
Better checks on valid survey in template.
Augment test
1 parent 0b4aaf6 commit 15a84b5

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

simpeg_drivers/plate_simulation/match/driver.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
from geoh5py import Workspace
2727
from geoh5py.groups import PropertyGroup, SimPEGGroup
2828
from geoh5py.objects import AirborneTEMReceivers, Surface
29-
from geoh5py.shared.utils import (
30-
fetch_active_workspace,
31-
)
3229
from geoh5py.ui_json import InputFile
3330
from scipy import signal
3431
from scipy.sparse import csr_matrix
@@ -57,20 +54,20 @@ def __init__(
5754
self._template = self.get_template()
5855
self._time_mask, self._time_projection = self.time_mask_and_projection()
5956

60-
def get_template(self):
57+
def get_template(self) -> AirborneTEMReceivers:
6158
"""
6259
Get a template simulation to extract time sampling.
6360
"""
6461
with Workspace(self.params.simulation_files[0], mode="r") as ws:
6562
survey = fetch_survey(ws)
66-
if survey.channels is None:
63+
if not isinstance(survey, AirborneTEMReceivers):
6764
raise GeoAppsError(
68-
f"No time channels found in survey of {self.params.simulation_files[0]}"
65+
f"No survey found under Plate Simulation of {self.params.simulation_files[0]}"
6966
)
7067

71-
if survey.vertices is None:
68+
if survey.channels is None:
7269
raise GeoAppsError(
73-
f"No receiver locations found in survey of {self.params.simulation_files[0]}"
70+
f"No time channels found in survey of {self.params.simulation_files[0]}"
7471
)
7572

7673
return survey

tests/plate_simulation/runtest/match_test.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
from pathlib import Path
1212

1313
import numpy as np
14+
import pytest
15+
from geoapps_utils.utils.importing import GeoAppsError
1416
from geoh5py import Workspace
15-
from geoh5py.groups import PropertyGroup
17+
from geoh5py.groups import PropertyGroup, SimPEGGroup
1618
from geoh5py.objects import Points
1719
from geoh5py.ui_json import InputFile
1820

@@ -84,6 +86,21 @@ def test_file_parsing(tmp_path: Path):
8486
assert len(sim_files) == 1
8587
assert sim_files[0].name == f"{__name__}.geoh5"
8688

89+
with pytest.raises(GeoAppsError, match="No survey found under Plate Simulation"):
90+
PlateMatchDriver(options)
91+
92+
# Copy the survey as if it was generated by the PlateSimulationDriver
93+
with geoh5.open():
94+
sim_group = SimPEGGroup.create(geoh5, name="Plate Simulation")
95+
survey = geoh5.get_entity("survey")[0]
96+
new_survey = survey.copy(parent=sim_group)
97+
metadata = survey.metadata
98+
metadata["EM Dataset"].pop("Channels")
99+
new_survey.metadata = metadata
100+
101+
with pytest.raises(GeoAppsError, match="No time channels found in survey"):
102+
PlateMatchDriver(options)
103+
87104

88105
def test_matching_driver(tmp_path: Path):
89106
"""

0 commit comments

Comments
 (0)