Server side scripts & all

This commit is contained in:
Edgar P. Burkhart 2022-06-24 16:50:38 +02:00
parent a000c67e93
commit b92e52ecbb
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
20 changed files with 629 additions and 58 deletions

View file

@ -9,7 +9,7 @@ import sys
from cycler import cycler
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from matplotlib.ticker import MultipleLocator
import numpy as np
from scipy import interpolate
@ -67,11 +67,12 @@ def get_pickle(out):
models = list(map(get_pickle, args.output))
figsize = 15 / 2.54, 4 / 2.54 * len(models)
fig, ax_ = plt.subplots(
len(models),
figsize=(6, 1.5 * len(models)),
dpi=100,
figsize=figsize,
dpi=200,
constrained_layout=True,
squeeze=False,
)
@ -90,32 +91,71 @@ if args.timestep is None:
)
case "U":
for i, (_ax, _model) in enumerate(zip(ax, models)):
v = np.nanmax(np.abs(np.where(
_model.post_fields[args.func]["alpha.water"] > 0.5,
#np.linalg.norm(_model.post_fields[args.func][args.field], axis=2),
_model.post_fields[args.func][args.field][..., 0],
np.nan,
)))
v150 = np.nanmax(np.abs(np.where(
(_model.post_fields[args.func]["alpha.water"] > 0.5) & (_model.t[:, None] > 170) & (_model.t[:, None] < 200),
#np.linalg.norm(_model.post_fields[args.func][args.field], axis=2),
_model.post_fields[args.func][args.field][..., 0],
np.nan,
)))
_data = _model.post_fields[args.func][args.field][..., 0].T
#_c = _ax.contourf(
# _model.t,
# _model.post_fields[args.func][f"x_{args.field}"],
# _data,
# cmap="PiYG",
# #levels=[-15, -10, -5, -2, -1, 0, 1, 2, 5, 10, 15],
# vmin=-np.nanmax(np.abs(_data)),
# vmax=np.nanmax(np.abs(_data)),
# extend="both",
#)
_c = _ax.imshow(
np.where(_model.post_fields[args.func]["alpha.water"] > 0.5, np.linalg.norm(_model.post_fields[args.func][args.field], axis=2), np.nan).T[::-1],
vmin=0,
vmax=20,
cmap="inferno_r",
_data[::-1],
cmap="PiYG",
alpha=np.clip(_model.post_fields[args.func]["alpha.water"], 0, 1).T[::-1],
extent=(
_model.t.min(),
_model.t.max(),
_model.post_fields[args.func][f"x_{args.field}"].min(),
_model.post_fields[args.func][f"x_{args.field}"].max(),
),
vmin=-v150,
vmax=v150,
aspect="auto",
)
_ax.set(xlim=(100, 300))
_ax.set(facecolor="k")
_ax.xaxis.set_minor_locator(MultipleLocator(5))
_ax.yaxis.set_minor_locator(MultipleLocator(1))
fig.colorbar(_c, label=f"{args.field} (m/s)", ax=_ax)
log.info(f"Vitesse max: {v}m/s")
log.info(f"Vitesse max [170,200]: {v150}m/s")
log.info(f"Écart: {abs(np.nanmax(_data)-17.7)/17.7:%}")
case _:
log.error(f"Cannot plot field {args.field} from {args.func}")
sys.exit(1)
for i, (_ax, _model) in enumerate(zip(ax, models)):
_ax.set(xlabel="t (s)", ylabel="z (m)", title=f"Case {i}")
_ax.grid(color="k", alpha=0.2)
_ax.set(xlabel="t (s)", ylabel="z (m)")
if len(models) > 1:
_ax.set(title=f"Case {i}")
#_ax.grid(color="#797979", alpha=0.5)
fig.savefig(
args.output[0].joinpath(
f"diff_{args.func}_{args.field}_{'_'.join([o.name for o in args.output])}.pdf"
)
)
fig.savefig(
args.output[0].joinpath(
f"diff_{args.func}_{args.field}_{'_'.join([o.name for o in args.output])}.jpg"
)
)
else:
match args.field:
case "alpha.water":
@ -123,7 +163,9 @@ else:
_ax.tricontour(
_model.x,
_model.z,
_model.fields[args.field][np.where(_model.t == args.timestep)[0]][0],
_model.fields[args.field][np.where(_model.t == args.timestep)[0]][
0
],
levels=(0.5,),
colors="k",
)