Skip to content

Commit 2dbc29e

Browse files
author
Lachlan Grose
committed
fix: minor fix to variogram saving wavelength guess as attribute
can access wavelength guess after model has been built for debugging
1 parent e62fdb9 commit 2dbc29e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

LoopStructural/interpolators/_discrete_fold_interpolator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,5 @@ def add_fold_constraints(
250250
B = np.zeros(A.shape[0])
251251
idc = np.array(idc[:ncons, :])
252252
self.add_constraints_to_least_squares(
253-
A, B, fold_regularisation[1], idc, name="fold regularisation 3"
253+
A, B, fold_regularisation[2], idc, name="fold regularisation 3"
254254
)

LoopStructural/modelling/fold/svariogram.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, xdata, ydata):
6060
self.variance_matrix = (self.ydata[:, None] - self.ydata[None, :]) ** 2
6161
self.lags = None
6262
self.variogram = None
63-
63+
self.wavelength_guess = [None, None]
6464
def calc_semivariogram(self, lag=None, nlag=None, lags=None):
6565
"""
6666
Calculate a semi-variogram for the x and y data for this object.
@@ -113,6 +113,11 @@ def calc_semivariogram(self, lag=None, nlag=None, lags=None):
113113
step = np.nanmean(np.nanmin(d, axis=1)) * 4.0
114114
# find number of steps to cover range in data
115115
nstep = int(np.ceil((np.nanmax(self.xdata) - np.nanmin(self.xdata)) / step))
116+
if nstep > 200:
117+
logger.warning(f'Variogram has too many steps: {nstep}, using 200')
118+
maximum = step*nstep
119+
nstep = 200
120+
step = maximum/nstep
116121
self.lags = np.arange(step / 2.0, nstep * step, step)
117122
logger.info(
118123
f"Using average minimum nearest neighbour distance as lag distance size {step} and using {nstep} lags"
@@ -176,8 +181,11 @@ def find_wavelengths(self, **kwargs):
176181
if wl2 > 0.0 and wl2 > wl1 * 2 and wl1py < py2[i]:
177182
break
178183
if wl1 == 0.0 and wl2 == 0.0:
179-
return 2 * (np.max(self.xdata) - np.min(self.xdata)), 0.0
184+
self.wavelength_guess = [2 * (np.max(self.xdata) - np.min(self.xdata)), 0.0]
185+
return self.wavelength_guess
180186
if np.isclose(wl1, 0.0):
181-
return np.array([wl2 * 2.0, wl1 * 2.0])
187+
self.wavelength_guess = np.array([wl2 * 2.0, wl1 * 2.0])
188+
return self.wavelength_guess
182189
# wavelength is 2x the peak on the curve
183-
return np.array([wl1 * 2.0, wl2 * 2.0])
190+
self.wavelength_guess = np.array([wl1 * 2.0, wl2 * 2.0])
191+
return self.wavelength_guess

0 commit comments

Comments
 (0)