Updated mat processing
This commit is contained in:
parent
bd0fef00a0
commit
eff2b09c8f
1 changed files with 27 additions and 6 deletions
|
@ -27,8 +27,10 @@ inp.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
log.info(f"Reading swash output from '{sws_out}'")
|
log.info(f"Reading swash output from '{sws_out}'")
|
||||||
raw_tsec = sio.loadmat(sws_out.joinpath("tsec.mat"))
|
raw_tsec = sio.loadmat(sws_out.joinpath("tsec.mat"))
|
||||||
i = np.fromiter((k[5:] for k in raw_tsec.keys() if re.compile(r"^Tsec_").match(k)), dtype="U10")
|
i = np.fromiter(
|
||||||
t = np.fromiter((raw_tsec[f"Tsec_{k}"][0,0]*10**3 for k in i), dtype=np.uintc)
|
(k[5:] for k in raw_tsec.keys() if re.compile(r"^Tsec_").match(k)), dtype="U10"
|
||||||
|
)
|
||||||
|
t = np.fromiter((raw_tsec[f"Tsec_{k}"][0, 0] * 10**3 for k in i), dtype=np.uintc)
|
||||||
np.save(inp.joinpath("t"), t)
|
np.save(inp.joinpath("t"), t)
|
||||||
del raw_tsec
|
del raw_tsec
|
||||||
raw_xp = sio.loadmat(sws_out.joinpath("xp.mat"), variable_names="Xp")
|
raw_xp = sio.loadmat(sws_out.joinpath("xp.mat"), variable_names="Xp")
|
||||||
|
@ -39,14 +41,33 @@ del raw_xp
|
||||||
raw_botl = sio.loadmat(sws_out.joinpath("botl.mat"), variable_names="Botlev")
|
raw_botl = sio.loadmat(sws_out.joinpath("botl.mat"), variable_names="Botlev")
|
||||||
botl = raw_botl["Botlev"][0]
|
botl = raw_botl["Botlev"][0]
|
||||||
np.save(inp.joinpath("botl"), botl)
|
np.save(inp.joinpath("botl"), botl)
|
||||||
del raw_botl
|
del raw_botl, botl
|
||||||
|
|
||||||
raw_watl = sio.loadmat(sws_out.joinpath("watl.mat"))
|
raw_watl = sio.loadmat(sws_out.joinpath("watl.mat"))
|
||||||
watl = np.asarray([raw_watl[i0][0] for i0 in np.char.add("Watlev_", i)], dtype=np.single)
|
watl = np.asarray(
|
||||||
|
[raw_watl[i0][0] for i0 in np.char.add("Watlev_", i)], dtype=np.single
|
||||||
|
)
|
||||||
np.save(inp.joinpath("watl"), watl)
|
np.save(inp.joinpath("watl"), watl)
|
||||||
del raw_watl
|
del raw_watl, watl
|
||||||
|
|
||||||
raw_vel = sio.loadmat(sws_out.joinpath("vel.mat"))
|
raw_vel = sio.loadmat(sws_out.joinpath("vel.mat"))
|
||||||
vel_x = np.asarray([raw_vel[i0][0] for i0 in np.char.add("vel_x_", i)], dtype=np.single)
|
vel_x = np.asarray([raw_vel[i0][0] for i0 in np.char.add("vel_x_", i)], dtype=np.single)
|
||||||
np.save(inp.joinpath("vel_x"), vel_x)
|
np.save(inp.joinpath("vel_x"), vel_x)
|
||||||
del raw_vel
|
del raw_vel, vel_x
|
||||||
|
|
||||||
|
raw_zk = sio.loadmat(sws_out.joinpath("zk.mat"))
|
||||||
|
n_zk = (len(raw_zk.keys()) - 3) // t.size
|
||||||
|
zk = np.asarray(
|
||||||
|
[
|
||||||
|
raw_zk[i0][0]
|
||||||
|
for i0 in np.char.add(
|
||||||
|
np.char.replace("zki_", "i", np.arange(n_zk).astype("U1"), count=1)[
|
||||||
|
None, :
|
||||||
|
],
|
||||||
|
i[:, None],
|
||||||
|
).reshape(-1)
|
||||||
|
],
|
||||||
|
dtype=np.single,
|
||||||
|
).reshape((t.size, n_zk, x.size))
|
||||||
|
np.save(inp.joinpath("zk"), zk)
|
||||||
|
del raw_zk, zk
|
||||||
|
|
Loading…
Reference in a new issue