Skip to content

Commit

Permalink
Merge pull request #180 from DataverseLabs/ethmtrgt-fix-points-values
Browse files Browse the repository at this point in the history
Fixed name of the attribute within the TheoreticalSemivariogram class
  • Loading branch information
Simon authored Oct 13, 2021
2 parents 060a769 + b14cad8 commit 0925cc2
Show file tree
Hide file tree
Showing 22 changed files with 492 additions and 1,366 deletions.
13 changes: 12 additions & 1 deletion changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@ Changes by date
2021-XX-XX
----------

**version 0.2.3.XX**
**version 0.2.XX**

* `self.points_values` chenged to `self.points_array` in `TheoreticalSemivariogram` class,
* `NaN` values are tested and checked in `calc_semivariance_from_pt_cloud()` function,


2021-08-23
----------

**version 0.2.3.post1**

* the outliers removal function: you can choose side for outlier detection and remove. Default is top, available are: both, top, down,
* the outliers removal function: changed algorithm,
* new tutorial about outliers and their influence on the final model.

2021-05-13
----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h1>Source code for pyinterpolate.semivariance.semivariogram_fit.fit_semivarianc
<span class="sd"> :param verbose: (bool) if True then all messages are printed, otherwise nothing.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="bp">self</span><span class="o">.</span><span class="n">points_values</span> <span class="o">=</span> <span class="n">points_array</span>
<span class="bp">self</span><span class="o">.</span><span class="n">points_array</span> <span class="o">=</span> <span class="n">points_array</span>
<span class="bp">self</span><span class="o">.</span><span class="n">empirical_semivariance</span> <span class="o">=</span> <span class="n">empirical_semivariance</span>
<span class="bp">self</span><span class="o">.</span><span class="n">verbose</span> <span class="o">=</span> <span class="n">verbose</span>
<span class="bp">self</span><span class="o">.</span><span class="n">theoretical_model</span> <span class="o">=</span> <span class="kc">None</span>
Expand Down Expand Up @@ -200,7 +200,7 @@ <h1>Source code for pyinterpolate.semivariance.semivariogram_fit.fit_semivarianc
<span class="bp">self</span><span class="o">.</span><span class="n">theoretical_model</span> <span class="o">=</span> <span class="n">model</span>

<span class="c1"># sill</span>
<span class="n">sill</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">points_values</span><span class="p">[:,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>
<span class="n">sill</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">points_array</span><span class="p">[:,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>

<span class="c1"># nugget</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">empirical_semivariance</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
Expand Down Expand Up @@ -250,7 +250,7 @@ <h1>Source code for pyinterpolate.semivariance.semivariogram_fit.fit_semivarianc
<span class="n">base_error</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">calculate_base_error</span><span class="p">()</span>

<span class="c1"># sill</span>
<span class="n">sill</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">points_values</span><span class="p">[:,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>
<span class="n">sill</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">var</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">points_array</span><span class="p">[:,</span> <span class="o">-</span><span class="mi">1</span><span class="p">])</span>

<span class="c1"># nugget</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">empirical_semivariance</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
Expand Down
111 changes: 57 additions & 54 deletions paper/paper.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,19 @@ def calc_semivariance_from_pt_cloud(pt_cloud_dict):
experimental_semivariogram = []
for k in pt_cloud_dict.keys():
try:
experimental_semivariogram.append([k, np.mean(pt_cloud_dict[k]), len(pt_cloud_dict[k])])
mean_semivariance_value = np.mean(pt_cloud_dict[k])
length = len(pt_cloud_dict[k])
except ZeroDivisionError:
# There are no points for this lag
experimental_semivariogram.append([k, 0, 0])
mean_semivariance_value = 0
length = 0

# Check if any nan
if np.isnan(mean_semivariance_value):
mean_semivariance_value = 0
length = 0

experimental_semivariogram.append([k, mean_semivariance_value, length])
experimental_semivariogram = np.array(experimental_semivariogram)
return experimental_semivariogram

Expand Down
18 changes: 15 additions & 3 deletions pyinterpolate/semivariance/semivariogram_fit/fit_semivariance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
"""
Authors:
Szymon Molinski | @szymon-datalions
Contributors:
Ethem Turgut | https://github.com/ethmtrgt
"""


import csv
from operator import itemgetter
import warnings
Expand Down Expand Up @@ -50,7 +62,7 @@ def __init__(self, points_array=None, empirical_semivariance=None, verbose=False
:param verbose: (bool) if True then all messages are printed, otherwise nothing.
"""

self.points_values = points_array
self.points_array = points_array
self.empirical_semivariance = empirical_semivariance
self.verbose = verbose
self.theoretical_model = None
Expand Down Expand Up @@ -204,7 +216,7 @@ def fit_semivariance(self, model_type, number_of_ranges=16):
self.theoretical_model = model

# sill
sill = np.var(self.points_values[:, -1])
sill = np.var(self.points_array[:, -1])

# nugget
if self.empirical_semivariance[0][0] != 0:
Expand Down Expand Up @@ -261,7 +273,7 @@ def find_optimal_model(self, weighted=False, number_of_ranges=16):
base_error = self.calculate_base_error()

# sill
sill = np.var(self.points_values[:, -1])
sill = np.var(self.points_array[:, -1])

# nugget
if self.empirical_semivariance[0][0] != 0:
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

62 changes: 25 additions & 37 deletions tutorials/Ordinary and Simple Kriging (Basic).ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 0925cc2

Please sign in to comment.