Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
CB-Lim authored Apr 5, 2024
1 parent 6f197f0 commit 1b0cf18
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IHSetUtils @ git+https://github.com/IHCantabria/IHSetUtils.git@486fcbe8f769be16f4d96fcecf39d8d7c29f2453
25 changes: 4 additions & 21 deletions src/IHSetBernabeu/IHSetBernabeu.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from scipy.interpolate import interp1d
from shapely.geometry import LineString
import xarray as xr
from IHSetUtils import wMOORE

class cal_Bernabeu(object):
"""
Expand All @@ -18,9 +19,6 @@ def __init__(self, path):
ens = xr.open_dataset(path+'ens.nc')
wav = xr.open_dataset(path+'wav.nc')

# self.Ymin = cfg['Ymin'].values
# self.Ymax = cfg['Ymax'].values
# self.dY = cfg['dy'].values
self.D50 = ens['D50'].values
self.dp = ens['d'].values
self.zp = ens['z'].values
Expand All @@ -40,7 +38,7 @@ def calibrate(self):
zp = zp[1:]
dp = dp[1:]

ws = caida_grano(self.D50)
ws = wMOORE(self.D50)
gamma = self.Hs / (ws * self.Tp)

self.Ar = 0.21 - 0.02 * gamma
Expand All @@ -58,21 +56,6 @@ def calibrate(self):

return self

def caida_grano(D50):
ws = np.nan
if D50 < 0.1:
ws = 1.1e6 * (D50 * 0.001) ** 2
elif 0.1 <= D50 <= 1:
ws = 273 * (D50 * 0.001) ** 1.1
elif D50 > 1:
ws = 4.36 * D50**0.5
return ws


def RMSEq(Y, Y2t):
return np.sqrt(np.mean((Y - Y2t) ** 2, axis=0))


def Bernabeu(self):
Xr = ((self.hr + self.CM) / self.Ar)**(1.5) + self.B / self.Ar**(1.5) * (self.hr + self.CM)**3
Xo = Xr - (self.hr / self.C)**(1.5) - self.D / self.C**(1.5) * self.hr**3
Expand Down Expand Up @@ -110,6 +93,6 @@ def Bernabeu(self):

self.hmi = interp1d(X, hm, kind='linear', fill_value='extrapolate')(self.dp)

err = RMSEq(self.zp, self.hmi)
# err = RMSEq(self.zp, self.hmi)

return self
return self
Binary file modified src/IHSetBernabeu/__pycache__/IHSetBernabeu.cpython-312.pyc
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions src/IHSetBernabeu/tests/test_bernabeu.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
hk = []
hk.append(plt.plot(self.dp, self.zp, '--k')[0])
hk.append(plt.plot(self.dp, self.hmi, linewidth=2)[0])
plt.xlabel('Distance [m]', fontdict=font)
plt.ylabel('Water depth [m]', fontdict=font)
plt.show()

0 comments on commit 1b0cf18

Please sign in to comment.