Skip to content

Commit

Permalink
Add exception for Dowds variogram for scikit-gstat version lower or e…
Browse files Browse the repository at this point in the history
…qual to 1.0.0
  • Loading branch information
rhugonnet committed Aug 2, 2023
1 parent 79a1ae9 commit 4f0562c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions xdem/spatialstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,17 @@ def sample_empirical_variogram(
df_mean["count"] = df_count["count"]
df = df_mean

# Fix variance error for Dowd's variogram in SciKit-GStat

# If skgstat > 1.0, we can use Dowd's without correcting, otherwise we correct
from packaging.version import Version

if Version(skg.__version__) <= Version("1.0.0"):
if "estimator" in kwargs.keys() and kwargs["estimator"].lower() == "dowd":
# Correction: we divide all experimental variance values by 2
df.exp.values /= 2
df.err_exp.values /= 2

# Remove the last spatial lag bin which is always undersampled
df.drop(df.tail(1).index, inplace=True)

Expand Down

0 comments on commit 4f0562c

Please sign in to comment.