Black reformat + favor non gzip pickle
This commit is contained in:
parent
ec5a503c63
commit
47bf31fb3a
4 changed files with 36 additions and 19 deletions
|
@ -27,9 +27,11 @@ config.read(args.config)
|
||||||
out = pathlib.Path(config.get("post", "out"))
|
out = pathlib.Path(config.get("post", "out"))
|
||||||
out.mkdir(parents=True, exist_ok=True)
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with gzip.open(gzf, "rb") if (
|
with (
|
||||||
gzf := out.joinpath("pickle.gz")
|
path.open("rb")
|
||||||
).exists() else gzf.with_suffix("").open("rb") as f:
|
if (path := out.joinpath("pickle")).exists()
|
||||||
|
else gzip.open(path.with_suffix(".gz"), "rb")
|
||||||
|
) as f:
|
||||||
model = pickle.load(f)
|
model = pickle.load(f)
|
||||||
|
|
||||||
x0 = config.getfloat("post", "x")
|
x0 = config.getfloat("post", "x")
|
||||||
|
@ -85,13 +87,26 @@ def anim(i):
|
||||||
aw_m.set_array(AW[i])
|
aw_m.set_array(AW[i])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
figU, axU = plt.subplots(figsize=(19.2, 10.8), dpi=100)
|
figU, axU = plt.subplots(figsize=(19.2, 10.8), dpi=100)
|
||||||
u_m = axU.pcolormesh(
|
u_m = axU.pcolormesh(
|
||||||
X, Z, U[0], cmap="BuPu", vmin=0, vmax=np.nanquantile(U, .99), zorder=1, alpha=np.nan_to_num(AW[0]).clip(0, 1)
|
X,
|
||||||
|
Z,
|
||||||
|
U[0],
|
||||||
|
cmap="BuPu",
|
||||||
|
vmin=0,
|
||||||
|
vmax=np.nanquantile(U, 0.99),
|
||||||
|
zorder=1,
|
||||||
|
alpha=np.nan_to_num(AW[0]).clip(0, 1),
|
||||||
)
|
)
|
||||||
ur_m = axU.pcolormesh(
|
ur_m = axU.pcolormesh(
|
||||||
X, Z, U[0], cmap="YlOrBr", vmin=0, vmax=np.nanquantile(U, .99), zorder=1, alpha=1-np.nan_to_num(AW[0]).clip(0, 1)
|
X,
|
||||||
|
Z,
|
||||||
|
U[0],
|
||||||
|
cmap="YlOrBr",
|
||||||
|
vmin=0,
|
||||||
|
vmax=np.nanquantile(U, 0.99),
|
||||||
|
zorder=1,
|
||||||
|
alpha=1 - np.nan_to_num(AW[0]).clip(0, 1),
|
||||||
)
|
)
|
||||||
# aw_u = axU.contour(X, Z, AW[0], levels=(.5,))
|
# aw_u = axU.contour(X, Z, AW[0], levels=(.5,))
|
||||||
figU.colorbar(u_m)
|
figU.colorbar(u_m)
|
||||||
|
|
|
@ -29,9 +29,11 @@ config.read(args.config)
|
||||||
out = pathlib.Path(config.get("post", "out"))
|
out = pathlib.Path(config.get("post", "out"))
|
||||||
out.mkdir(parents=True, exist_ok=True)
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with gzip.open(gzf, "rb") if (
|
with (
|
||||||
gzf := out.joinpath("pickle.gz")
|
path.open("rb")
|
||||||
).exists() else gzf.with_suffix("").open("rb") as f:
|
if (path := out.joinpath("pickle")).exists()
|
||||||
|
else gzip.open(path.with_suffix(".gz"), "rb")
|
||||||
|
) as f:
|
||||||
model = pickle.load(f)
|
model = pickle.load(f)
|
||||||
|
|
||||||
x0_conf = config.getfloat("post", "x")
|
x0_conf = config.getfloat("post", "x")
|
||||||
|
@ -81,8 +83,8 @@ with plt.rc_context(
|
||||||
list(
|
list(
|
||||||
starmap(lambda x, z: f"x={x:8}m; z={z:8}m", zip(model.x[i0], model.z[i0]))
|
starmap(lambda x, z: f"x={x:8}m; z={z:8}m", zip(model.x[i0], model.z[i0]))
|
||||||
),
|
),
|
||||||
bbox_to_anchor=(1.05, .5),
|
bbox_to_anchor=(1.05, 0.5),
|
||||||
loc="center left"
|
loc="center left",
|
||||||
)
|
)
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
|
@ -44,7 +44,7 @@ olaflow_root = args.output
|
||||||
model = OFModel(olaflow_root)
|
model = OFModel(olaflow_root)
|
||||||
model.read_mesh()
|
model.read_mesh()
|
||||||
|
|
||||||
level = config.getfloat("bathy", "level", fallback=0.)
|
level = config.getfloat("bathy", "level", fallback=0.0)
|
||||||
watl_t = interpolate.interp1d(x, watl[arg_t0] + level)
|
watl_t = interpolate.interp1d(x, watl[arg_t0] + level)
|
||||||
alpha_water = np.where(model.z < watl_t(model.x), 1, 0)
|
alpha_water = np.where(model.z < watl_t(model.x), 1, 0)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ log = logging.getLogger("sws_ola")
|
||||||
log.info("Starting sws -> olaFlow converter")
|
log.info("Starting sws -> olaFlow converter")
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(args.config)
|
config.read(args.config)
|
||||||
level = config.getfloat("bathy", "level", fallback=0.)
|
level = config.getfloat("bathy", "level", fallback=0.0)
|
||||||
|
|
||||||
sws_out = pathlib.Path(config.get("swash", "np_out"))
|
sws_out = pathlib.Path(config.get("swash", "np_out"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue