diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..e2e7327 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1 @@ +/out diff --git a/data/config.ini b/data/config.ini index e0e702f..9d968b8 100644 --- a/data/config.ini +++ b/data/config.ini @@ -1,7 +1,8 @@ [bathy] -inp=Database_20220224.xyz -sub=bathy_sub.npy -out=bathy.npy +inp=data/Database_20220224.xyz +sub=out/bathy_sub.npy +out=out/bathy.npy +step=1 [artha] lat=43.398450 diff --git a/data/processing/projection.py b/data/processing/projection.py index 4f63591..6a7b2dd 100644 --- a/data/processing/projection.py +++ b/data/processing/projection.py @@ -32,7 +32,7 @@ bathy = np.stack( *projection.cartesian(bathy_curvi[:, 0], bathy_curvi[:, 1]), bathy_curvi[:, 2], ), - axis=1 + axis=1, ) log.debug(f"Cartesian bathy: {bathy}") @@ -46,37 +46,18 @@ buoy_curvi = np.array( artha = np.asarray(projection.cartesian(*artha_curvi)) buoy = np.asarray(projection.cartesian(*buoy_curvi)) - -def display(): - x = np.linspace(bathy[:, 0].min(), bathy[:, 0].max()) - y = np.linspace(bathy[:, 1].min(), bathy[:, 1].max()) - - X, Y = np.meshgrid(x, y) - - Z = interpolate.griddata( - bathy[:, :2], bathy[:, 2], (X, Y), method="nearest" - ) - - fix, ax = plt.subplots() - ax.pcolormesh(X, Y, Z) - ax.scatter(*artha, c="k") - ax.scatter(*buoy, c="k") - - ax.axis("equal") - return ax - - D = np.diff(np.stack((artha, buoy)), axis=0) -x = np.arange(-150, np.sqrt((D**2).sum()) + 150) +x = np.arange( + -150, + np.sqrt((D**2).sum()) + 150, + config.getfloat("bathy", "step", fallback=1), +) theta = np.angle(D.dot((1, 1j))) coords = artha + (x * np.stack((np.cos(theta), np.sin(theta)))).T -z = interpolate.griddata(bathy[:,:2], bathy[:,2], coords) +log.info("Interpolating bathymetry in 1D") +z = interpolate.griddata(bathy[:, :2], bathy[:, 2], coords) +log.debug(z) -ax = display() -ax.scatter(*coords.T, c="k", marker=".") -fig_1d, ax_1d = plt.subplots() -ax_1d.plot(x, z) -plt.show(block=True)