Update 'diff' with U
This commit is contained in:
parent
8ad6690a46
commit
402ad87091
1 changed files with 64 additions and 20 deletions
|
@ -5,6 +5,7 @@ import logging
|
||||||
from multiprocessing import pool
|
from multiprocessing import pool
|
||||||
import pathlib
|
import pathlib
|
||||||
import pickle
|
import pickle
|
||||||
|
import sys
|
||||||
|
|
||||||
from cycler import cycler
|
from cycler import cycler
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
@ -36,6 +37,15 @@ parser.add_argument(
|
||||||
type=str,
|
type=str,
|
||||||
help="Post-process function to compare",
|
help="Post-process function to compare",
|
||||||
default="graphUniform",
|
default="graphUniform",
|
||||||
|
choices=("graphUniform", "graphUniform2"),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-y",
|
||||||
|
"--field",
|
||||||
|
type=str,
|
||||||
|
help="Field to compare",
|
||||||
|
default="alpha.water",
|
||||||
|
choices=("alpha.water", "U"),
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -57,35 +67,69 @@ def get_pickle(out):
|
||||||
|
|
||||||
models = list(map(get_pickle, args.output))
|
models = list(map(get_pickle, args.output))
|
||||||
|
|
||||||
fig, ax = plt.subplots(len(models), figsize=(6, 1.5 * len(models)), dpi=100, constrained_layout=True)
|
|
||||||
|
fig, (ax,) = plt.subplots(
|
||||||
|
len(models),
|
||||||
|
figsize=(6, 1.5 * len(models)),
|
||||||
|
dpi=100,
|
||||||
|
constrained_layout=True,
|
||||||
|
squeeze=False,
|
||||||
|
)
|
||||||
|
|
||||||
if args.timestep is None:
|
if args.timestep is None:
|
||||||
|
match args.field:
|
||||||
|
case "alpha.water":
|
||||||
for i, (_ax, _model) in enumerate(zip(ax, models)):
|
for i, (_ax, _model) in enumerate(zip(ax, models)):
|
||||||
_ax.contour(
|
_ax.contour(
|
||||||
_model.t,
|
_model.t,
|
||||||
_model.post_fields[args.func]["x_alpha.water"],
|
_model.post_fields[args.func][f"x_{args.field}"],
|
||||||
_model.post_fields[args.func]["alpha.water"].T,
|
_model.post_fields[args.func][args.field].T,
|
||||||
(0.5,),
|
(0.5,),
|
||||||
colors="k",
|
colors="k",
|
||||||
)
|
)
|
||||||
|
case "U":
|
||||||
|
for i, (_ax, _model) in enumerate(zip(ax, models)):
|
||||||
|
_c = _ax.imshow(
|
||||||
|
np.linalg.norm(_model.post_fields[args.func][args.field], axis=2).T,
|
||||||
|
vmin=0,
|
||||||
|
cmap="inferno",
|
||||||
|
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(),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
fig.colorbar(_c, label=f"{args.field} (m/s)", ax=_ax)
|
||||||
|
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.set(xlabel="t (s)", ylabel="z (m)", title=f"Case {i}")
|
||||||
_ax.grid()
|
_ax.grid(color="k", alpha=0.2)
|
||||||
|
|
||||||
fig.savefig(
|
fig.savefig(
|
||||||
args.output[0].joinpath(
|
args.output[0].joinpath(
|
||||||
f"diff_{args.func}_{'_'.join([o.name for o in args.output])}.pdf"
|
f"diff_{args.func}_{args.field}_{'_'.join([o.name for o in args.output])}.pdf"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
match args.field:
|
||||||
|
case "alpha.water":
|
||||||
for i, (_ax, _model) in enumerate(zip(ax, models)):
|
for i, (_ax, _model) in enumerate(zip(ax, models)):
|
||||||
_ax.tricontour(
|
_ax.tricontour(
|
||||||
_model.x,
|
_model.x,
|
||||||
_model.z,
|
_model.z,
|
||||||
_model.fields["alpha.water"][np.where(_model.t == args.timestep)[0]][0],
|
_model.fields[args.field][np.where(_model.t == args.timestep)[0]][0],
|
||||||
levels=(0.5,),
|
levels=(0.5,),
|
||||||
colors="k",
|
colors="k",
|
||||||
)
|
)
|
||||||
|
case _:
|
||||||
|
log.error(f"Cannot plot field {args.field} from {args.func} at timestep")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for i, (_ax, _model) in enumerate(zip(ax, models)):
|
||||||
_ax.set(xlabel="x (m)", ylabel="z (m)", title=f"Case {i}")
|
_ax.set(xlabel="x (m)", ylabel="z (m)", title=f"Case {i}")
|
||||||
_ax.grid()
|
_ax.grid()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue