Skip to content

Commit

Permalink
Bugfix: Define spectral_density instead of spectrum in covariance mod…
Browse files Browse the repository at this point in the history
…els since Cov-base derives spectrum
  • Loading branch information
MuellerSeb committed Oct 1, 2019
1 parent 896008c commit 00f2747
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions gstools/covmodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit 00f2747

Please sign in to comment.