Skip to content

Commit

Permalink
plot: minor fixes for latlon
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Jun 12, 2023
1 parent 868d4b1 commit 12012c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/gstools/covmodel/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
# plotting routines #######################################################


def _plot_spatial(dim, pos, field, fig, ax, latlon, **kwargs):
def _plot_spatial(dim, pos, field, fig, ax, time, **kwargs):
from gstools.field.plot import plot_1d, plot_nd

if dim == 1:
return plot_1d(pos, field, fig, ax, **kwargs)
return plot_nd(pos, field, "structured", fig, ax, latlon, **kwargs)
return plot_nd(pos, field, "structured", fig, ax, time=time, **kwargs)


def plot_vario_spatial(
Expand All @@ -70,7 +70,7 @@ def plot_vario_spatial(
pos = [x_s] * model.dim
shp = tuple(len(p) for p in pos)
fld = model.vario_spatial(generate_grid(pos)).reshape(shp)
return _plot_spatial(model.dim, pos, fld, fig, ax, model.latlon, **kwargs)
return _plot_spatial(model.dim, pos, fld, fig, ax, model.time, **kwargs)


def plot_cov_spatial(
Expand All @@ -83,7 +83,7 @@ def plot_cov_spatial(
pos = [x_s] * model.dim
shp = tuple(len(p) for p in pos)
fld = model.cov_spatial(generate_grid(pos)).reshape(shp)
return _plot_spatial(model.dim, pos, fld, fig, ax, model.latlon, **kwargs)
return _plot_spatial(model.dim, pos, fld, fig, ax, model.time, **kwargs)


def plot_cor_spatial(
Expand All @@ -96,7 +96,7 @@ def plot_cor_spatial(
pos = [x_s] * model.dim
shp = tuple(len(p) for p in pos)
fld = model.cor_spatial(generate_grid(pos)).reshape(shp)
return _plot_spatial(model.dim, pos, fld, fig, ax, model.latlon, **kwargs)
return _plot_spatial(model.dim, pos, fld, fig, ax, model.time, **kwargs)


def plot_variogram(
Expand Down Expand Up @@ -150,7 +150,7 @@ def plot_vario_yadrenko(
"""Plot Yadrenko variogram of a given CovModel."""
fig, ax = get_fig_ax(fig, ax)
if x_max is None:
x_max = 3 * model.len_scale
x_max = min(3 * model.len_scale, model.geo_scale * np.pi)
x_s = np.linspace(x_min, x_max)
kwargs.setdefault("label", f"{model.name} Yadrenko variogram")
ax.plot(x_s, model.vario_yadrenko(x_s), **kwargs)
Expand All @@ -165,7 +165,7 @@ def plot_cov_yadrenko(
"""Plot Yadrenko covariance of a given CovModel."""
fig, ax = get_fig_ax(fig, ax)
if x_max is None:
x_max = 3 * model.len_scale
x_max = min(3 * model.len_scale, model.geo_scale * np.pi)
x_s = np.linspace(x_min, x_max)
kwargs.setdefault("label", f"{model.name} Yadrenko covariance")
ax.plot(x_s, model.cov_yadrenko(x_s), **kwargs)
Expand All @@ -180,7 +180,7 @@ def plot_cor_yadrenko(
"""Plot Yadrenko correlation function of a given CovModel."""
fig, ax = get_fig_ax(fig, ax)
if x_max is None:
x_max = 3 * model.len_scale
x_max = min(3 * model.len_scale, model.geo_scale * np.pi)
x_s = np.linspace(x_min, x_max)
kwargs.setdefault("label", f"{model.name} Yadrenko correlation")
ax.plot(x_s, model.cor_yadrenko(x_s), **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions src/gstools/field/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ def _ax_names(dim, latlon=False, time=False, ax_names=None):
return ax_names[:dim]
if dim == 2 + t_fac and latlon:
return ["lon", "lat"] + t_fac * ["time"]
if dim <= 3:
if dim - t_fac <= 3:
return (
["$x$", "$y$", "$z$"][:dim]
["$x$", "$y$", "$z$"][: dim - t_fac]
+ t_fac * ["time"]
+ (dim == 1) * ["field"]
)
Expand Down

0 comments on commit 12012c6

Please sign in to comment.