Server side scripts & all

This commit is contained in:
Edgar P. Burkhart 2022-06-24 16:50:38 +02:00
parent a000c67e93
commit b92e52ecbb
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
20 changed files with 629 additions and 58 deletions

29
data/config2.ini Normal file
View file

@ -0,0 +1,29 @@
[inp]
root=data
base=Database_20220224.xyz
hires=bathyhires.dat
hstru=Hstru.dat
poro=Poro.dat
psize=Psize.dat
raw_ts=cerema/raw/201702281700.raw
raw_spec=cerema/spt/201702281715.spt
hires_step=0.5
cycle=14400
[out]
margin=0.005
#no_breakwater=True
root=out2
sub=bathy_sub.npy
out=bathy.npy
step=1
left=-300
right=150
[artha]
lat=43.398450
lon=-1.673097
[buoy]
lat=43.408333
lon=-1.681667

View file

@ -4,6 +4,7 @@ import logging
import pathlib
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
import numpy as np
parser = argparse.ArgumentParser(description="Plot orbitals")
@ -85,16 +86,18 @@ fig2dv, ax2dv = plt.subplots(figsize=(5/2.54, 2/3*10/2.54), dpi=200, constrained
x0 = ts_flt["x"] * np.cos(theta) + ts_flt["y"] * np.sin(theta)
#ax2dv.plot(x0, z0, c="#0066ff", lw=1)
ax2dv.quiver(
x0[:-1],
z0[:-1],
np.diff(x0)[:],
np.diff(z0)[:],
x0[:-1] * 1e-2,
z0[:-1] * 1e-2,
np.diff(x0)[:] * 1e-2,
np.diff(z0)[:] * 1e-2,
color="k",
scale_units="xy",
scale=1,
)
ax2dv.grid(c="k", alpha=.2)
ax2dv.set(aspect="equal", xlabel="x (cm)", ylabel="z (cm)")
ax2dv.set(aspect="equal", xlabel="x (m)", ylabel="z (m)")
ax2dv.set(ylim=(-10, 10))
ax2dv.yaxis.set_minor_locator(MultipleLocator(1))
fig2dv.savefig("out_orbitals.pdf")
fig2dv.savefig("out_orbitals.jpg")

View file

@ -131,8 +131,12 @@ np.savetxt(out_root.joinpath("hstru.dat"), hstru[::-1], newline=" ")
np.savetxt(out_root.joinpath("poro.dat"), poro[::-1], newline=" ")
np.savetxt(out_root.joinpath("psize.dat"), psize[::-1], newline=" ")
fig, ax = plt.subplots()
fig, ax = plt.subplots(figsize=(16 / 2.54, 2 / 3 * 10 / 2.54), constrained_layout=True)
ax.plot(-x, z, color="k")
ax.fill_between(-x, z + hstru, z, color="k", alpha=0.2)
ax.set_title(f"N={z.size-1}, x=[{-x.max()};{-x.min()}]")
#ax.set_title(f"N={z.size-1}, x=[{-x.max()};{-x.min()}]")
ax.set(ylim=(-30, 15))
ax.set(xlabel="x (m)", ylabel="z (m)")
ax.autoscale(True, "x", True)
ax.grid()
fig.savefig(out_root.joinpath("bathy.pdf"))

View file

@ -45,7 +45,7 @@ if cycle is None:
f = inp["f"]
S = inp["S"] * Sm
else:
f = np.arange(inp["f"].min(), inp["f"].max() + 1/cycle, 1/cycle)
f = np.arange(inp["f"].min(), inp["f"].max() + 1 / cycle, 1 / cycle)
S = griddata(inp["f"], inp["S"] * Sm, f)
with out_spec.open("w") as out:

View file

@ -4,6 +4,7 @@ import logging
import pathlib
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
import numpy as np
parser = argparse.ArgumentParser(description="Pre-process time-series")
@ -25,12 +26,14 @@ out_ts = out_root.joinpath("ts.dat")
raw_ts = []
for tsi in config.get("inp", "raw_ts").split(","):
raw_ts.append(np.loadtxt(
inp_root.joinpath(tsi),
dtype=[("state", int), ("z", float), ("y", float), ("x", float)],
delimiter=",",
max_rows=2304,
))
raw_ts.append(
np.loadtxt(
inp_root.joinpath(tsi),
dtype=[("state", int), ("z", float), ("y", float), ("x", float)],
delimiter=",",
max_rows=2304,
)
)
n = len(raw_ts)
raw_ts = np.concatenate(raw_ts)
log.debug(f"{raw_ts=}")
@ -39,13 +42,43 @@ if (errs := np.count_nonzero(raw_ts["state"])) != 0:
log.warning(f"{errs} transmission errors!")
log.debug(f"{dict(zip(*np.unique(raw_ts['state'], return_counts=True)))}")
t = np.linspace(0, 30 * 60 * n, 2304*n+1)[:-1]
t = np.linspace(0, 30 * 60 * n, 2304 * n + 1)[:-1]
log.debug(f"{t=}")
log.info(f"Saving timeseries to '{out_ts}'")
np.savetxt(out_ts, np.stack((t, raw_ts["z"]/100), axis=1))
np.savetxt(out_ts, np.stack((t, raw_ts["z"] / 100), axis=1))
fig, ax = plt.subplots()
ax.plot(t, raw_ts["z"])
ax.set(xlabel="t (s)", ylabel="z (cm)")
fig, ax = plt.subplots(figsize=(8 / 2.54, 2 / 3 * 10 / 2.54), constrained_layout=True)
tp = np.datetime64("2017-02-28T17:00:00") + t.astype(np.timedelta64)[-(t.size // 3) :]
ax.plot(
tp,
raw_ts["z"][-(t.size // 3) :] * 1e-2,
color="k",
lw=1,
)
ax.axvline(
np.datetime64("2017-02-28T17:00:00") + np.timedelta64(23 * 60 + 8),
color="k",
alpha=0.1,
lw=20,
)
ax.autoscale(True, "x", True)
ax.set(xlabel="t (s)", ylabel="z (m)")
yabs_max = abs(max(ax.get_ylim(), key=abs))
ax.set(ylim=(-10, 10))
ax.set(
xticks=(
np.datetime64("2017-02-28T17:20:00"),
np.datetime64("2017-02-28T17:25:00"),
np.datetime64("2017-02-28T17:30:00"),
),
xticklabels=(
"17:20",
"17:25",
"17:30",
),
)
ax.yaxis.set_minor_locator(MultipleLocator(1))
ax.grid(color="k", alpha=0.2)
fig.savefig(out_root.joinpath("ts.pdf"))
fig.savefig(out_root.joinpath("ts.jpg"), dpi=200)