LFS wtf
This commit is contained in:
parent
71049d49ea
commit
ba675fb763
68 changed files with 5727 additions and 204 deletions
4
data/.gitignore
vendored
4
data/.gitignore
vendored
|
@ -1,3 +1 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:17bc194f27793ae12ccd604a1f667d03cc6f9b07222f4e67d633b7296cc97e24
|
||||
size 5
|
||||
/out
|
||||
|
|
|
@ -1,3 +1,26 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:13605228ca2c48f7bc869db92b329f5395122662ced9a7ce930241b821a11f7a
|
||||
size 300
|
||||
[inp]
|
||||
root=data
|
||||
base=Database_20220224.xyz
|
||||
hires=bathyhires.dat
|
||||
hstru=Hstru.dat
|
||||
poro=Poro.dat
|
||||
psize=Psize.dat
|
||||
hires_step=0.5
|
||||
|
||||
[out]
|
||||
no_breakwater=True
|
||||
root=out
|
||||
sub=bathy_sub.npy
|
||||
out=bathy.npy
|
||||
step=1
|
||||
left=0
|
||||
right=150
|
||||
#plot=True
|
||||
|
||||
[artha]
|
||||
lat=43.398450
|
||||
lon=-1.673097
|
||||
|
||||
[buoy]
|
||||
lat=43.408333
|
||||
lon=-1.681667
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:752dec83ecb9ee7fb94f4b1d2f46ce0e4ebbf504002714b798e704fd705e64e8
|
||||
size 2639
|
||||
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.09053913636363475 0.12857195454545334 0.1106843636363628 0.08742181818181649 0.05449704545454637 0.19579977272727156 0.47464572727272625 0.7977639000000014 1.2037601545454546 1.5225200999999977 1.7882055545454527 2.024811236363634 2.256461418181816 2.7078580227272706 3.3284555954545443 4.016352159090907 4.587657986363634 4.972522395454543 5.264216395454545 5.512329618181816 5.8869764545454535 6.372828168181817 6.94589004090909 7.571161649999999 8.023941072727272 8.39270449090909 8.77935388181818 8.805197545454547 8.601612395454545 8.292523681818182 7.930243750000001 7.646413318181818 7.526211804545455 7.564564154090908 7.746881157727273 7.834589710454546 7.754542366818181 7.49324825090909 7.207938067272727 7.178323675454545 7.217737861818183 7.161903220909092 7.1852990436363635 7.206258208636364 7.038393730000001 6.763687682727273 6.502847790000001 6.291055629545454 6.077600841363637 5.790635207727273 5.443607505909091 5.103184435909092 4.86922702 4.617471335454545 4.3047238850000005 4.031671995909091 3.8282986531818186 3.6257627568181823 3.385370432272728 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 1.8351631188311681 1.8344353740259738 1.8088506428571423 1.7847644344155826 1.7829720396103879 1.7923390038961013 1.7139384863636344 1.6436818051948028 1.6240780240259713 1.60447424285714 1.4623914616883082 1.320308680519477 1.1642865493506456 1.0082644181818141 0.8563518870129894 0.7044393558441584 0.5246033246753274 0.3447672935064956 0.16403271233766414 -0.01670186883116731 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
|
|
@ -1,3 +1 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0b1ea84701b4c5daa9e37293b3a8c84aff9357a425969c5d1720f13ab4ec7606
|
||||
size 1308
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0.25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
|
@ -1,3 +1 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:eaa82206c1a952bdfd10ba322149514d2a3aaf7db7a08d0f89d96fa282bfdc43
|
||||
size 900
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
|
@ -1,3 +1 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cd7a7e42abc9ec28c5cfe91964e8cb6d7807a947463cd708edf835386b6f5c2c
|
||||
size 4809
|
||||
-16.0 -16.0 -16.0 -16.0 -16.0 -16.0 -16.0 -16.0 -16.0 -16.0030005 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -16.006001 -15.943623500000001 -15.881246 -15.816197500000001 -15.751149 -15.773361 -15.795573 -15.8146685 -15.833764 -15.778788 -15.723812 -15.689659 -15.655506 -15.6387295 -15.621953 -15.661657 -15.701361 -15.7411355 -15.78091 -15.755651499999999 -15.730393 -15.688119 -15.645845 -15.631902499999999 -15.61796 -15.589325500000001 -15.560691 -15.5670085 -15.573326 -15.486844 -15.400362 -15.214036 -15.02771 -14.9567825 -14.885855 -14.882393 -14.878931 -14.9088545 -14.938778 -14.8344285 -14.730079 -14.7571455 -14.784212 -14.7689165 -14.753621 -14.7533025 -14.752984 -14.706036000000001 -14.659088 -14.7279955 -14.796903 -14.814821 -14.832739 -14.8244145 -14.81609 -14.7981595 -14.780229 -14.771710500000001 -14.763192 -14.7391665 -14.715141 -14.759877 -14.804613 -14.762627 -14.720641 -14.789644500000001 -14.858648 -14.862199 -14.86575 -14.799389999999999 -14.73303 -14.760145999999999 -14.787262 -14.737239500000001 -14.687217 -14.715263 -14.743309 -14.737463 -14.731617 -14.7335975 -14.735578 -14.7440185 -14.752459 -14.800866 -14.849273 -14.8300105 -14.810748 -14.7690775 -14.727407 -14.699237 -14.671067 -14.697172 -14.723277 -14.7142905 -14.705304 -14.6880615 -14.670819 -14.727667 -14.784515 -14.708768 -14.633021 -14.675764999999998 -14.718509 -14.597324 -14.476139 -14.459793999999999 -14.443449 -14.4187075 -14.393966 -14.3316695 -14.002316272727272 -13.855776363636364 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.73685518181818 -13.480393763636364 -13.02899715909091 -12.408399586363636 -11.720503022727273 -11.149197195454546 -10.764332786363637 -10.472638786363635 -10.224525563636364 -9.849878727272728 -9.364027013636363 -8.79096514090909 -8.165693531818182 -7.712914109090909 -7.344150690909092 -6.9575013000000006 -6.675196218181818 -6.427384763636364 -6.115875904545455 -5.790259272727273 -5.502783877272728 -5.238120981818182 -4.9080746322727276 -4.477644405909091 -4.015289016818182 -3.6094846468181823 -3.2977168900000002 -2.9577554645454542 -2.534590433636364 -2.126412829090909 -1.795598079090909 -1.4898971745454546 -1.2211265550000001 0.18171014090909088 0.225112168181818 0.2626339090909089 0.3160848454545455 0.3755115090909089 0.44294754090909105 0.5119367499999998 0.579982840909091 0.6242613363636367 0.6613643272727274 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.7182761454545452 0.8831130266233771 1.0479499077922085 1.21278678896104 1.3776236701298714 1.5424605512987029 1.7072974324675343 1.8721343136363657 2.036971194805197 2.2018080759740286 2.36664495714286 2.5314818383116915 2.696318719480523 2.8611556006493544 3.025992481818186 3.19082936298701 3.3556662441558416 3.520503125324673 3.6853400064935045 3.850176887662336 4.015013768831167 4.1798506500000006 4.3613894 5.0562667 5.751144 7.12597825 8.5008125 8.95175665 9.4027008 9.39748715 9.3922735 9.389079899999999 9.3858863 9.3923233 9.3987603 9.394938549999999 9.3911168 9.3864873 9.3818578 9.364699 9.3475402 9.3475402
|
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,100 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:418acad81c40d8d5dcde803335a86309b51121bab736b553a60c0735ff98cc19
|
||||
size 2601
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Lambert:
|
||||
def __init__(
|
||||
self,
|
||||
X0=1.7e6,
|
||||
Y0=2.2e6,
|
||||
lambda0=3,
|
||||
phi0=43,
|
||||
phi1=42.25,
|
||||
phi2=43.75,
|
||||
a=6378137,
|
||||
e=0.081819190842622,
|
||||
):
|
||||
self._X0 = X0
|
||||
self._Y0 = Y0
|
||||
|
||||
self._lambda0 = np.radians(lambda0)
|
||||
self._phi0 = np.radians(phi0)
|
||||
self._phi1 = np.radians(phi1)
|
||||
self._phi2 = np.radians(phi2)
|
||||
|
||||
self._a = a
|
||||
self._e = e
|
||||
|
||||
self._set_n()
|
||||
self._set_rho0()
|
||||
|
||||
def cartesian(self, lam, phi):
|
||||
lam = np.radians(lam)
|
||||
phi = np.radians(phi)
|
||||
|
||||
theta = self._n * (lam - self._lambda0)
|
||||
rho = self._rho(phi)
|
||||
rho0 = self._rho(self._phi0)
|
||||
|
||||
X = self._X0 + rho * np.sin(theta)
|
||||
Y = self._Y0 + rho0 - rho * np.cos(theta)
|
||||
|
||||
return X, Y
|
||||
|
||||
def _set_n(self):
|
||||
self._n = (
|
||||
np.log(np.cos(self._phi2) / np.cos(self._phi1))
|
||||
+ (
|
||||
np.log(
|
||||
(1 - (self._e * np.sin(self._phi1) ** 2))
|
||||
/ (1 - (self._e * np.sin(self._phi2) ** 2))
|
||||
)
|
||||
/ 2
|
||||
)
|
||||
) / (
|
||||
np.log(
|
||||
(
|
||||
np.tan(self._phi1 / 2 + np.pi / 4)
|
||||
* (
|
||||
(1 - self._e * np.sin(self._phi2))
|
||||
* (1 + self._e * np.sin(self._phi1))
|
||||
)
|
||||
** (self._e / 2)
|
||||
)
|
||||
/ (
|
||||
np.tan(self._phi2 / 2 + np.pi / 4)
|
||||
* (
|
||||
(1 + self._e * np.sin(self._phi2))
|
||||
* (1 - self._e * np.sin(self._phi1))
|
||||
)
|
||||
** (self._e / 2)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def _set_rho0(self):
|
||||
self._rho0 = (
|
||||
self._a
|
||||
* np.cos(self._phi1)
|
||||
/ (self._n * np.sqrt(1 - self._e**2 * np.sin(self._phi1) ** 2))
|
||||
* (
|
||||
np.tan(self._phi1 / 2 + np.pi / 4)
|
||||
* (
|
||||
(1 - self._e * np.sin(self._phi1))
|
||||
/ (1 + self._e * np.sin(self._phi1))
|
||||
)
|
||||
** (self._e / 2)
|
||||
)
|
||||
** self._n
|
||||
)
|
||||
|
||||
def _rho(self, phi):
|
||||
return (
|
||||
self._rho0
|
||||
* (
|
||||
1
|
||||
/ np.tan(phi / 2 + np.pi / 4)
|
||||
* ((1 + self._e * np.sin(phi)) / (1 - self._e * np.sin(phi)))
|
||||
** (self._e / 2)
|
||||
)
|
||||
** self._n
|
||||
)
|
||||
|
|
|
@ -1,3 +1,144 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:45448faf5475a6aac61efe9b3f69e20a7e44bdcb7e493d7e8d7c8d1cb7eac5fd
|
||||
size 4370
|
||||
import argparse
|
||||
import configparser
|
||||
import logging
|
||||
import pathlib
|
||||
|
||||
import numpy as np
|
||||
from scipy import interpolate
|
||||
try:
|
||||
import matplotlib.pyplot as plt
|
||||
except ImportError:
|
||||
plt = None
|
||||
|
||||
from .lambert import Lambert
|
||||
|
||||
parser = argparse.ArgumentParser(description="Pre-process bathymetry")
|
||||
parser.add_argument("-v", "--verbose", action="count", default=0)
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
|
||||
log = logging.getLogger("bathy")
|
||||
|
||||
log.info("Starting bathymetry pre-processing")
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config.ini")
|
||||
|
||||
inp_root = pathlib.Path(config.get("inp", "root"))
|
||||
out_root = pathlib.Path(config.get("out", "root"))
|
||||
bathy_inp = out_root.joinpath(config.get("out", "sub"))
|
||||
hires_inp = inp_root.joinpath(config.get("inp", "hires"))
|
||||
hstru_inp = inp_root.joinpath(config.get("inp", "hstru"))
|
||||
poro_inp = inp_root.joinpath(config.get("inp", "poro"))
|
||||
psize_inp = inp_root.joinpath(config.get("inp", "psize"))
|
||||
bathy_out = inp_root.joinpath(config.get("out", "out"))
|
||||
|
||||
log.info(f"Loading bathymetry from {bathy_inp}")
|
||||
bathy_curvi = np.load(bathy_inp)
|
||||
|
||||
projection = Lambert()
|
||||
bathy = np.stack(
|
||||
(
|
||||
*projection.cartesian(bathy_curvi[:, 0], bathy_curvi[:, 1]),
|
||||
bathy_curvi[:, 2],
|
||||
),
|
||||
axis=1,
|
||||
)
|
||||
log.debug(f"Cartesian bathy: {bathy}")
|
||||
|
||||
artha_curvi = np.array(
|
||||
(config.getfloat("artha", "lon"), config.getfloat("artha", "lat"))
|
||||
)
|
||||
buoy_curvi = np.array(
|
||||
(config.getfloat("buoy", "lon"), config.getfloat("buoy", "lat"))
|
||||
)
|
||||
|
||||
artha = np.asarray(projection.cartesian(*artha_curvi))
|
||||
buoy = np.asarray(projection.cartesian(*buoy_curvi))
|
||||
|
||||
D = np.diff(np.stack((artha, buoy)), axis=0)
|
||||
x = np.arange(
|
||||
config.getfloat("out", "left", fallback=0),
|
||||
np.sqrt((D**2).sum()) + config.getfloat("out", "right", fallback=0),
|
||||
config.getfloat("out", "step", fallback=1),
|
||||
)
|
||||
theta = np.angle(D.dot((1, 1j)))
|
||||
|
||||
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(f"z: {z}")
|
||||
|
||||
_hires = np.loadtxt(hires_inp)[::-1]
|
||||
bathy_hires = np.stack(
|
||||
(
|
||||
np.linspace(
|
||||
0,
|
||||
(_hires.size - 1) * config.getfloat("inp", "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)
|
||||
hstru = np.zeros(z.shape)
|
||||
poro = np.zeros(z.shape)
|
||||
psize = np.zeros(z.shape)
|
||||
if config.getboolean("out", "no_breakwater", fallback=False):
|
||||
z[flt_x] = z[flt_x][-1]
|
||||
else:
|
||||
z[flt_x] = interpolate.griddata(
|
||||
(bathy_hires[:, 0],),
|
||||
bathy_hires[:, 1],
|
||||
(x[flt_x] - x[z_crossing] + bathy_hires[hires_crossing, 0]),
|
||||
)
|
||||
|
||||
hstru_in = np.loadtxt(hstru_inp)[::-1]
|
||||
hstru[flt_x] = interpolate.griddata(
|
||||
(bathy_hires[:,0],),
|
||||
hstru_in,
|
||||
(x[flt_x] - x[z_crossing] + bathy_hires[hires_crossing, 0]),
|
||||
)
|
||||
|
||||
poro_in = np.loadtxt(poro_inp)[::-1]
|
||||
poro[flt_x] = interpolate.griddata(
|
||||
(bathy_hires[:,0],),
|
||||
poro_in,
|
||||
(x[flt_x] - x[z_crossing] + bathy_hires[hires_crossing, 0]),
|
||||
)
|
||||
|
||||
psize_in = np.loadtxt(psize_inp)[::-1]
|
||||
psize[flt_x] = interpolate.griddata(
|
||||
(bathy_hires[:,0],),
|
||||
psize_in,
|
||||
(x[flt_x] - x[z_crossing] + bathy_hires[hires_crossing, 0]),
|
||||
)
|
||||
|
||||
np.savetxt(out_root.joinpath("bathy.dat"), z[::-1], newline=" ")
|
||||
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=" ")
|
||||
|
||||
if plt is not None and config.getboolean("out", "plot", fallback=False):
|
||||
fig, ax = plt.subplots()
|
||||
ax.plot(-x, z, color="k")
|
||||
ax.fill_between(-x, z+hstru, z, color="k", alpha=.2)
|
||||
plt.show(block=True)
|
||||
|
|
|
@ -1,3 +1,53 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:cee15595a8dac4e684da41c7b1cb9b80bd091a6879407ad516114d46addd0af0
|
||||
size 1435
|
||||
import argparse
|
||||
import configparser
|
||||
import logging
|
||||
import pathlib
|
||||
|
||||
import numpy as np
|
||||
|
||||
parser = argparse.ArgumentParser(description="Pre-process bathymetry")
|
||||
parser.add_argument("-v", "--verbose", action="count", default=0)
|
||||
args = parser.parse_args()
|
||||
|
||||
logging.basicConfig(level=max((10, 20 - 10 * args.verbose)))
|
||||
log = logging.getLogger("bathy")
|
||||
|
||||
log.info("Starting bathymetry pre-processing")
|
||||
config = configparser.ConfigParser()
|
||||
config.read("config.ini")
|
||||
|
||||
artha = np.array(
|
||||
(config.getfloat("artha", "lon"), config.getfloat("artha", "lat"))
|
||||
)
|
||||
buoy = np.array(
|
||||
(config.getfloat("buoy", "lon"), config.getfloat("buoy", "lat"))
|
||||
)
|
||||
log.debug(f"artha: {artha}")
|
||||
log.debug(f"buoy: {buoy}")
|
||||
|
||||
domain = np.stack((artha, buoy))
|
||||
domain.sort(axis=0)
|
||||
log.debug(f"domain: {domain}")
|
||||
|
||||
domain[0] -= 0.002
|
||||
domain[1] += 0.002
|
||||
log.debug(f"domain: {domain}")
|
||||
|
||||
inp_root = pathlib.Path(config.get("inp", "root"))
|
||||
out_root = pathlib.Path(config.get("out", "root"))
|
||||
bathy_inp = inp_root.joinpath(config.get("inp", "base"))
|
||||
bathy_out = out_root.joinpath(config.get("out", "sub"))
|
||||
log.info(f"Reading bathymetry from '{bathy_inp}'")
|
||||
raw_bathy = np.loadtxt(bathy_inp)
|
||||
log.debug(f"Initial size: {raw_bathy.shape}")
|
||||
|
||||
bathy = raw_bathy[
|
||||
((raw_bathy[:, :2] > domain[0]) & (raw_bathy[:, :2] < domain[1])).all(
|
||||
axis=1
|
||||
)
|
||||
]
|
||||
del raw_bathy
|
||||
log.debug(f"Final size: {bathy.shape}")
|
||||
|
||||
log.info(f"Saving subdomain to 'bathy'")
|
||||
np.save(bathy_out, bathy)
|
||||
|
|
Reference in a new issue