From 10bf725acd29e76dff40ba5b102e47f15f1cecef Mon Sep 17 00:00:00 2001 From: Egil Date: Thu, 24 Sep 2020 09:04:02 +0200 Subject: [PATCH 1/3] Bugfix for angle calculation for compass shape --- skgstat/DirectionalVariogram.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skgstat/DirectionalVariogram.py b/skgstat/DirectionalVariogram.py index 12e8635..92e3e63 100644 --- a/skgstat/DirectionalVariogram.py +++ b/skgstat/DirectionalVariogram.py @@ -757,7 +757,7 @@ def _compass(self, local_ref): xmax = np.max(local_ref[:,0]) # calculate the radius and y coordinates - r = xmax / a + r = xmax / np.cos(a) y = r * np.sin(a) # build and return the figure From db8a642f334b06c7848b9fbdeb287e4ba31b6efd Mon Sep 17 00:00:00 2001 From: Egil Date: Thu, 24 Sep 2020 10:02:12 +0200 Subject: [PATCH 2/3] Handle the case where the triangle extends past xmax --- skgstat/DirectionalVariogram.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skgstat/DirectionalVariogram.py b/skgstat/DirectionalVariogram.py index 92e3e63..2ca4051 100644 --- a/skgstat/DirectionalVariogram.py +++ b/skgstat/DirectionalVariogram.py @@ -641,6 +641,9 @@ def _triangle(self, local_ref): # get the maximum x coordinate in the current representation xmax = np.max(local_ref[:, 0]) + if h >= xmax: + return self._compass(local_ref) + # build the figure poly = Polygon([ (0, 0), From ef393bb1395bb414bac5a629c22dab593718d639 Mon Sep 17 00:00:00 2001 From: Egil Date: Thu, 24 Sep 2020 10:11:55 +0200 Subject: [PATCH 3/3] Bugfix for unit tests to match corrected search area shapes --- skgstat/tests/DirectionalVariogram.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/skgstat/tests/DirectionalVariogram.py b/skgstat/tests/DirectionalVariogram.py index ab773fe..4b6526c 100644 --- a/skgstat/tests/DirectionalVariogram.py +++ b/skgstat/tests/DirectionalVariogram.py @@ -17,7 +17,7 @@ def setUp(self): def test_standard_settings(self): DV = DirectionalVariogram(self.c, self.v, normalize=True) - for x, y in zip(DV.parameters, [406., 2145., 0]): + for x, y in zip(DV.parameters, [407.467, 2138.098, 0]): self.assertAlmostEqual(x, y, places=0) def test_azimuth(self): @@ -38,7 +38,7 @@ def test_invalid_azimuth(self): def test_tolerance(self): DV = DirectionalVariogram(self.c, self.v, tolerance=15, normalize=True) - for x, y in zip(DV.parameters, [32.474, 2016.601, 0]): + for x, y in zip(DV.parameters, [26.342, 1880.015, 0]): self.assertAlmostEqual(x, y, places=3) def test_invalid_tolerance(self): @@ -53,7 +53,7 @@ def test_invalid_tolerance(self): def test_bandwidth(self): DV = DirectionalVariogram(self.c, self.v, bandwidth=12, normalize=True) - for x, y in zip(DV.parameters, [435.733, 2746.608, 0]): + for x, y in zip(DV.parameters, [435.733, 2715.865, 0]): self.assertAlmostEqual(x, y, places=3) def test_invalid_model(self):