Skip to content

Commit

Permalink
CovModel: saver setting of anis
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Jun 13, 2023
1 parent 1e47ab7 commit e821a6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/gstools/covmodel/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __init__(

# set anisotropy and len_scale, disable anisotropy for latlon models
self._len_scale, self._anis = set_len_anis(
self.dim, len_scale, anis, self.latlon, self.temporal
self.dim, len_scale, anis, self.latlon
)
self._angles = set_model_angles(
self.dim, angles, self.latlon, self.temporal
Expand Down Expand Up @@ -974,7 +974,9 @@ def len_scale(self):

@len_scale.setter
def len_scale(self, len_scale):
self._len_scale, anis = set_len_anis(self.dim, len_scale, self.anis)
self._len_scale, anis = set_len_anis(
self.dim, len_scale, self.anis, self.latlon
)
if self.latlon:
self._anis = np.array((self.dim - 1) * [1], dtype=np.double)
else:
Expand Down Expand Up @@ -1004,7 +1006,7 @@ def anis(self):
@anis.setter
def anis(self, anis):
self._len_scale, self._anis = set_len_anis(
self.dim, self.len_scale, anis, self.latlon, self.temporal
self.dim, self.len_scale, anis, self.latlon
)
self.check_arg_bounds()

Expand Down
13 changes: 5 additions & 8 deletions src/gstools/covmodel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def set_opt_args(model, opt_arg):
setattr(model, opt_name, float(opt_arg[opt_name]))


def set_len_anis(dim, len_scale, anis, latlon=False, temporal=False):
def set_len_anis(dim, len_scale, anis, latlon=False):
"""Set the length scale and anisotropy factors for the given dimension.
Parameters
Expand All @@ -197,10 +197,7 @@ def set_len_anis(dim, len_scale, anis, latlon=False, temporal=False):
the anisotropy of length scales along the transversal axes
latlon : :class:`bool`, optional
Whether the model is describing 2D fields on earths surface described
by latitude and longitude.
Default: False
temporal : :class:`bool`, optional
Whether a time-dimension is appended.
by latitude and longitude. In this case there is no spatial anisotropy.
Default: False
Returns
Expand Down Expand Up @@ -241,11 +238,11 @@ def set_len_anis(dim, len_scale, anis, latlon=False, temporal=False):
for ani in out_anis:
if not ani > 0.0:
raise ValueError(
"anisotropy-ratios needs to be > 0, " + "got: " + str(out_anis)
f"anisotropy-ratios needs to be > 0, " + "got: {out_anis}"
)
# no anisotropy for latlon (only when temporal, but then only in time-dimension)
# no spatial anisotropy for latlon
if latlon:
out_anis[: dim - (2 if temporal else 1)] = 1.0
out_anis[:2] = 1.0
return out_len_scale, out_anis


Expand Down

0 comments on commit e821a6a

Please sign in to comment.