Skip to content

Commit d987725

Browse files
committed
Merge branch 'develop' into GEOPY-2770
# Conflicts: # simpeg_drivers/plate_simulation/driver.py
2 parents c601508 + 191af70 commit d987725

24 files changed

Lines changed: 387 additions & 188 deletions

simpeg_drivers-assets/uijson/tdem1d_forward.ui.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"z_channel_bool": {
4040
"group": "Survey",
4141
"main": true,
42-
"label": "Z component",
42+
"label": "Vertical",
43+
"tooltip": "Vertical (w) component of the magnetic data",
4344
"value": true
4445
},
4546
"u_cell_size": {

simpeg_drivers-assets/uijson/tdem1d_inversion.ui.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"group": "Data",
4646
"dataGroupType": "Multi-element",
4747
"main": true,
48-
"label": "z-component",
48+
"label": "Vertical",
49+
"tooltip": "Vertical (w) component of the magnetic data",
4950
"parent": "data_object",
5051
"optional": true,
5152
"enabled": true,

simpeg_drivers-assets/uijson/tdem_forward.ui.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,25 @@
5858
],
5959
"value": "dB/dt (T/s)"
6060
},
61-
"z_channel_bool": {
61+
"vertical_channel_bool": {
6262
"group": "Survey",
6363
"main": true,
64-
"label": "Z component",
64+
"label": "Vertical",
65+
"tooltip": "Vertical (w) component of the magnetic data.\nPositive up along the z-axis if no receiver orientation provided",
6566
"value": true
6667
},
67-
"x_channel_bool": {
68+
"inline_channel_bool": {
6869
"group": "Survey",
6970
"main": true,
70-
"label": "X component",
71+
"label": "In-line",
72+
"tooltip": "In-line (u) component of the magnetic data.\nPositive towards North if no receiver orientation provided",
7173
"value": true
7274
},
73-
"y_channel_bool": {
75+
"crossline_channel_bool": {
7476
"group": "Survey",
7577
"main": true,
76-
"label": "Y component",
78+
"label": "Cross-line",
79+
"tooltip": "Cross-line (v) component of the magnetic data.\nPositive towards East if no receiver orientation provided",
7780
"value": true
7881
},
7982
"mesh": {

simpeg_drivers-assets/uijson/tdem_inversion.ui.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
],
5959
"value": "dB/dt (T/s)"
6060
},
61-
"z_channel": {
61+
"vertical_channel": {
6262
"association": [
6363
"Cell",
6464
"Vertex"
@@ -67,13 +67,14 @@
6767
"group": "Data",
6868
"dataGroupType": "Multi-element",
6969
"main": true,
70-
"label": "z-component",
70+
"label": "Vertical",
7171
"parent": "data_object",
72+
"tooltip": "Vertical (w) component of the magnetic data.\nPositive up along the z-axis if no receiver orientation provided",
7273
"optional": true,
7374
"enabled": true,
7475
"value": ""
7576
},
76-
"z_uncertainty": {
77+
"vertical_uncertainty": {
7778
"association": [
7879
"Cell",
7980
"Vertex"
@@ -84,11 +85,11 @@
8485
"main": true,
8586
"label": "Uncertainty",
8687
"parent": "data_object",
87-
"dependency": "z_channel",
88+
"dependency": "vertical_channel",
8889
"dependencyType": "enabled",
8990
"value": ""
9091
},
91-
"x_channel": {
92+
"inline_channel": {
9293
"association": [
9394
"Cell",
9495
"Vertex"
@@ -97,13 +98,14 @@
9798
"group": "Data",
9899
"dataGroupType": "Multi-element",
99100
"main": true,
100-
"label": "x-component",
101+
"label": "In-line",
101102
"parent": "data_object",
103+
"tooltip": "In-line (u) component of the magnetic data.\nPositive towards North if no receiver orientation provided",
102104
"optional": true,
103105
"enabled": false,
104106
"value": ""
105107
},
106-
"x_uncertainty": {
108+
"inline_uncertainty": {
107109
"association": [
108110
"Cell",
109111
"Vertex"
@@ -114,11 +116,11 @@
114116
"main": true,
115117
"label": "Uncertainty",
116118
"parent": "data_object",
117-
"dependency": "x_channel",
119+
"dependency": "inline_channel",
118120
"dependencyType": "enabled",
119121
"value": ""
120122
},
121-
"y_channel": {
123+
"crossline_channel": {
122124
"association": [
123125
"Cell",
124126
"Vertex"
@@ -127,13 +129,14 @@
127129
"group": "Data",
128130
"dataGroupType": "Multi-element",
129131
"main": true,
130-
"label": "y-component",
132+
"label": "Cross-line",
133+
"tooltip": "Cross-line (v) component of the magnetic data.\nPositive towards East if no receiver orientation provided",
131134
"parent": "data_object",
132135
"optional": true,
133136
"enabled": false,
134137
"value": ""
135138
},
136-
"y_uncertainty": {
139+
"crossline_uncertainty": {
137140
"association": [
138141
"Cell",
139142
"Vertex"
@@ -144,7 +147,7 @@
144147
"main": true,
145148
"label": "Uncertainty",
146149
"parent": "data_object",
147-
"dependency": "y_channel",
150+
"dependency": "crossline_channel",
148151
"dependencyType": "enabled",
149152
"value": ""
150153
},

simpeg_drivers/components/data.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ def get_normalizations(self):
309309
"tdem" in self.params.inversion_type
310310
and "dB/dt" in self.params.data_units
311311
):
312-
if comp in ["x", "y", "z"]:
313-
normalizations[chan][comp] = -1
314-
normalizations[chan][comp] *= np.ones(self.mask.sum())
312+
normalizations[chan][comp] = np.full(self.mask.sum(), -1)
315313

316314
return normalizations
317315

simpeg_drivers/components/factories/receiver_factory.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
from simpeg_drivers.utils.regularization import direction_and_dip, get_cell_normals
3131

3232

33+
ORIENTATION_MAP = {
34+
"vertical": "z",
35+
"inline": "y",
36+
"crossline": "x",
37+
}
38+
39+
3340
class ReceiversFactory(SimPEGFactory):
3441
"""Build SimPEG receivers objects based on factory type."""
3542

@@ -150,14 +157,16 @@ def assemble_keyword_arguments(
150157

151158
if self.factory_type in ["fdem", "fdem 1d", "magnetotellurics", "tipper"]:
152159
comp = component.split("_")[0]
153-
kwargs["orientation"] = comp[0] if "fdem" in self.factory_type else comp[1:]
160+
kwargs["orientation"] = (
161+
ORIENTATION_MAP[comp] if "fdem" in self.factory_type else comp[1:]
162+
)
154163
kwargs["component"] = component.split("_")[1]
155164

156165
if self.factory_type in ["tipper"]:
157166
kwargs["orientation"] = kwargs["orientation"][::-1]
158167

159168
if "tdem" in self.factory_type:
160-
kwargs["orientation"] = component
169+
kwargs["orientation"] = ORIENTATION_MAP[component]
161170

162171
if self.factory_type == "fdem 1d":
163172
kwargs["data_type"] = "ppm"

simpeg_drivers/driver.py

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
from __future__ import annotations
1515

1616
from abc import abstractmethod, ABC
17-
import cProfile
18-
import pstats
1917

20-
import contextlib
2118
from copy import deepcopy
2219
import sys
2320
from datetime import datetime, timedelta
@@ -26,7 +23,7 @@
2623
from time import time
2724

2825
import numpy as np
29-
from dask.distributed import get_client, Client, LocalCluster, performance_report
26+
from dask.distributed import get_client, Client
3027

3128
from geoapps_utils.base import Driver, Options
3229
from geoapps_utils.run import load_ui_json_as_dict
@@ -74,7 +71,7 @@
7471
from simpeg_drivers.joint.options import BaseJointOptions
7572
from simpeg_drivers.utils.nested import tile_locations
7673
from simpeg_drivers.utils.regularization import cell_neighbors, set_rotated_operators
77-
from simpeg_drivers.utils.utils import validate_out_group
74+
from simpeg_drivers.utils.utils import validate_out_group, start_dask_run
7875

7976
mlogger = logging.getLogger("distributed")
8077
mlogger.setLevel(logging.WARNING)
@@ -500,47 +497,7 @@ def start_dask_run(
500497
:param n_workers: Number of workers to use.
501498
:param n_threads: Number of threads to use.
502499
"""
503-
ui_json = load_ui_json_as_dict(json_path)
504-
505-
n_workers = ui_json.get("n_workers", n_workers)
506-
n_threads = ui_json.get("n_threads", n_threads)
507-
save_report = ui_json.get("performance_report", False)
508-
509-
if (n_workers is not None and n_workers > 1) or n_threads is not None:
510-
cluster = LocalCluster(
511-
processes=True,
512-
n_workers=n_workers,
513-
threads_per_worker=n_threads,
514-
)
515-
else:
516-
cluster = None
517-
518-
profiler = cProfile.Profile()
519-
profiler.enable()
520-
521-
with (
522-
cluster.get_client()
523-
if cluster is not None
524-
else contextlib.nullcontext() as context_client
525-
):
526-
# Full run
527-
with (
528-
performance_report(filename=json_path.parent / "dask_profile.html")
529-
if (save_report and isinstance(context_client, Client))
530-
else contextlib.nullcontext()
531-
):
532-
cls.start(json_path)
533-
sys.stdout.close()
534-
535-
profiler.disable()
536-
537-
if save_report:
538-
with open(
539-
json_path.parent / "runtime_profile.txt", encoding="utf-8", mode="w"
540-
) as s:
541-
ps = pstats.Stats(profiler, stream=s)
542-
ps.sort_stats("cumulative")
543-
ps.print_stats()
500+
start_dask_run(cls, json_path, n_workers=n_workers, n_threads=n_threads)
544501

545502
@property
546503
def workers(self) -> list[tuple[str]]:

0 commit comments

Comments
 (0)