From f89616807165af3a3592de5e2d21122aec344a90 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Fri, 11 Mar 2022 14:42:42 +0100 Subject: [PATCH] Use high res smoothed bathymetry for breakwater --- data/config.ini | 2 ++ data/data/Hstru.dat | 0 data/data/Poro.dat | 0 data/data/Psize.dat | 0 data/data/bathyhires.dat | 0 data/data/buoyarthabathy.dat | 0 data/processing/projection.py | 37 ++++++++++++++++++++++++++++++++++- 7 files changed, 38 insertions(+), 1 deletion(-) mode change 100755 => 100644 data/data/Hstru.dat mode change 100755 => 100644 data/data/Poro.dat mode change 100755 => 100644 data/data/Psize.dat mode change 100755 => 100644 data/data/bathyhires.dat mode change 100755 => 100644 data/data/buoyarthabathy.dat diff --git a/data/config.ini b/data/config.ini index 9d968b8..d8da6b7 100644 --- a/data/config.ini +++ b/data/config.ini @@ -1,5 +1,7 @@ [bathy] inp=data/Database_20220224.xyz +hires=data/bathyhires.dat +hires_step=0.5 sub=out/bathy_sub.npy out=out/bathy.npy step=1 diff --git a/data/data/Hstru.dat b/data/data/Hstru.dat old mode 100755 new mode 100644 diff --git a/data/data/Poro.dat b/data/data/Poro.dat old mode 100755 new mode 100644 diff --git a/data/data/Psize.dat b/data/data/Psize.dat old mode 100755 new mode 100644 diff --git a/data/data/bathyhires.dat b/data/data/bathyhires.dat old mode 100755 new mode 100644 diff --git a/data/data/buoyarthabathy.dat b/data/data/buoyarthabathy.dat old mode 100755 new mode 100644 diff --git a/data/processing/projection.py b/data/processing/projection.py index 6a7b2dd..ae62196 100644 --- a/data/processing/projection.py +++ b/data/processing/projection.py @@ -21,6 +21,7 @@ config = configparser.ConfigParser() config.read("config.ini") bathy_inp = pathlib.Path(config.get("bathy", "sub")) +hires_inp = pathlib.Path(config.get("bathy", "hires")) bathy_out = pathlib.Path(config.get("bathy", "out")) log.info(f"Loading bathymetry from {bathy_inp}") @@ -58,6 +59,40 @@ coords = artha + (x * np.stack((np.cos(theta), np.sin(theta)))).T log.info("Interpolating bathymetry in 1D") z = interpolate.griddata(bathy[:, :2], bathy[:, 2], coords) -log.debug(z) +log.debug(f"z: {z}") +_hires = np.genfromtxt(hires_inp)[::-1] +bathy_hires = np.stack( + ( + np.linspace( + 0, + (_hires.size - 1) * config.getfloat("bathy", "hires_step"), + _hires.size, + ), + _hires, + ), + axis=1, +) +del _hires +log.debug(f"Bathy hires: {bathy_hires}") +z_cr = 5 +hires_crossing = np.diff(np.signbit(bathy_hires[:, 1] - z_cr)).nonzero()[0][-1] +log.debug(f"Hires crossing: {hires_crossing}") +z_crossing = np.diff(np.signbit(z - z_cr)).nonzero()[0][-1] +log.debug(f"Z crossing: {z_crossing}") + +x_min_hires = x[z_crossing] + ( + bathy_hires[:, 0].min() - bathy_hires[hires_crossing, 0] +) +x_max_hires = x[z_crossing] + ( + bathy_hires[:, 0].max() - bathy_hires[hires_crossing, 0] +) +log.debug(f"Replacing range: [{x_min_hires},{x_max_hires}]") + +flt_x = (x > x_min_hires) & (x < x_max_hires) +z[flt_x] = interpolate.griddata( + (bathy_hires[:, 0],), + bathy_hires[:, 1], + (x[flt_x] - x[z_crossing] + bathy_hires[hires_crossing, 0]), +)