@@ -53,6 +53,7 @@ def __init__(self, mt_dataframe=None, **kwargs):
53
53
self .rho_initial = 100
54
54
self .rho_reference = 100
55
55
self .output_dict = None
56
+ self .max_iterations = 40
56
57
57
58
for key , value in kwargs .items ():
58
59
setattr (self , key , value )
@@ -192,12 +193,35 @@ def cull_from_difference(self, sub_df, max_diff_res=1.0, max_diff_phase=10):
192
193
np .where (np .log10 (abs (np .diff (sub_df .res ))) > max_diff_res )[0 ] + 1
193
194
] = 0
194
195
195
- self . _sub_df = sub_df .loc [(sub_df != 0 ).all (axis = 1 )]
196
+ return sub_df .loc [(sub_df != 0 ).all (axis = 1 )]
196
197
197
- def cull_from_interpolated (
198
- self ,
199
- ):
200
- pass
198
+ def cull_from_interpolated (self , sub_df , tolerance = 0.1 , s_factor = 2 ):
199
+ """
200
+ create a cubic spline as a smooth version of the data and then
201
+ find points a certain distance away to remove.
202
+
203
+ :param : DESCRIPTION
204
+ :type : TYPE
205
+ :return: DESCRIPTION
206
+ :rtype: TYPE
207
+
208
+ """
209
+
210
+ from scipy import interpolate
211
+
212
+ spline_res = interpolate .splrep (
213
+ sub_df .period ,
214
+ sub_df .resistivity ,
215
+ s = s_factor * len (sub_df .period ),
216
+ )
217
+
218
+ bad_res = np .where (
219
+ abs (
220
+ interpolate .splev (sub_df .period , spline_res )
221
+ - sub_df .resistivity
222
+ )
223
+ > tolerance
224
+ )
201
225
202
226
def cull_from_model (self , iteration ):
203
227
"""
@@ -244,7 +268,7 @@ def run_fixed_layer_inversion(
244
268
245
269
# Cull the data
246
270
if cull_from_difference :
247
- self .cull_from_difference (self ._sub_df )
271
+ self ._sub_df = self . cull_from_difference (self ._sub_df )
248
272
249
273
source_list = []
250
274
for freq in self .frequencies :
@@ -316,7 +340,7 @@ def run_fixed_layer_inversion(
316
340
reg .norms = [p_s , p_z ]
317
341
# Reach target misfit for L2 solution, then use IRLS until model stops changing.
318
342
IRLS = directives .Update_IRLS (
319
- max_irls_iterations = 40 , minGNiter = 1 , f_min_change = 1e-5
343
+ max_irls_iterations = maxIter , minGNiter = 1 , f_min_change = 1e-5
320
344
)
321
345
322
346
# The directives are defined as a list.
0 commit comments