From 00f2747fd0503ff8806f2eebfba36acff813416b Mon Sep 17 00:00:00 2001 From: MuellerSeb Date: Wed, 2 Oct 2019 00:31:18 +0200 Subject: [PATCH] Bugfix: Define spectral_density instead of spectrum in covariance models since Cov-base derives spectrum --- gstools/covmodel/models.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/gstools/covmodel/models.py b/gstools/covmodel/models.py index ac5abdce..38dd3dce 100644 --- a/gstools/covmodel/models.py +++ b/gstools/covmodel/models.py @@ -64,11 +64,10 @@ def correlation(self, r): r = np.array(np.abs(r), dtype=np.double) return np.exp(-np.pi / 4 * (r / self.len_scale) ** 2) - def spectrum(self, k): # noqa: D102 + def spectral_density(self, k): # noqa: D102 k = np.array(k, dtype=np.double) return ( - self.var - * (self.len_scale / np.pi) ** self.dim + (self.len_scale / np.pi) ** self.dim * np.exp(-(k * self.len_scale) ** 2 / np.pi) ) @@ -137,11 +136,10 @@ def correlation(self, r): r = np.array(np.abs(r), dtype=np.double) return np.exp(-1 * r / self.len_scale) - def spectrum(self, k): # noqa: D102 + def spectral_density(self, k): # noqa: D102 k = np.array(k, dtype=np.double) return ( - self.var - * self.len_scale ** self.dim + self.len_scale ** self.dim * sps.gamma((self.dim + 1) / 2) / (np.pi * (1.0 + (k * self.len_scale) ** 2)) ** ((self.dim + 1) / 2) @@ -423,13 +421,12 @@ def correlation(self, r): res = np.maximum(res, 0.0) return res - def spectrum(self, k): # noqa: D102 + def spectral_density(self, k): # noqa: D102 k = np.array(k, dtype=np.double) # for nu > 20 we just use an approximation of the gaussian model if self.nu > 20.0: return ( - self.var - * (self.len_scale / np.sqrt(np.pi)) ** self.dim + (self.len_scale / np.sqrt(np.pi)) ** self.dim * np.exp(-(k * self.len_scale) ** 2) * ( 1 @@ -441,8 +438,7 @@ def spectrum(self, k): # noqa: D102 ) ) return ( - self.var - * (self.len_scale / np.sqrt(np.pi)) ** self.dim + (self.len_scale / np.sqrt(np.pi)) ** self.dim * np.exp( -(self.nu + self.dim / 2.0) * np.log(1.0 + (k * self.len_scale) ** 2 / self.nu) @@ -686,7 +682,7 @@ def correlation(self, r): # noqa: D102 ) return res - def spectrum(self, k): # noqa: D102 + def spectral_density(self, k): # noqa: D102 k = np.array(k, dtype=np.double) res = np.empty_like(k) kl = k * self.len_scale @@ -710,4 +706,4 @@ def spectrum(self, k): # noqa: D102 res[np.logical_not(kl_gz)] = ( self.len_scale ** 3 / 48.0 / np.pi ** 2 ) - return res * self.var + return res