Skip to content

Commit

Permalink
fix: minor fix to variogram saving wavelength guess as attribute
Browse files Browse the repository at this point in the history
can access wavelength guess after model has been built for debugging
  • Loading branch information
Lachlan Grose committed Feb 21, 2022
1 parent e62fdb9 commit 2dbc29e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,5 @@ def add_fold_constraints(
B = np.zeros(A.shape[0])
idc = np.array(idc[:ncons, :])
self.add_constraints_to_least_squares(
A, B, fold_regularisation[1], idc, name="fold regularisation 3"
A, B, fold_regularisation[2], idc, name="fold regularisation 3"
)
16 changes: 12 additions & 4 deletions LoopStructural/modelling/fold/svariogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, xdata, ydata):
self.variance_matrix = (self.ydata[:, None] - self.ydata[None, :]) ** 2
self.lags = None
self.variogram = None

self.wavelength_guess = [None, None]
def calc_semivariogram(self, lag=None, nlag=None, lags=None):
"""
Calculate a semi-variogram for the x and y data for this object.
Expand Down Expand Up @@ -113,6 +113,11 @@ def calc_semivariogram(self, lag=None, nlag=None, lags=None):
step = np.nanmean(np.nanmin(d, axis=1)) * 4.0
# find number of steps to cover range in data
nstep = int(np.ceil((np.nanmax(self.xdata) - np.nanmin(self.xdata)) / step))
if nstep > 200:
logger.warning(f'Variogram has too many steps: {nstep}, using 200')
maximum = step*nstep
nstep = 200
step = maximum/nstep
self.lags = np.arange(step / 2.0, nstep * step, step)
logger.info(
f"Using average minimum nearest neighbour distance as lag distance size {step} and using {nstep} lags"
Expand Down Expand Up @@ -176,8 +181,11 @@ def find_wavelengths(self, **kwargs):
if wl2 > 0.0 and wl2 > wl1 * 2 and wl1py < py2[i]:
break
if wl1 == 0.0 and wl2 == 0.0:
return 2 * (np.max(self.xdata) - np.min(self.xdata)), 0.0
self.wavelength_guess = [2 * (np.max(self.xdata) - np.min(self.xdata)), 0.0]
return self.wavelength_guess
if np.isclose(wl1, 0.0):
return np.array([wl2 * 2.0, wl1 * 2.0])
self.wavelength_guess = np.array([wl2 * 2.0, wl1 * 2.0])
return self.wavelength_guess
# wavelength is 2x the peak on the curve
return np.array([wl1 * 2.0, wl2 * 2.0])
self.wavelength_guess = np.array([wl1 * 2.0, wl2 * 2.0])
return self.wavelength_guess

0 comments on commit 2dbc29e

Please sign in to comment.