Skip to content

Commit 719eb27

Browse files
committed
Continue update
1 parent 7771663 commit 719eb27

20 files changed

Lines changed: 220 additions & 1244 deletions

simpeg_drivers-assets/uijson/direct_current_2d_forward.ui.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
},
2020
"line_object": {
2121
"association": "Cell",
22-
"dataType": "Referenced",
22+
"dataType": [
23+
"Integer",
24+
"Referenced"
25+
],
2326
"group": "Survey",
2427
"main": true,
2528
"label": "Line ID",
2629
"parent": "data_object",
2730
"value": "",
31+
"optional": true,
32+
"enabled": false,
2833
"tooltip": "Selects the data representing the different lines in the survey."
2934
},
3035
"line_id": {
@@ -35,6 +40,8 @@
3540
"value": 1,
3641
"optional": true,
3742
"enabled": false,
43+
"dependency": "line_object",
44+
"dependencyType": "enabled",
3845
"tooltip": "Selects the line of data to be processed."
3946
},
4047
"potential_channel_bool": true,

simpeg_drivers-assets/uijson/direct_current_2d_inversion.ui.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,29 @@
1919
},
2020
"line_object": {
2121
"association": "Cell",
22-
"dataType": "Referenced",
23-
"group": "Data",
22+
"dataType": [
23+
"Integer",
24+
"Referenced"
25+
],
26+
"group": "Survey",
2427
"main": true,
2528
"label": "Line ID",
2629
"parent": "data_object",
2730
"value": "",
31+
"optional": true,
32+
"enabled": false,
2833
"tooltip": "Selects the data representing the different lines in the survey."
2934
},
3035
"line_id": {
31-
"group": "Data",
36+
"group": "Survey",
3237
"main": true,
3338
"min": 1,
3439
"label": "Line number",
3540
"value": 1,
3641
"optional": true,
3742
"enabled": false,
43+
"dependency": "line_object",
44+
"dependencyType": "enabled",
3845
"tooltip": "Selects the line of data to be processed."
3946
},
4047
"potential_channel": {

simpeg_drivers-assets/uijson/induced_polarization_2d_forward.ui.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
},
2020
"line_object": {
2121
"association": "Cell",
22-
"dataType": "Referenced",
22+
"dataType": [
23+
"Integer",
24+
"Referenced"
25+
],
2326
"group": "Survey",
2427
"main": true,
2528
"label": "Line ID",
2629
"parent": "data_object",
2730
"value": "",
31+
"optional": true,
32+
"enabled": false,
2833
"tooltip": "Selects the data representing the different lines in the survey."
2934
},
3035
"line_id": {
@@ -35,6 +40,8 @@
3540
"value": 1,
3641
"optional": true,
3742
"enabled": false,
43+
"dependency": "line_object",
44+
"dependencyType": "enabled",
3845
"tooltip": "Selects the line of data to be processed."
3946
},
4047
"chargeability_channel_bool": true,

simpeg_drivers-assets/uijson/induced_polarization_2d_inversion.ui.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,29 @@
1919
},
2020
"line_object": {
2121
"association": "Cell",
22-
"dataType": "Referenced",
23-
"group": "Data",
22+
"dataType": [
23+
"Integer",
24+
"Referenced"
25+
],
26+
"group": "Survey",
2427
"main": true,
2528
"label": "Line ID",
2629
"parent": "data_object",
2730
"value": "",
31+
"optional": true,
32+
"enabled": false,
2833
"tooltip": "Selects the data representing the different lines in the survey."
2934
},
3035
"line_id": {
31-
"group": "Data",
36+
"group": "Survey",
3237
"main": true,
3338
"min": 1,
3439
"label": "Line number",
3540
"value": 1,
3641
"optional": true,
3742
"enabled": false,
43+
"dependency": "line_object",
44+
"dependencyType": "enabled",
3845
"tooltip": "Selects the line of data to be processed."
3946
},
4047
"chargeability_channel": {

simpeg_drivers/components/data.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
import numpy as np
1919
from geoh5py.objects import LargeLoopGroundTEMReceivers, PotentialElectrode
20-
from scipy.sparse import csgraph, csr_matrix
2120
from scipy.spatial import cKDTree
2221
from simpeg.electromagnetics.static.utils.static_utils import geometric_factor
2322

23+
from simpeg_drivers.utils.surveys import get_parts_from_electrodes
2424
from simpeg_drivers.utils.utils import drape_2_tensor
2525

2626
from .factories import (
@@ -140,19 +140,7 @@ def parts(self):
140140
Return parts indices from the entity.
141141
"""
142142
if isinstance(self.entity, PotentialElectrode):
143-
edge_array = csr_matrix(
144-
(
145-
np.ones(self.entity.n_cells * 2),
146-
(
147-
np.kron(self.entity.cells[:, 0], [1, 1]),
148-
self.entity.cells.flatten(),
149-
),
150-
),
151-
shape=(self.entity.n_vertices, self.entity.n_vertices),
152-
)
153-
154-
connections = csgraph.connected_components(edge_array)[1]
155-
return connections[self.entity.cells[:, 0]]
143+
return get_parts_from_electrodes(self.entity)
156144

157145
if isinstance(self.entity, LargeLoopGroundTEMReceivers):
158146
return self.entity.tx_id_property.values
@@ -360,7 +348,7 @@ def create_survey(self):
360348
survey.cells = self.entity.cells
361349

362350
if "2d" in self.params.inversion_type:
363-
survey.line_ids = self.entity.get_data("line_ids")[0].values[
351+
survey.line_ids = self.params.line_selection.line_object.values[
364352
survey_factory.sorting
365353
]
366354

@@ -398,11 +386,17 @@ def update_params(self, data_dict, uncert_dict):
398386
setattr(self.params, f"{comp}_uncertainty", uncert_dict[comp])
399387

400388
if getattr(self.params, "line_selection", None) is not None:
401-
new_line = self.params.line_selection.line_object.copy(
402-
parent=self.entity,
403-
values=self.params.line_selection.line_object.values[self.mask],
404-
)
405-
self.params.line_selection.line_object = new_line
389+
if self.params.line_selection.line_object is None:
390+
parts = get_parts_from_electrodes(self.entity)
391+
_, u_part = np.unique(parts, return_inverse=True)
392+
line_ids = self.entity.add_data({"Line IDs": {"values": u_part + 1}})
393+
else:
394+
line_ids = self.params.line_selection.line_object.copy(
395+
parent=self.entity,
396+
values=self.params.line_selection.line_object.values[self.mask],
397+
)
398+
399+
self.params.line_selection.line_object = line_ids
406400

407401
@property
408402
def survey(self):

simpeg_drivers/electricals/base_2d.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,17 @@
1212
from __future__ import annotations
1313

1414
import numpy as np
15-
from geoapps_utils.utils.locations import get_locations
16-
from geoapps_utils.utils.numerical import weighted_average
17-
from geoh5py.data import Data, IntegerData
18-
from geoh5py.groups import PropertyGroup
19-
from geoh5py.objects import DrapeModel, PotentialElectrode
15+
from geoh5py.data import IntegerData
16+
from geoh5py.objects import DrapeModel
2017
from geoh5py.shared.merging.drape_model import DrapeModelMerger
2118
from geoh5py.ui_json.ui_json import fetch_active_workspace
2219
from geoh5py.workspace import Workspace
2320

24-
from simpeg_drivers.components.data import InversionData
2521
from simpeg_drivers.components.meshes import InversionMesh
26-
from simpeg_drivers.components.topography import InversionTopography
27-
from simpeg_drivers.components.windows import InversionWindow
2822
from simpeg_drivers.driver import InversionDriver
29-
from simpeg_drivers.line_sweep.driver import LineSweepDriver
3023
from simpeg_drivers.options import (
31-
BaseForwardOptions,
32-
BaseInversionOptions,
3324
DrapeModelOptions,
34-
LineSelectionOptions,
3525
)
36-
from simpeg_drivers.utils.surveys import extract_dcip_survey
3726
from simpeg_drivers.utils.utils import get_drape_model
3827

3928

simpeg_drivers/electricals/direct_current/two_dimensions/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DC2DForwardOptions(BaseForwardOptions):
4747

4848
data_object: PotentialElectrode
4949
potential_channel_bool: bool = True
50-
line_selection: LineSelectionOptions
50+
line_selection: LineSelectionOptions = LineSelectionOptions()
5151
mesh: DrapeModel | None = None
5252
drape_model: DrapeModelOptions = DrapeModelOptions()
5353
models: ConductivityModelOptions
@@ -75,7 +75,7 @@ class DC2DInversionOptions(BaseInversionOptions):
7575
data_object: PotentialElectrode
7676
potential_channel: FloatData
7777
potential_uncertainty: float | FloatData | None = None
78-
line_selection: LineSelectionOptions
78+
line_selection: LineSelectionOptions = LineSelectionOptions()
7979
mesh: DrapeModel | None = None
8080
drape_model: DrapeModelOptions = DrapeModelOptions()
8181
models: ConductivityModelOptions

0 commit comments

Comments
 (0)