1
Fork 0

Black reformat + favor non gzip pickle

This commit is contained in:
Edgar P. Burkhart 2022-04-15 10:31:55 +02:00
parent ec5a503c63
commit 47bf31fb3a
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 36 additions and 19 deletions

View file

@ -27,9 +27,11 @@ config.read(args.config)
out = pathlib.Path(config.get("post", "out"))
out.mkdir(parents=True, exist_ok=True)
with gzip.open(gzf, "rb") if (
gzf := out.joinpath("pickle.gz")
).exists() else gzf.with_suffix("").open("rb") as f:
with (
path.open("rb")
if (path := out.joinpath("pickle")).exists()
else gzip.open(path.with_suffix(".gz"), "rb")
) as f:
model = pickle.load(f)
x0 = config.getfloat("post", "x")
@ -85,13 +87,26 @@ def anim(i):
aw_m.set_array(AW[i])
figU, axU = plt.subplots(figsize=(19.2, 10.8), dpi=100)
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(
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,))
figU.colorbar(u_m)

View file

@ -29,9 +29,11 @@ config.read(args.config)
out = pathlib.Path(config.get("post", "out"))
out.mkdir(parents=True, exist_ok=True)
with gzip.open(gzf, "rb") if (
gzf := out.joinpath("pickle.gz")
).exists() else gzf.with_suffix("").open("rb") as f:
with (
path.open("rb")
if (path := out.joinpath("pickle")).exists()
else gzip.open(path.with_suffix(".gz"), "rb")
) as f:
model = pickle.load(f)
x0_conf = config.getfloat("post", "x")
@ -81,8 +83,8 @@ with plt.rc_context(
list(
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),
loc="center left"
bbox_to_anchor=(1.05, 0.5),
loc="center left",
)
plt.show()

View file

@ -44,7 +44,7 @@ olaflow_root = args.output
model = OFModel(olaflow_root)
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)
alpha_water = np.where(model.z < watl_t(model.x), 1, 0)

View file

@ -22,7 +22,7 @@ log = logging.getLogger("sws_ola")
log.info("Starting sws -> olaFlow converter")
config = configparser.ConfigParser()
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"))