1
Fork 0

Black+isort, layers, vz in sws_npz

This commit is contained in:
Edgar P. Burkhart 2022-03-16 07:50:44 +01:00
parent ce3de3f932
commit 934b391e59
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
5 changed files with 49 additions and 25 deletions

View file

@ -19,9 +19,9 @@ out=out_sws
mpi=4 mpi=4
[post] [post]
inp=inp_post inp=inp_post_test
case=sws_spec_buoy.npz #case=sws_spec_buoy.npz
compare=sws_spec_buoy_nb.npz #compare=sws_spec_buoy_nb.npz
out=out_post out=out_post
#nperseg=1024 #nperseg=1024
dt=0.25 dt=0.25

View file

@ -3,12 +3,11 @@ import configparser
import logging import logging
import pathlib import pathlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation import matplotlib.animation as animation
import matplotlib.pyplot as plt
import numpy as np import numpy as np
import pandas as pd import pandas as pd
parser = argparse.ArgumentParser(description="Animate swash output") parser = argparse.ArgumentParser(description="Animate swash output")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
args = parser.parse_args() args = parser.parse_args()

View file

@ -3,12 +3,11 @@ import configparser
import logging import logging
import pathlib import pathlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation import matplotlib.animation as animation
import matplotlib.pyplot as plt
import numpy as np import numpy as np
import pandas as pd import pandas as pd
parser = argparse.ArgumentParser(description="Animate swash output") parser = argparse.ArgumentParser(description="Animate swash output")
parser.add_argument("-v", "--verbose", action="count", default=0) parser.add_argument("-v", "--verbose", action="count", default=0)
args = parser.parse_args() args = parser.parse_args()
@ -39,31 +38,55 @@ watl = data("watl")
botl = data("botl") botl = data("botl")
zk = data("zk") zk = data("zk")
velk = data("velk") velk = data("velk")
vz = data("vz")
wl = np.maximum(watl, -botl) wl = np.maximum(watl, -botl)
# print(x.size, -np.arange(0, 1 * bathy.hstru.size, 1)[::-1].size) # print(x.size, -np.arange(0, 1 * bathy.hstru.size, 1)[::-1].size)
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.plot(x, -botl, c="k") # ax.plot(x, -botl, c="k")
# ax.fill_between( # ax.fill_between(
# x, -botl, -data["botl"] + bathy.hstru, color="k", alpha=0.2 # x, -botl, -data["botl"] + bathy.hstru, color="k", alpha=0.2
# ) # )
lines = ax.plot(x, zk[0].T)
print(velk.shape) n = 0
velk = velk.reshape((6001, 10, 2, 1251)) velk = velk.reshape((6001, 10, 2, 1251))
vk = np.sqrt((velk[1000] ** 2).sum(axis=1)) vk = np.sqrt((velk[n] ** 2).sum(axis=1))
print(vk.shape) # print(vk.shape)
plt.imshow(vk) # plt.imshow(vk)
plt.colorbar() # plt.colorbar()
# def animate(i): lines = ax.plot(x, zk[n].T, c="#0066cc")
# for line, z in zip(lines, zk[i]): quiv = []
# line.set_ydata(z) for i in range(10):
# return lines quiv.append(
# ax.quiver(
# ani = animation.FuncAnimation( x[::50],
# fig, animate, frames=wl[:, 0].size, interval=20, blit=True (zk[n, i, ::50] + zk[n, i + 1, ::50]) / 2,
# ) velk[n, i, 0, ::50],
vz[n, i, ::50],
units="dots",
width=2,
scale=0.05,
)
)
ax.autoscale(True, "w", True)
ax.set_ylim(top=15)
def animate(k):
for i, q in enumerate(quiv):
q.set_UVC(
velk[k, i, 0, ::50],
vz[k, i, ::50],
)
for i, l in enumerate(lines):
l.set_ydata(zk[k, i])
ani = animation.FuncAnimation(
fig, animate, frames=wl[:, 0].size, interval=20, blit=True
)
plt.show(block=True) plt.show(block=True)

View file

@ -5,8 +5,8 @@ import pathlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
import scipy.signal as sgl
import scipy.fft as fft import scipy.fft as fft
import scipy.signal as sgl
from .read_swash import * from .read_swash import *

View file

@ -1,8 +1,8 @@
import argparse import argparse
import configparser import configparser
import logging import logging
from multiprocessing.pool import ThreadPool
import pathlib import pathlib
from multiprocessing.pool import ThreadPool
import numpy as np import numpy as np
import pandas as pd import pandas as pd
@ -36,6 +36,7 @@ var = {
"press": rsws.read_scalar, "press": rsws.read_scalar,
"zk": rsws.read_scalar_lay, "zk": rsws.read_scalar_lay,
"velk": rsws.read_vector_lay, "velk": rsws.read_vector_lay,
"vz": rsws.read_scalar_lay,
} }
inp.mkdir(exist_ok=True) inp.mkdir(exist_ok=True)
@ -43,7 +44,8 @@ with ThreadPool() as pool:
log.info("Converting all data") log.info("Converting all data")
pool.map( pool.map(
lambda x: np.save( lambda x: np.save(
inp.joinpath(x[0]), x[1](sws_out.joinpath(x[0]).with_suffix(".dat")) inp.joinpath(x[0]),
x[1](sws_out.joinpath(x[0]).with_suffix(".dat")),
), ),
var.items(), var.items(),
) )