Skip to content

PR: Simplify Inversion Parameter inputs and outputs. #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: simpleem3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9617fd2
updating the .gitignore
burningsage Mar 19, 2024
db36ebb
commented out the two lines that pollute the output of the inversion …
burningsage Mar 19, 2024
c70014b
Merge branch 'log-spaced-thicknesses' of github.com:emerald-geomodell…
burningsage Apr 2, 2024
e4d07b6
Merge branch 'log-spaced-thicknesses' into Burningsage_less_prints
burningsage Apr 2, 2024
f25b073
Merge branch 'log-spaced-thicknesses' into Burningsage_less_prints
burningsage Apr 2, 2024
b8f46f4
Merge branch 'simpleem3' into Burningsage_less_prints
burningsage Jul 4, 2024
e8db3ee
cleaning up the import statements in dual.py
burningsage Aug 22, 2024
0f39add
adding properties to the inverison object to hide them from the gui
burningsage Aug 22, 2024
5d4fdea
set the first and last gates as properties for each channel that are …
burningsage Aug 23, 2024
f1a0653
Set transmitter and receiver orientations as properties based on the …
burningsage Aug 23, 2024
0efc2f3
starting to make the parameters for the inversion independent of mome…
burningsage Aug 27, 2024
b3991f9
correcting the indexing channels in the gex calls
burningsage Aug 27, 2024
c4ee5d3
update to the irls max iterations
burningsage Aug 27, 2024
110caa6
change the keys used to libaarhusxyz standard
burningsage Sep 4, 2024
b66c628
method call spelling error fix
burningsage Sep 4, 2024
b12f5e3
Merge remote-tracking branch 'origin/simpleem3' into Burningsage_less…
burningsage Sep 4, 2024
0cec45e
Merge remote-tracking branch 'origin/simpleem3' into Burningsage_less…
burningsage Dec 31, 2024
7f57b0e
formatting
burningsage Dec 31, 2024
39baf03
formatting
burningsage Dec 31, 2024
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ tutorials/13-joint_inversion/cross_gradient_data/*

# jupyter
*.ipynb
*.ipynb_checkpoints/
*.idea/

# results and testing files
*.obs
Expand Down
2 changes: 1 addition & 1 deletion SimPEG/electromagnetics/time_domain/simulation_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
try:
from pyMKL import mkl_set_num_threads
except Exception as e:
print("No MKL support: ", e)
# print("No MKL support: ", e)
mkl_set_num_threads = None


Expand Down
99 changes: 63 additions & 36 deletions SimPEG/electromagnetics/utils/static_instrument/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from matplotlib import pyplot as plt
from discretize import TensorMesh
import multiprocessing

from SimPEG import maps
from SimPEG.electromagnetics import time_domain as tdem
Expand Down Expand Up @@ -149,8 +150,9 @@ def times(self):
for times_full, times_filter
in zip(self.times_full, self.times_filter)]

startmodel__n_layer = 30
startmodel__n_layer : int = 30
"Number of layers in model discretization"

@property
def n_layer_used(self):
if "resistivity" in self.xyz.layer_data:
Expand All @@ -176,15 +178,26 @@ def data_uncert_array_culled(self):
return np.where(np.isnan(dobs), np.inf, self.data_uncert_array)

dipole_moments = [1]

uncertainties__std_data = 0.03
"Noise as a factor of data"
uncertainties__std_data_override = False
"If set to true, use the std_data value instead of data std:s from stacking"
uncertainties__noise_level_1ms = 1e-9
"Amplitude at 1ms, in V/m^2"
uncertainties__noise_exponent = -0.5
"Slope of noise floor, t^uncertainties__noise_exponent"

# uncertainties__std_data = 0.03
# "Noise as a factor of data"
@property
def uncertainties__std_data(self):
channel = 1
return self.gex.gex_dict[f'Channel{channel}']['UniformDataSTD']
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no references to gex in base.py


# uncertainties__std_data_override: bool = False
# "If set to true, use the std_data value instead of data std:s from stacking"
@property
def uncertainties__std_data_override(self):
channel = 1
return f"dbdt_std_ch{channel}gt" not in self.xyz.layer_data.keys()

uncertainties__noise_level_1ms : float = 1e-9
"Noise amplitude at 1e-3 seconds. Unit of value is V/m^2"
uncertainties__noise_exponent : float = -0.5
"Slope of noise-floor. Typically expressed as: t^uncertainties__noise_exponent"

@property
def uncert_array(self):
n_sounding = len(self.xyz.flightlines)
Expand All @@ -205,13 +218,13 @@ def uncert_array(self):

return np.where(np.isnan(self.data_array_nan), np.Inf, uncertainties)

startmodel__thicknesses_type: typing.Literal['logspaced', 'geometric', 'time'] = "logspaced"
startmodel__thicknesses_type : typing.Literal['logspaced', 'geometric', 'time'] = "logspaced"
"Type of model discretization"
startmodel__thicknesses_minimum_dz = 1
startmodel__thicknesses_minimum_dz : float = 1
"Thickness of thinnest layer if using 'logspaced' or 'geometric' discretization"
startmodel__top_depth_last_layer = 400
"Depth to the top of the last layer if using logspaced discretization"
startmodel__thicknesses_geomtric_factor = 1.15309
startmodel__top_depth_last_layer : float = 400
"Depth to the top of the last layer if using log-spaced discretization"
startmodel__thicknesses_geomtric_factor : float = 1.15309
"Ratio of one layer to the next if using geometric discretization"

def make_thicknesses(self):
Expand Down Expand Up @@ -255,13 +268,24 @@ def make_survey(self):

def n_param(self, thicknesses):
return (len(thicknesses)+1)*len(self.xyz.flightlines)

simulation__solver : typing.Literal['LU', 'pardiso'] = 'LU'
"Equation solver to use. Some solvers might require hardware support."
simulation__parallel = True
"Use multiple computation threads in parallel. Useful to set to false in a notebook for debugging."
simulation__n_cpu = 3
"Number of threads (roughly same as CPU cores) to use"

@property
def simulation__parallel(self):
return True
# simulation__parallel: bool = True
# "Use multiple computation threads in parallel. Useful to set to false in a notebook for debugging."

# FIXME!!! the simulation__n_cpu will need adjusted when we start to spin up dedicated machines for inversion
# like this property will basically be "choose your inversion machine"
@property
def simulation__n_cpu(self):
return multiprocessing.cpu_count()
# simulation__n_cpu = 3
# "Number of threads (roughly same as CPU cores) to use"

def make_simulation(self, survey, thicknesses):
if 'pardiso' in self.simulation__solver.lower():
print('Using Pardiso solver')
Expand Down Expand Up @@ -302,7 +326,7 @@ def make_misfit(self, thicknesses):
dmis.W = self.make_misfit_weights()
return dmis

startmodel__res=100.
startmodel__res : float = 100.
"Initial resistivity (ohmm)"
def make_startmodel(self, thicknesses):
startmodel=np.log(np.ones(self.n_param(thicknesses)) * 1/self.startmodel__res)
Expand All @@ -321,9 +345,9 @@ def make_startmodel(self, thicknesses):
# 5) line spacing (if 100m then alpha_s = 1e-4, if 400m then 6.3e-6)
# 6) geomean of the linespacing and sounding spacing: sqrt(line_space * sound_space)
# - 25m sounding spacing, 100m line spacing: h=50, alpha_s=4e-4
regularization__alpha_s = 1e-4
regularization__alpha_r = 1.
regularization__alpha_z = 1.
regularization__alpha_s : float = 1e-4
regularization__alpha_r : float = 1.
regularization__alpha_z : float = 1.

def make_regularization(self, thicknesses):
if False:
Expand Down Expand Up @@ -367,18 +391,19 @@ def make_regularization(self, thicknesses):
"Random seed for beta (regularization) schedule estimator"
directives__beta__beta0_ratio : float = 10.
"Start ratio for the beta (regularization) schedule estimator"
directives__beta__cooling_factor=2
directives__beta__cooling_factor : float = 2
"Cooling factor for the beta (regularization) schedule"
directives__beta__cooling_rate=1
directives__beta__cooling_rate : float = 1
"Initial cooling rate for the beta (regularization) schedule"
directives__irls__enable = False
"IRLS is used to generate a sparse model in addition to and l2 model"
directives__irls__max_iterations = 30
directives__irls__enable : bool = False
"IRLS is used to generate a sparse [sharp] model in addition to the l2 [smooth] model"
directives__irls__max_iterations : int = 30
"Maximum number of iterations (after l2 model has converged)"
directives__irls__minGNiter = 1
directives__irls__fix_Jmatrix = True
directives__irls__f_min_change = 1e-3
directives__irls__coolingRate = 1
# FIXME!!! fill out descriptions for the rest of the irls directives
directives__irls__minGNiter : int = 1
directives__irls__fix_Jmatrix : bool = True
directives__irls__f_min_change : float = 1e-3
directives__irls__coolingRate : float = 1
def make_directives(self):
if self.directives__beta__seed:
BetaEstimate = directives.BetaEstimate_ByEig(beta0_ratio=self.directives__beta__beta0_ratio,
Expand All @@ -405,9 +430,11 @@ def make_directives(self):

return dirs

optimizer__max_iter=40
"Maximum number of gauss newton iterations"
optimizer__max_iter_cg=20
optimizer__max_iter : int = 50
"Maximum number of inversion iterations"
optimizer__max_iter_cg : int = 20
"Maximum number of Inexact-Gauss-Newton iterations"

def make_optimizer(self):
return optimization.InexactGaussNewton(maxIter = self.optimizer__max_iter, maxIterCG=self.optimizer__max_iter_cg)

Expand Down
Loading