Skip to content

Commit

Permalink
CovModel: Doc update; changed calculation of anisotropy in 3D
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Jan 23, 2020
1 parent d602a55 commit b13845b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
13 changes: 10 additions & 3 deletions gstools/covmodel/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,22 @@ class CovModel(metaclass=InitSubclassMeta):
If a single value is given, the same length-scale will be used for
every direction. If multiple values (for main and transversal
directions) are given, `anis` will be
recalculated accordingly.
recalculated accordingly. If only two values are given in 3D,
the latter one will be used for both transversal directions.
Default: ``1.0``
nugget : :class:`float`, optional
nugget of the model. Default: ``0.0``
anis : :class:`float` or :class:`list`, optional
anisotropy ratios in the transversal directions [y, z].
anisotropy ratios in the transversal directions [e_y, e_z].
* e_y = l_y / l_x
* e_z = l_z / l_x
If only one value is given in 3D, e_y will be set to 1.
This value will be ignored, if multiple len_scales are given.
Default: ``1.0``
angles : :class:`float` or :class:`list`, optional
angles of rotation:
angles of rotation (given in rad):
* in 2D: given as rotation around z-axis
* in 3D: given by yaw, pitch, and roll (known as Tait–Bryan angles)
Expand Down
22 changes: 11 additions & 11 deletions gstools/covmodel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,15 @@ def set_len_anis(dim, len_scale, anis):
Notes
-----
If ``len_scale`` is given as list, ``anis`` will be recalculated.
If ``len_scale`` is given by at least two values,
``anis`` will be recalculated.
If ``len_scale`` is given as list with to few values, the latter value will
be used for the remaining dimensions. (e.g. [l_1, l_2] in 3D is equal to
[l_1, l_2, l_2])
If to few ``anis`` values are given, the first dimensions will be filled
up with 1. (eg. anis=[e] in 3D is equal to anis=[1, e])
"""
ls_tmp = np.atleast_1d(len_scale)[:dim]
# use just one length scale (x-direction)
Expand All @@ -122,22 +130,14 @@ def set_len_anis(dim, len_scale, anis):
# fill up the anisotropies with ones, such that len()==dim-1
out_anis = np.pad(
out_anis,
(0, dim - len(out_anis) - 1),
(dim - len(out_anis) - 1, 0),
"constant",
constant_values=1.0,
)
elif dim == 1:
# there is no anisotropy in 1 dimension
out_anis = np.empty(0)
else:
# fill up length-scales with main len_scale, such that len()==dim
if len(ls_tmp) < dim:
ls_tmp = np.pad(
ls_tmp,
(0, dim - len(ls_tmp)),
"constant",
constant_values=out_len_scale,
)
ls_tmp = np.pad(ls_tmp, (0, dim - len(ls_tmp)), "edge")
# if multiple length-scales are given, calculate the anisotropies
out_anis = np.zeros(dim - 1, dtype=np.double)
for i in range(1, dim):
Expand Down

0 comments on commit b13845b

Please sign in to comment.