Skip to content

Commit

Permalink
Merge pull request #201 from GeoStat-Framework/krige_nan_data
Browse files Browse the repository at this point in the history
Krige: filter out nan values from cond_val
  • Loading branch information
MuellerSeb authored Aug 8, 2021
2 parents f0666f3 + 1d5cdcd commit e96848b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ All notable changes to **GSTools** will be documented in this file.
### Enhancements
See: [#197](https://github.com/GeoStat-Framework/GSTools/issues/197)
- `gstools.transform`:
- add keywords `field`, `store` and `process` keyword to all transformations to control storage and respect `normalizer`
- add keywords `field`, `store`, `process` and `keep_mean` to all transformations to control storage and respect `normalizer`
- added `apply_function` transformation
- added `apply` as wrapper for all transformations
- added `transform` method to all `Field` (sub)classes as interface to `transform.apply`
Expand All @@ -26,6 +26,7 @@ See: [#197](https://github.com/GeoStat-Framework/GSTools/issues/197)
- performance improvement by using `np.asarray` instead of `np.array` where possible
- updated examples to use new features
- added incomplete lower gamma function `inc_gamma_low` (for TPLGaussian spectral density)
- filter `nan` values from `cond_val` array in all kriging routines [#201](https://github.com/GeoStat-Framework/GSTools/issues/201)

### Bugfixes
- `inc_gamma` was defined wrong for integer `s < 0`
Expand Down
5 changes: 3 additions & 2 deletions gstools/krige/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Krige(Field):
cond_pos : :class:`list`
tuple, containing the given condition positions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
drift_functions : :class:`list` of :any:`callable`, :class:`str` or :class:`int`
Either a list of callable functions, an integer representing
the polynomial order of the drift or one of the following strings:
Expand Down Expand Up @@ -469,7 +469,8 @@ def set_condition(
cond_pos : :class:`list`, optional
the position tuple of the conditions (x, [y, z]). Default: current.
cond_val : :class:`numpy.ndarray`, optional
the values of the conditions. Default: current.
the values of the conditions (nan values will be ignored).
Default: current.
ext_drift : :class:`numpy.ndarray` or :any:`None`, optional
the external drift values at the given conditions (only for EDK)
For multiple external drifts, the first dimension
Expand Down
10 changes: 5 additions & 5 deletions gstools/krige/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Simple(Krige):
cond_pos : :class:`list`
tuple, containing the given condition positions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
mean : :class:`float`, optional
mean value used to shift normalized conditioning data.
Could also be a callable. The default is None.
Expand Down Expand Up @@ -130,7 +130,7 @@ class Ordinary(Krige):
cond_pos : :class:`list`
tuple, containing the given condition positions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
normalizer : :any:`None` or :any:`Normalizer`, optional
Normalizer to be applied to the input data to gain normality.
The default is None.
Expand Down Expand Up @@ -228,7 +228,7 @@ class Universal(Krige):
cond_pos : :class:`list`
tuple, containing the given condition positions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
drift_functions : :class:`list` of :any:`callable`, :class:`str` or :class:`int`
Either a list of callable functions, an integer representing
the polynomial order of the drift or one of the following strings:
Expand Down Expand Up @@ -335,7 +335,7 @@ class ExtDrift(Krige):
cond_pos : :class:`list`
tuple, containing the given condition positions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
ext_drift : :class:`numpy.ndarray`
the external drift values at the given condition positions.
normalizer : :any:`None` or :any:`Normalizer`, optional
Expand Down Expand Up @@ -441,7 +441,7 @@ class Detrended(Krige):
cond_pos : :class:`list`
tuple, containing the given condition positions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
trend_function : :any:`callable`
The callable trend function. Should have the signiture: f(x, [y, z])
exact : :class:`bool`, optional
Expand Down
9 changes: 5 additions & 4 deletions gstools/krige/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def set_condition(cond_pos, cond_val, dim):
cond_pos : :class:`list`
the position tuple of the conditions (x, [y, z])
cond_val : :class:`numpy.ndarray`
the values of the conditions
the values of the conditions (nan values will be ignored)
dim : :class:`int`, optional
Spatial dimension
Expand All @@ -39,9 +39,9 @@ def set_condition(cond_pos, cond_val, dim):
Returns
-------
cond_pos : :class:`list`
the error checked cond_pos
the error checked cond_pos with all finite values
cond_val : :class:`numpy.ndarray`
the error checked cond_val
the error checked cond_val for all finite cond_pos values
"""
# convert the input for right shapes and dimension checks
cond_val = np.asarray(cond_val, dtype=np.double).reshape(-1)
Expand All @@ -51,7 +51,8 @@ def set_condition(cond_pos, cond_val, dim):
"Please check your 'cond_pos' and 'cond_val' parameters. "
"The shapes do not match."
)
return cond_pos, cond_val
mask = np.isfinite(cond_val)
return cond_pos[:, mask], cond_val[mask]


def get_drift_functions(dim, drift_type):
Expand Down

0 comments on commit e96848b

Please sign in to comment.