loop-interpolation 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- loop_interpolation/__init__.py +152 -0
- loop_interpolation/_builders.py +149 -0
- loop_interpolation/_constant_norm.py +232 -0
- loop_interpolation/_diagnostics.py +102 -0
- loop_interpolation/_discrete_fold_interpolator.py +242 -0
- loop_interpolation/_discrete_interpolator.py +1405 -0
- loop_interpolation/_fd_fold_interpolator.py +237 -0
- loop_interpolation/_finite_difference_interpolator.py +1348 -0
- loop_interpolation/_fold_event.py +185 -0
- loop_interpolation/_fold_norm_alignment.py +118 -0
- loop_interpolation/_fold_setup.py +39 -0
- loop_interpolation/_geological_interpolator.py +920 -0
- loop_interpolation/_interpolator_builder.py +251 -0
- loop_interpolation/_interpolator_factory.py +167 -0
- loop_interpolation/_interpolatortype.py +20 -0
- loop_interpolation/_operator.py +44 -0
- loop_interpolation/_p1interpolator.py +299 -0
- loop_interpolation/_p2interpolator.py +317 -0
- loop_interpolation/_regularisation.py +110 -0
- loop_interpolation/_solver_pipeline.py +138 -0
- loop_interpolation/_solver_strategy.py +218 -0
- loop_interpolation/_surfe_wrapper.py +211 -0
- loop_interpolation/_svariogram.py +133 -0
- loop_interpolation/_validation.py +604 -0
- loop_interpolation/constraints.py +473 -0
- loop_interpolation/fold_function/__init__.py +39 -0
- loop_interpolation/fold_function/_base_fold_rotation_angle.py +219 -0
- loop_interpolation/fold_function/_fourier_series_fold_rotation_angle.py +131 -0
- loop_interpolation/fold_function/_lambda_fold_rotation_angle.py +53 -0
- loop_interpolation/loopsolver/__init__.py +2 -0
- loop_interpolation/loopsolver/admm_constant_norm.py +118 -0
- loop_interpolation/loopsolver/admm_method.py +25 -0
- loop_interpolation/loopsolver/admm_solver.py +463 -0
- loop_interpolation/loopsolver/version.py +1 -0
- loop_interpolation-0.0.1.dist-info/METADATA +34 -0
- loop_interpolation-0.0.1.dist-info/RECORD +39 -0
- loop_interpolation-0.0.1.dist-info/WHEEL +5 -0
- loop_interpolation-0.0.1.dist-info/licenses/LICENSE +21 -0
- loop_interpolation-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Semi-variogram for estimating fold wavelengths from orientation data."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
from loop_common.logging import get_logger
|
|
6
|
+
|
|
7
|
+
logger = get_logger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def find_peaks_and_troughs(x: np.ndarray, y: np.ndarray) -> tuple[list, list]:
|
|
11
|
+
"""Return x/y positions of local maxima and minima using finite differences."""
|
|
12
|
+
if len(x) != len(y):
|
|
13
|
+
raise ValueError("x and y must have the same length")
|
|
14
|
+
pairsx: list = []
|
|
15
|
+
pairsy: list = []
|
|
16
|
+
for i in range(len(x)):
|
|
17
|
+
if i < 1 or i > len(x) - 2:
|
|
18
|
+
if not np.isnan(y[i]):
|
|
19
|
+
pairsx.append(x[i])
|
|
20
|
+
pairsy.append(y[i])
|
|
21
|
+
continue
|
|
22
|
+
if np.isnan(y[i - 1]) or np.isnan(y[i]) or np.isnan(y[i + 1]):
|
|
23
|
+
continue
|
|
24
|
+
left_grad = (y[i - 1] - y[i]) / (x[i - 1] - x[i])
|
|
25
|
+
right_grad = (y[i] - y[i + 1]) / (x[i] - x[i + 1])
|
|
26
|
+
if np.sign(left_grad) != np.sign(right_grad):
|
|
27
|
+
pairsx.append(x[i])
|
|
28
|
+
pairsy.append(y[i])
|
|
29
|
+
return pairsx, pairsy
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SVariogram:
|
|
33
|
+
"""Experimental semi-variogram used to estimate fold wavelengths."""
|
|
34
|
+
|
|
35
|
+
def __init__(self, xdata: np.ndarray, ydata: np.ndarray):
|
|
36
|
+
self.xdata = np.asarray(xdata)
|
|
37
|
+
self.ydata = np.asarray(ydata)
|
|
38
|
+
mask = np.logical_or(np.isnan(self.xdata), np.isnan(self.ydata))
|
|
39
|
+
self.xdata = self.xdata[~mask]
|
|
40
|
+
self.ydata = self.ydata[~mask]
|
|
41
|
+
self.dist = np.abs(self.xdata[:, None] - self.xdata[None, :])
|
|
42
|
+
self.variance_matrix = (self.ydata[:, None] - self.ydata[None, :]) ** 2
|
|
43
|
+
self.lags: np.ndarray | None = None
|
|
44
|
+
self.variogram: np.ndarray | None = None
|
|
45
|
+
self.wavelength_guesses: list = []
|
|
46
|
+
|
|
47
|
+
def initialise_lags(self, step: float | None = None, nsteps: int | None = None):
|
|
48
|
+
if nsteps is not None and step is not None:
|
|
49
|
+
self.lags = np.arange(step / 2.0, nsteps * step, step)
|
|
50
|
+
elif step is not None:
|
|
51
|
+
nsteps = int(np.ceil((np.nanmax(self.xdata) - np.nanmin(self.xdata)) / step))
|
|
52
|
+
self.lags = np.arange(step / 2.0, nsteps * step, step)
|
|
53
|
+
|
|
54
|
+
if self.lags is None:
|
|
55
|
+
d = np.copy(self.dist)
|
|
56
|
+
d[d == 0] = np.nan
|
|
57
|
+
step = np.nanmean(np.nanmin(d, axis=1)) * 4.0
|
|
58
|
+
nsteps = int(np.ceil((np.nanmax(self.xdata) - np.nanmin(self.xdata)) / step))
|
|
59
|
+
if nsteps > 200:
|
|
60
|
+
logger.warning(f"Variogram has too many steps: {nsteps}, capping at 200")
|
|
61
|
+
maximum = step * nsteps
|
|
62
|
+
nsteps = 200
|
|
63
|
+
step = maximum / nsteps
|
|
64
|
+
self.lags = np.arange(step / 2.0, nsteps * step, step)
|
|
65
|
+
|
|
66
|
+
def calc_semivariogram(
|
|
67
|
+
self,
|
|
68
|
+
step: float | None = None,
|
|
69
|
+
nsteps: int | None = None,
|
|
70
|
+
lags: np.ndarray | None = None,
|
|
71
|
+
):
|
|
72
|
+
if lags is not None:
|
|
73
|
+
self.lags = lags
|
|
74
|
+
self.initialise_lags(step, nsteps)
|
|
75
|
+
if self.lags is None:
|
|
76
|
+
raise ValueError(
|
|
77
|
+
"Cannot determine variogram step size; specify step or nsteps."
|
|
78
|
+
)
|
|
79
|
+
tol = self.lags[1] - self.lags[0]
|
|
80
|
+
self.variogram = np.full(self.lags.shape, np.nan)
|
|
81
|
+
npairs = np.zeros(self.lags.shape)
|
|
82
|
+
for i in range(len(self.lags)):
|
|
83
|
+
logic = (self.dist > self.lags[i] - tol / 2.0) & (
|
|
84
|
+
self.dist < self.lags[i] + tol / 2.0
|
|
85
|
+
)
|
|
86
|
+
npairs[i] = np.sum(logic)
|
|
87
|
+
if npairs[i] > 0:
|
|
88
|
+
self.variogram[i] = np.mean(self.variance_matrix[logic])
|
|
89
|
+
return self.lags, self.variogram, npairs
|
|
90
|
+
|
|
91
|
+
def find_wavelengths(
|
|
92
|
+
self,
|
|
93
|
+
step: float | None = None,
|
|
94
|
+
nsteps: int | None = None,
|
|
95
|
+
lags: np.ndarray | None = None,
|
|
96
|
+
) -> list:
|
|
97
|
+
h, var, _npairs = self.calc_semivariogram(step=step, nsteps=nsteps, lags=lags)
|
|
98
|
+
px, py = find_peaks_and_troughs(h, var)
|
|
99
|
+
|
|
100
|
+
averagex: list = []
|
|
101
|
+
averagey: list = []
|
|
102
|
+
for i in range(len(px) - 1):
|
|
103
|
+
averagex.append((px[i] + px[i + 1]) / 2.0)
|
|
104
|
+
averagey.append((py[i] + py[i + 1]) / 2.0)
|
|
105
|
+
|
|
106
|
+
res = find_peaks_and_troughs(np.array(averagex), np.array(averagey))
|
|
107
|
+
px2, py2 = res
|
|
108
|
+
|
|
109
|
+
wl1 = 0.0
|
|
110
|
+
wl1py = 0.0
|
|
111
|
+
for i in range(len(px)):
|
|
112
|
+
if 0 < i < len(px) - 1 and py[i] > 10 and py[i - 1] < py[i] * 0.7 and py[i + 1] < py[i] * 0.7:
|
|
113
|
+
wl1 = px[i]
|
|
114
|
+
if wl1 > 0.0:
|
|
115
|
+
wl1py = py[i]
|
|
116
|
+
break
|
|
117
|
+
|
|
118
|
+
wl2 = 0.0
|
|
119
|
+
for i in range(len(px2)):
|
|
120
|
+
if 0 < i < len(px2) - 1 and py2[i - 1] < py2[i] * 0.90 and py2[i + 1] < py2[i] * 0.90:
|
|
121
|
+
wl2 = px2[i]
|
|
122
|
+
if wl2 > 0.0 and wl2 > wl1 * 2 and wl1py < py2[i]:
|
|
123
|
+
break
|
|
124
|
+
|
|
125
|
+
if wl1 == 0.0 and wl2 == 0.0:
|
|
126
|
+
logger.warning("Could not auto-estimate wavelength; using 2× data range")
|
|
127
|
+
self.wavelength_guesses = [2 * (np.max(self.xdata) - np.min(self.xdata)), 0.0]
|
|
128
|
+
return self.wavelength_guesses
|
|
129
|
+
if np.isclose(wl1, 0.0):
|
|
130
|
+
self.wavelength_guesses = [wl2 * 2.0, 0.0]
|
|
131
|
+
return [wl2 * 2.0]
|
|
132
|
+
self.wavelength_guesses = [wl1 * 2.0, wl2 * 2.0]
|
|
133
|
+
return self.wavelength_guesses
|