pitmap 0.0.0a1__tar.gz

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.
pitmap-0.0.0a1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Leonid Shpaner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: pitmap
3
+ Version: 0.0.0a1
4
+ Summary: Surface construction from scattered survey points for open-pit mine surveying: polygonal, sector IDW, polynomial, NURBS and kernel interpolators, with prism volumes.
5
+ Author: Leonid Shpaner
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/lshpaner/pitmap
8
+ Project-URL: Repository, https://github.com/lshpaner/pitmap
9
+ Keywords: mine surveying,interpolation,open-pit,NURBS,IDW,surface modeling
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: numpy>=1.24
18
+ Requires-Dist: scipy>=1.11
19
+ Provides-Extra: kernel
20
+ Requires-Dist: scikit-learn>=1.3; extra == "kernel"
21
+ Provides-Extra: nurbs
22
+ Requires-Dist: geomdl>=5.3; extra == "nurbs"
23
+ Provides-Extra: data
24
+ Requires-Dist: pandas>=2.0; extra == "data"
25
+ Requires-Dist: pyarrow>=14; extra == "data"
26
+ Requires-Dist: rasterio>=1.3; extra == "data"
27
+ Requires-Dist: typer>=0.9; extra == "data"
28
+ Provides-Extra: viz
29
+ Requires-Dist: matplotlib>=3.7; extra == "viz"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: black; extra == "dev"
33
+ Requires-Dist: nbstripout; extra == "dev"
34
+ Requires-Dist: jupyter; extra == "dev"
35
+ Requires-Dist: build; extra == "dev"
36
+ Requires-Dist: twine; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <img src="https://raw.githubusercontent.com/lshpaner/pitmap/main/docs/logo.svg" width="520" alt="pitmap">
40
+
41
+ [![PyPI](https://img.shields.io/pypi/v/pitmap.svg)](https://pypi.org/project/pitmap/)
42
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lshpaner/pitmap/blob/main/LICENSE)
43
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)
44
+
45
+ Surface construction from scattered survey points for open-pit mine surveying.
46
+
47
+ `pitmap` is a Python implementation of the surface-modeling methods used in
48
+ the automated geological and mine-surveying support system developed at the
49
+ State University of Economics and Technology (Kryvyi Rih, Ukraine), with a
50
+ kernel-based interpolator added for comparison. All methods share one
51
+ `fit` / `predict` interface.
52
+
53
+ > **Status:** pre-alpha. The API will change. Nothing here is ready for
54
+ > production use yet.
55
+
56
+ ## Methods
57
+
58
+ | Class | Method | Source |
59
+ |---|---|---|
60
+ | `NearestRegion` | Polygonal (nearest-region / Thiessen) surface | Zelensky & Lysenko (2023) |
61
+ | `SectorIDW` | Sector-constrained inverse distance weighting, optional anisotropy via critical correlation radius | Zelenskyi et al. (2020); Zelensky & Donchenko (2025) |
62
+ | `PolynomialSurface` | Bivariate least-squares polynomial up to degree 5, with adequacy statistics | Zelenskyi et al. (2020); Zelensky & Donchenko (2025) |
63
+ | `NURBSSurface` | Tensor-product NURBS smoother over an interpolated grid | Zelensky & Lysenko (2023) |
64
+ | `KernelSurface` | SVR / Gaussian process with the critical correlation radius as default length scale | this package |
65
+
66
+ Utilities: `acf_radius()` (critical correlation radius from the spatial
67
+ autocorrelation function) and `prism_volume()` (volume between surfaces by
68
+ unit prisms).
69
+
70
+ Implemented so far: `NearestRegion`, `SectorIDW`.
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ pip install pitmap
76
+ ```
77
+
78
+ ## Usage
79
+
80
+ ```python
81
+ import numpy as np
82
+ from pitmap import NearestRegion
83
+
84
+ xy = np.array([[0.0, 0.0], [10.0, 0.0], [0.0, 10.0], [10.0, 10.0]])
85
+ z = np.array([100.0, 102.0, 101.0, 103.0])
86
+
87
+ model = NearestRegion().fit(xy, z)
88
+ model.predict(np.array([[2.0, 1.0], [9.0, 9.0]]))
89
+ # array([100., 103.])
90
+ ```
91
+
92
+ ## Repository layout
93
+
94
+ ```
95
+ pitmap/ package; core/ holds the interpolators
96
+ data_gen.py fetch a raw DEM tile -> data/raw (Parquet, optional CSV)
97
+ preprocessing.py subsample to sparse survey points -> data/processed
98
+ notebooks/ analysis; outputs stripped before commit
99
+ data/ gitignored
100
+ ```
101
+
102
+ ## Development
103
+
104
+ ```bash
105
+ conda activate conda_312
106
+ make create_venv && source venv_pitmap/bin/activate
107
+ make requirements
108
+ make test
109
+ make help # list all targets
110
+ ```
111
+
112
+ ## References
113
+
114
+ Zelenskyi, O., Lysenko, V., Alekseyev, M., & Vlasov, V. (2020). Modeling of
115
+ the earth's surface subsidence during its undermining by stoping in coal mines.
116
+ *Naukovyi Visnyk Natsionalnoho Hirnychoho Universytetu*, (6), 121–127.
117
+ https://doi.org/10.33271/nvngu/2020-6/121
118
+
119
+ Zelensky, O., & Lysenko, V. (2023). Construction surface using desktop and
120
+ mobile applications. *Economics and Technical Engineering*, 1(1), 87–102.
121
+ https://doi.org/10.62911/ete.2023.01.01.07
122
+
123
+ Zelensky, O., & Donchenko, O. (2025). Research and application of polynomial
124
+ models in the development of an automated geological and mine surveying
125
+ support system for open-pit mining. *Mining Journal of Kryvyi Rih National
126
+ University*, 59(1), 10–21. https://doi.org/10.31721/2306-5435-2025-1-10-21
127
+
128
+ ## License
129
+
130
+ MIT
@@ -0,0 +1,92 @@
1
+ <img src="https://raw.githubusercontent.com/lshpaner/pitmap/main/docs/logo.svg" width="520" alt="pitmap">
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/pitmap.svg)](https://pypi.org/project/pitmap/)
4
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lshpaner/pitmap/blob/main/LICENSE)
5
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)
6
+
7
+ Surface construction from scattered survey points for open-pit mine surveying.
8
+
9
+ `pitmap` is a Python implementation of the surface-modeling methods used in
10
+ the automated geological and mine-surveying support system developed at the
11
+ State University of Economics and Technology (Kryvyi Rih, Ukraine), with a
12
+ kernel-based interpolator added for comparison. All methods share one
13
+ `fit` / `predict` interface.
14
+
15
+ > **Status:** pre-alpha. The API will change. Nothing here is ready for
16
+ > production use yet.
17
+
18
+ ## Methods
19
+
20
+ | Class | Method | Source |
21
+ |---|---|---|
22
+ | `NearestRegion` | Polygonal (nearest-region / Thiessen) surface | Zelensky & Lysenko (2023) |
23
+ | `SectorIDW` | Sector-constrained inverse distance weighting, optional anisotropy via critical correlation radius | Zelenskyi et al. (2020); Zelensky & Donchenko (2025) |
24
+ | `PolynomialSurface` | Bivariate least-squares polynomial up to degree 5, with adequacy statistics | Zelenskyi et al. (2020); Zelensky & Donchenko (2025) |
25
+ | `NURBSSurface` | Tensor-product NURBS smoother over an interpolated grid | Zelensky & Lysenko (2023) |
26
+ | `KernelSurface` | SVR / Gaussian process with the critical correlation radius as default length scale | this package |
27
+
28
+ Utilities: `acf_radius()` (critical correlation radius from the spatial
29
+ autocorrelation function) and `prism_volume()` (volume between surfaces by
30
+ unit prisms).
31
+
32
+ Implemented so far: `NearestRegion`, `SectorIDW`.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install pitmap
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ import numpy as np
44
+ from pitmap import NearestRegion
45
+
46
+ xy = np.array([[0.0, 0.0], [10.0, 0.0], [0.0, 10.0], [10.0, 10.0]])
47
+ z = np.array([100.0, 102.0, 101.0, 103.0])
48
+
49
+ model = NearestRegion().fit(xy, z)
50
+ model.predict(np.array([[2.0, 1.0], [9.0, 9.0]]))
51
+ # array([100., 103.])
52
+ ```
53
+
54
+ ## Repository layout
55
+
56
+ ```
57
+ pitmap/ package; core/ holds the interpolators
58
+ data_gen.py fetch a raw DEM tile -> data/raw (Parquet, optional CSV)
59
+ preprocessing.py subsample to sparse survey points -> data/processed
60
+ notebooks/ analysis; outputs stripped before commit
61
+ data/ gitignored
62
+ ```
63
+
64
+ ## Development
65
+
66
+ ```bash
67
+ conda activate conda_312
68
+ make create_venv && source venv_pitmap/bin/activate
69
+ make requirements
70
+ make test
71
+ make help # list all targets
72
+ ```
73
+
74
+ ## References
75
+
76
+ Zelenskyi, O., Lysenko, V., Alekseyev, M., & Vlasov, V. (2020). Modeling of
77
+ the earth's surface subsidence during its undermining by stoping in coal mines.
78
+ *Naukovyi Visnyk Natsionalnoho Hirnychoho Universytetu*, (6), 121–127.
79
+ https://doi.org/10.33271/nvngu/2020-6/121
80
+
81
+ Zelensky, O., & Lysenko, V. (2023). Construction surface using desktop and
82
+ mobile applications. *Economics and Technical Engineering*, 1(1), 87–102.
83
+ https://doi.org/10.62911/ete.2023.01.01.07
84
+
85
+ Zelensky, O., & Donchenko, O. (2025). Research and application of polynomial
86
+ models in the development of an automated geological and mine surveying
87
+ support system for open-pit mining. *Mining Journal of Kryvyi Rih National
88
+ University*, 59(1), 10–21. https://doi.org/10.31721/2306-5435-2025-1-10-21
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,6 @@
1
+ """pitmap: surface construction from scattered survey points."""
2
+
3
+ from pitmap.core.interpolation import NearestRegion, SectorIDW
4
+
5
+ __all__ = ["NearestRegion", "SectorIDW"]
6
+ __version__ = "0.0.0a1"
File without changes
@@ -0,0 +1,160 @@
1
+ """Interpolators that share one fit/predict interface.
2
+
3
+ Each class takes survey points as an (n, 2) array of x, y coordinates and an
4
+ (n,) array of elevations (or any indicator such as ore grade) z, and predicts
5
+ z at new x, y locations.
6
+
7
+ Methods follow the automated geological and mine-surveying support system
8
+ described in Zelenskyi et al. (2020), Zelensky & Lysenko (2023), and
9
+ Zelensky & Donchenko (2025).
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import numpy as np
15
+ from scipy.interpolate import NearestNDInterpolator
16
+ from scipy.spatial import cKDTree
17
+
18
+
19
+ def _check_xy_z(xy: np.ndarray, z: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
20
+ xy = np.asarray(xy, dtype=float)
21
+ z = np.asarray(z, dtype=float)
22
+ if xy.ndim != 2 or xy.shape[1] != 2:
23
+ raise ValueError("xy must have shape (n, 2)")
24
+ if z.shape != (xy.shape[0],):
25
+ raise ValueError("z must have shape (n,)")
26
+ return xy, z
27
+
28
+
29
+ def _check_query(xy: np.ndarray) -> np.ndarray:
30
+ xy = np.asarray(xy, dtype=float)
31
+ if xy.ndim != 2 or xy.shape[1] != 2:
32
+ raise ValueError("query xy must have shape (m, 2)")
33
+ return xy
34
+
35
+
36
+ class NearestRegion:
37
+ """Polygonal (nearest-region / Thiessen polygon) surface.
38
+
39
+ Every location takes the elevation of its closest survey point, so the
40
+ surface is piecewise constant over the Voronoi cell of each point. This is
41
+ the classical polygonal method of mine surveying and reserve estimation
42
+ (Zelensky & Lysenko, 2023, section 4).
43
+ """
44
+
45
+ def __init__(self) -> None:
46
+ self._interp: NearestNDInterpolator | None = None
47
+
48
+ def fit(self, xy: np.ndarray, z: np.ndarray) -> "NearestRegion":
49
+ xy, z = _check_xy_z(xy, z)
50
+ self._interp = NearestNDInterpolator(xy, z)
51
+ return self
52
+
53
+ def predict(self, xy: np.ndarray) -> np.ndarray:
54
+ if self._interp is None:
55
+ raise RuntimeError("call fit() before predict()")
56
+ xy = _check_query(xy)
57
+ return self._interp(xy[:, 0], xy[:, 1])
58
+
59
+
60
+ class SectorIDW:
61
+ """Sector-constrained inverse distance weighting.
62
+
63
+ The value at a query point is a weighted average of nearby survey points,
64
+ with weight 1 / d**power (Zelenskyi et al., 2020; Zelensky & Donchenko,
65
+ 2025, eq. 11). To stop a cluster of points on one side from dominating,
66
+ the search circle of the given radius is cut into ``n_sectors`` equal
67
+ angular sectors and only the single closest point in each sector is used
68
+ (2020 paper, Fig. 3). Query points with no survey point inside the radius
69
+ return NaN.
70
+
71
+ Parameters
72
+ ----------
73
+ radius : float
74
+ Search radius in the units of xy.
75
+ power : float, default 2.0
76
+ Distance exponent alpha. 2 is the usual choice.
77
+ n_sectors : int, default 8
78
+ Number of angular sectors around each query point.
79
+ anisotropy : tuple[float, float] or None
80
+ Critical correlation radius along x and along y, (rk_x, rk_y). When
81
+ given, distances are scaled by rk_max / rk_axis before weighting so a
82
+ point along the better-correlated axis counts as closer (Zelensky &
83
+ Donchenko, 2025, eq. 12-13). None means isotropic.
84
+ """
85
+
86
+ def __init__(
87
+ self,
88
+ radius: float,
89
+ power: float = 2.0,
90
+ n_sectors: int = 8,
91
+ anisotropy: tuple[float, float] | None = None,
92
+ ) -> None:
93
+ if radius <= 0:
94
+ raise ValueError("radius must be positive")
95
+ if n_sectors < 1:
96
+ raise ValueError("n_sectors must be at least 1")
97
+ if anisotropy is not None:
98
+ rk_x, rk_y = anisotropy
99
+ if rk_x <= 0 or rk_y <= 0:
100
+ raise ValueError("anisotropy radii must be positive")
101
+ self.radius = float(radius)
102
+ self.power = float(power)
103
+ self.n_sectors = int(n_sectors)
104
+ self.anisotropy = anisotropy
105
+ self._xy: np.ndarray | None = None
106
+ self._z: np.ndarray | None = None
107
+ self._tree: cKDTree | None = None
108
+
109
+ # scale factors that stretch the axis with the shorter correlation radius
110
+ def _axis_scale(self) -> np.ndarray:
111
+ if self.anisotropy is None:
112
+ return np.ones(2)
113
+ rk = np.asarray(self.anisotropy, dtype=float)
114
+ return rk.max() / rk
115
+
116
+ def fit(self, xy: np.ndarray, z: np.ndarray) -> "SectorIDW":
117
+ xy, z = _check_xy_z(xy, z)
118
+ self._xy = xy
119
+ self._z = z
120
+ # the tree is built on scaled coordinates so the radius search already
121
+ # respects anisotropy
122
+ self._tree = cKDTree(xy * self._axis_scale())
123
+ return self
124
+
125
+ def _predict_one(self, q: np.ndarray) -> float:
126
+ assert self._tree is not None and self._xy is not None and self._z is not None
127
+ scale = self._axis_scale()
128
+ q_scaled = q * scale
129
+ idx = self._tree.query_ball_point(q_scaled, self.radius)
130
+ if len(idx) == 0:
131
+ return np.nan
132
+ idx = np.asarray(idx)
133
+
134
+ delta = self._xy[idx] * scale - q_scaled # (k, 2) offsets, scaled
135
+ d = np.hypot(delta[:, 0], delta[:, 1])
136
+
137
+ # a survey point sitting exactly on the query location wins outright
138
+ hit = np.where(d == 0.0)[0]
139
+ if hit.size:
140
+ return float(self._z[idx[hit[0]]])
141
+
142
+ # assign each candidate to an angular sector and keep the closest per sector
143
+ angle = np.arctan2(delta[:, 1], delta[:, 0]) # (-pi, pi]
144
+ sector = np.floor((angle + np.pi) / (2.0 * np.pi / self.n_sectors)).astype(int)
145
+ sector = np.clip(sector, 0, self.n_sectors - 1)
146
+
147
+ keep: list[int] = []
148
+ for s in np.unique(sector):
149
+ members = np.where(sector == s)[0]
150
+ keep.append(members[np.argmin(d[members])])
151
+ keep_arr = np.asarray(keep)
152
+
153
+ w = d[keep_arr] ** (-self.power)
154
+ return float(np.sum(w * self._z[idx[keep_arr]]) / np.sum(w))
155
+
156
+ def predict(self, xy: np.ndarray) -> np.ndarray:
157
+ if self._tree is None:
158
+ raise RuntimeError("call fit() before predict()")
159
+ xy = _check_query(xy)
160
+ return np.array([self._predict_one(q) for q in xy])
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: pitmap
3
+ Version: 0.0.0a1
4
+ Summary: Surface construction from scattered survey points for open-pit mine surveying: polygonal, sector IDW, polynomial, NURBS and kernel interpolators, with prism volumes.
5
+ Author: Leonid Shpaner
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/lshpaner/pitmap
8
+ Project-URL: Repository, https://github.com/lshpaner/pitmap
9
+ Keywords: mine surveying,interpolation,open-pit,NURBS,IDW,surface modeling
10
+ Classifier: Development Status :: 2 - Pre-Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: numpy>=1.24
18
+ Requires-Dist: scipy>=1.11
19
+ Provides-Extra: kernel
20
+ Requires-Dist: scikit-learn>=1.3; extra == "kernel"
21
+ Provides-Extra: nurbs
22
+ Requires-Dist: geomdl>=5.3; extra == "nurbs"
23
+ Provides-Extra: data
24
+ Requires-Dist: pandas>=2.0; extra == "data"
25
+ Requires-Dist: pyarrow>=14; extra == "data"
26
+ Requires-Dist: rasterio>=1.3; extra == "data"
27
+ Requires-Dist: typer>=0.9; extra == "data"
28
+ Provides-Extra: viz
29
+ Requires-Dist: matplotlib>=3.7; extra == "viz"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: black; extra == "dev"
33
+ Requires-Dist: nbstripout; extra == "dev"
34
+ Requires-Dist: jupyter; extra == "dev"
35
+ Requires-Dist: build; extra == "dev"
36
+ Requires-Dist: twine; extra == "dev"
37
+ Dynamic: license-file
38
+
39
+ <img src="https://raw.githubusercontent.com/lshpaner/pitmap/main/docs/logo.svg" width="520" alt="pitmap">
40
+
41
+ [![PyPI](https://img.shields.io/pypi/v/pitmap.svg)](https://pypi.org/project/pitmap/)
42
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/lshpaner/pitmap/blob/main/LICENSE)
43
+ ![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)
44
+
45
+ Surface construction from scattered survey points for open-pit mine surveying.
46
+
47
+ `pitmap` is a Python implementation of the surface-modeling methods used in
48
+ the automated geological and mine-surveying support system developed at the
49
+ State University of Economics and Technology (Kryvyi Rih, Ukraine), with a
50
+ kernel-based interpolator added for comparison. All methods share one
51
+ `fit` / `predict` interface.
52
+
53
+ > **Status:** pre-alpha. The API will change. Nothing here is ready for
54
+ > production use yet.
55
+
56
+ ## Methods
57
+
58
+ | Class | Method | Source |
59
+ |---|---|---|
60
+ | `NearestRegion` | Polygonal (nearest-region / Thiessen) surface | Zelensky & Lysenko (2023) |
61
+ | `SectorIDW` | Sector-constrained inverse distance weighting, optional anisotropy via critical correlation radius | Zelenskyi et al. (2020); Zelensky & Donchenko (2025) |
62
+ | `PolynomialSurface` | Bivariate least-squares polynomial up to degree 5, with adequacy statistics | Zelenskyi et al. (2020); Zelensky & Donchenko (2025) |
63
+ | `NURBSSurface` | Tensor-product NURBS smoother over an interpolated grid | Zelensky & Lysenko (2023) |
64
+ | `KernelSurface` | SVR / Gaussian process with the critical correlation radius as default length scale | this package |
65
+
66
+ Utilities: `acf_radius()` (critical correlation radius from the spatial
67
+ autocorrelation function) and `prism_volume()` (volume between surfaces by
68
+ unit prisms).
69
+
70
+ Implemented so far: `NearestRegion`, `SectorIDW`.
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ pip install pitmap
76
+ ```
77
+
78
+ ## Usage
79
+
80
+ ```python
81
+ import numpy as np
82
+ from pitmap import NearestRegion
83
+
84
+ xy = np.array([[0.0, 0.0], [10.0, 0.0], [0.0, 10.0], [10.0, 10.0]])
85
+ z = np.array([100.0, 102.0, 101.0, 103.0])
86
+
87
+ model = NearestRegion().fit(xy, z)
88
+ model.predict(np.array([[2.0, 1.0], [9.0, 9.0]]))
89
+ # array([100., 103.])
90
+ ```
91
+
92
+ ## Repository layout
93
+
94
+ ```
95
+ pitmap/ package; core/ holds the interpolators
96
+ data_gen.py fetch a raw DEM tile -> data/raw (Parquet, optional CSV)
97
+ preprocessing.py subsample to sparse survey points -> data/processed
98
+ notebooks/ analysis; outputs stripped before commit
99
+ data/ gitignored
100
+ ```
101
+
102
+ ## Development
103
+
104
+ ```bash
105
+ conda activate conda_312
106
+ make create_venv && source venv_pitmap/bin/activate
107
+ make requirements
108
+ make test
109
+ make help # list all targets
110
+ ```
111
+
112
+ ## References
113
+
114
+ Zelenskyi, O., Lysenko, V., Alekseyev, M., & Vlasov, V. (2020). Modeling of
115
+ the earth's surface subsidence during its undermining by stoping in coal mines.
116
+ *Naukovyi Visnyk Natsionalnoho Hirnychoho Universytetu*, (6), 121–127.
117
+ https://doi.org/10.33271/nvngu/2020-6/121
118
+
119
+ Zelensky, O., & Lysenko, V. (2023). Construction surface using desktop and
120
+ mobile applications. *Economics and Technical Engineering*, 1(1), 87–102.
121
+ https://doi.org/10.62911/ete.2023.01.01.07
122
+
123
+ Zelensky, O., & Donchenko, O. (2025). Research and application of polynomial
124
+ models in the development of an automated geological and mine surveying
125
+ support system for open-pit mining. *Mining Journal of Kryvyi Rih National
126
+ University*, 59(1), 10–21. https://doi.org/10.31721/2306-5435-2025-1-10-21
127
+
128
+ ## License
129
+
130
+ MIT
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ pitmap/__init__.py
5
+ pitmap.egg-info/PKG-INFO
6
+ pitmap.egg-info/SOURCES.txt
7
+ pitmap.egg-info/dependency_links.txt
8
+ pitmap.egg-info/requires.txt
9
+ pitmap.egg-info/top_level.txt
10
+ pitmap/core/__init__.py
11
+ pitmap/core/interpolation.py
12
+ tests/test_nearest_region.py
13
+ tests/test_sector_idw.py
@@ -0,0 +1,25 @@
1
+ numpy>=1.24
2
+ scipy>=1.11
3
+
4
+ [data]
5
+ pandas>=2.0
6
+ pyarrow>=14
7
+ rasterio>=1.3
8
+ typer>=0.9
9
+
10
+ [dev]
11
+ pytest
12
+ black
13
+ nbstripout
14
+ jupyter
15
+ build
16
+ twine
17
+
18
+ [kernel]
19
+ scikit-learn>=1.3
20
+
21
+ [nurbs]
22
+ geomdl>=5.3
23
+
24
+ [viz]
25
+ matplotlib>=3.7
@@ -0,0 +1 @@
1
+ pitmap
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pitmap"
7
+ version = "0.0.0a1"
8
+ description = "Surface construction from scattered survey points for open-pit mine surveying: polygonal, sector IDW, polynomial, NURBS and kernel interpolators, with prism volumes."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{name = "Leonid Shpaner"}]
14
+ keywords = ["mine surveying", "interpolation", "open-pit", "NURBS", "IDW", "surface modeling"]
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3",
19
+ "Topic :: Scientific/Engineering",
20
+ ]
21
+ dependencies = [
22
+ "numpy>=1.24",
23
+ "scipy>=1.11",
24
+ ]
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/lshpaner/pitmap"
28
+ Repository = "https://github.com/lshpaner/pitmap"
29
+
30
+ [project.optional-dependencies]
31
+ kernel = ["scikit-learn>=1.3"]
32
+ nurbs = ["geomdl>=5.3"]
33
+ data = ["pandas>=2.0", "pyarrow>=14", "rasterio>=1.3", "typer>=0.9"]
34
+ viz = ["matplotlib>=3.7"]
35
+ dev = ["pytest", "black", "nbstripout", "jupyter", "build", "twine"]
36
+
37
+ [tool.setuptools.packages.find]
38
+ include = ["pitmap*"]
39
+
40
+ [tool.black]
41
+ line-length = 88
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,19 @@
1
+ import numpy as np
2
+
3
+ from pitmap import NearestRegion
4
+
5
+
6
+ def test_nearest_region_reproduces_training_points():
7
+ rng = np.random.default_rng(0)
8
+ xy = rng.uniform(0, 100, size=(50, 2))
9
+ z = rng.normal(500, 10, size=50)
10
+ model = NearestRegion().fit(xy, z)
11
+ np.testing.assert_allclose(model.predict(xy), z)
12
+
13
+
14
+ def test_nearest_region_is_piecewise_constant():
15
+ xy = np.array([[0.0, 0.0], [10.0, 0.0]])
16
+ z = np.array([1.0, 2.0])
17
+ model = NearestRegion().fit(xy, z)
18
+ assert model.predict(np.array([[2.0, 0.0]]))[0] == 1.0
19
+ assert model.predict(np.array([[8.0, 0.0]]))[0] == 2.0
@@ -0,0 +1,55 @@
1
+ import numpy as np
2
+ import pytest
3
+
4
+ from pitmap import SectorIDW
5
+
6
+
7
+ def test_exact_at_training_points():
8
+ rng = np.random.default_rng(1)
9
+ xy = rng.uniform(0, 100, size=(40, 2))
10
+ z = rng.normal(500, 10, size=40)
11
+ model = SectorIDW(radius=50).fit(xy, z)
12
+ np.testing.assert_allclose(model.predict(xy), z)
13
+
14
+
15
+ def test_symmetric_square_returns_mean_at_center():
16
+ # four points at equal distance from the origin, one per quadrant
17
+ xy = np.array([[1.0, 1.0], [-1.0, 1.0], [-1.0, -1.0], [1.0, -1.0]])
18
+ z = np.array([10.0, 20.0, 30.0, 40.0])
19
+ model = SectorIDW(radius=5, n_sectors=4).fit(xy, z)
20
+ assert model.predict(np.array([[0.0, 0.0]]))[0] == pytest.approx(25.0)
21
+
22
+
23
+ def test_outside_radius_is_nan():
24
+ xy = np.array([[0.0, 0.0], [1.0, 0.0]])
25
+ z = np.array([1.0, 2.0])
26
+ model = SectorIDW(radius=2).fit(xy, z)
27
+ assert np.isnan(model.predict(np.array([[100.0, 100.0]]))[0])
28
+
29
+
30
+ def test_sector_rule_limits_cluster_influence():
31
+ # nine points clustered just north of the origin, one point south
32
+ north = np.column_stack([np.linspace(-0.5, 0.5, 9), np.full(9, 2.0)])
33
+ south = np.array([[0.0, -2.0]])
34
+ xy = np.vstack([north, south])
35
+ z = np.concatenate([np.full(9, 100.0), [0.0]])
36
+
37
+ plain = SectorIDW(radius=10, n_sectors=1).fit(xy, z) # effectively plain IDW
38
+ sectored = SectorIDW(radius=10, n_sectors=8).fit(xy, z)
39
+ q = np.array([[0.0, 0.0]])
40
+
41
+ # plain IDW is pulled hard toward the cluster; sectoring pulls it back toward the middle
42
+ assert plain.predict(q)[0] > 85.0
43
+ assert sectored.predict(q)[0] < plain.predict(q)[0]
44
+
45
+
46
+ def test_anisotropy_favours_long_axis():
47
+ # one point east, one point north, same distance; stretch correlation along x
48
+ xy = np.array([[10.0, 0.0], [0.0, 10.0]])
49
+ z = np.array([0.0, 100.0])
50
+ iso = SectorIDW(radius=50).fit(xy, z)
51
+ aniso = SectorIDW(radius=50, anisotropy=(40.0, 10.0)).fit(xy, z)
52
+ q = np.array([[0.0, 0.0]])
53
+ assert iso.predict(q)[0] == pytest.approx(50.0)
54
+ # the east point lies along the long axis so it should pull the estimate down
55
+ assert aniso.predict(q)[0] < 50.0