From 7cdebd28ba7dbc2423ecb246bca39dfd517d154c Mon Sep 17 00:00:00 2001 From: CB-Lim <129813815+CB-Lim@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:11:44 +0100 Subject: [PATCH] Add files via upload --- CHANGELOG.md | 6 +- README.md | 52 +++---- data/config.nc | Bin 0 -> 3345 bytes data/ens.nc | Bin 0 -> 2224 bytes data/wav.nc | Bin 0 -> 2224 bytes docs/Makefile | 38 ++--- docs/conf.py | 104 +++++++------- docs/index.md | 53 ++++--- docs/make.bat | 68 ++++----- pyproject.toml | 98 ++++++------- src/IHSetDean/IHSetDean.py | 136 ++++++++++-------- src/IHSetDean/__init__.py | 6 +- .../__pycache__/IHSetDean.cpython-311.pyc | Bin 0 -> 3080 bytes .../__pycache__/IHSetDean.cpython-312.pyc | Bin 0 -> 3976 bytes .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 212 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 203 bytes src/IHSetDean/tests/__init__.py | 22 +-- .../__pycache__/__init__.cpython-311.pyc | Bin 0 -> 743 bytes .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 669 bytes ...test_dean ori.cpython-312-pytest-8.0.2.pyc | Bin 0 -> 1969 bytes .../test_dean.cpython-311-pytest-7.3.1.pyc | Bin 0 -> 2392 bytes .../test_dean.cpython-312-pytest-8.0.2.pyc | Bin 0 -> 1717 bytes src/IHSetDean/tests/test_dean.py | 50 +++---- 23 files changed, 329 insertions(+), 304 deletions(-) create mode 100644 data/config.nc create mode 100644 data/ens.nc create mode 100644 data/wav.nc create mode 100644 src/IHSetDean/__pycache__/IHSetDean.cpython-311.pyc create mode 100644 src/IHSetDean/__pycache__/IHSetDean.cpython-312.pyc create mode 100644 src/IHSetDean/__pycache__/__init__.cpython-311.pyc create mode 100644 src/IHSetDean/__pycache__/__init__.cpython-312.pyc create mode 100644 src/IHSetDean/tests/__pycache__/__init__.cpython-311.pyc create mode 100644 src/IHSetDean/tests/__pycache__/__init__.cpython-312.pyc create mode 100644 src/IHSetDean/tests/__pycache__/test_dean ori.cpython-312-pytest-8.0.2.pyc create mode 100644 src/IHSetDean/tests/__pycache__/test_dean.cpython-311-pytest-7.3.1.pyc create mode 100644 src/IHSetDean/tests/__pycache__/test_dean.cpython-312-pytest-8.0.2.pyc diff --git a/CHANGELOG.md b/CHANGELOG.md index d9e5e69..b757a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ -# 2024.02.23 - -- Features: Implements Dean article +# 2024.02.23 + +- Features: Implements Dean article diff --git a/README.md b/README.md index 2b0b645..08373e8 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,26 @@ -# IHSetDean - -Dean (1991) have proposed the concept of an equilibrium beach profile. Dean (1991) derived the equilibrium beach profile model with the wave energy dissipation similar to other previous works (e.g., Bruun, 1954). The equilibrium beach profile equation is very simple, but has been used by many researchers for coastal engineering. - - -## Installation and use - -To install this module use: - -```sh -pip install https://github.com/IHCantabria/IHSetDean/archive/refs/tags/latest.zip -``` - -Run tests to validate: - -```sh -ihsetdean-tests -``` - -## Documentation - -Documentation is available at https://ihcantabria.github.io/IHSetDean - -## Credits - -Developed and maintained by Lim, Changbin @ IHCantabria. +# IHSetDean + +Miller and Dean (2004) proposed a simple model for shoreline evolution using several field datasets. The model is developed based on the observation that shoreline positions change as a function of an equilibrium position. The model includes three adjustable parameters that represent the baseline conditions under which shoreline displacement is calculated to minimize the error. This model is very efficient because it only represents the shoreline response to the process and only requires input of readily available storm surge and water level data. + + +## Installation and use + +To install this module use: + +```sh +pip install https://github.com/IHCantabria/IHSetDean/archive/refs/tags/latest.zip +``` + +Run tests to validate: + +```sh +ihsetdean-tests +``` + +## Documentation + +Documentation is available at https://ihcantabria.github.io/IHSetDean + +## Credits + +Developed and maintained by Lim, Changbin @ IHCantabria. diff --git a/data/config.nc b/data/config.nc new file mode 100644 index 0000000000000000000000000000000000000000..bf2e85e74d759ad51b82ce5e0a7456230e24a422 GIT binary patch literal 3345 zcmeD5aB<`1lHy|G;9!7(|4<;v3lTAZO6*d6yv^UkC5VY<3zHI9jF}lK1=E5~b1^Y6 zf|LjdfXLrqHUmQ`hywy_5DG-{=z>UQ1|9|u1{MZ}hnM2w-xeG9X6-B^b~{0LJHW0jXzZ z;ARj3LWX#^%$%IC#GKMptadXo0s%+^5Wr{%??*j@9fU;*IWuwFcYkLOZ%DkRZa(GVC7fzc2c4S~@R z7y%)Gr2)nRYT*a~TT+mQoB{(Y7o_0@;sd1`V2!Q{Xrl|F4k)>8=myw=j?JGy4KP^4 zkqKwR5z<6E4{87dffIy+wF+xknqE*6q&34RNZUW22>}Hun>Z+p7+GNLW)@I)p@0h# Wa4<=zzZrm%i4}*T?O!WLrfC4hDX|&= literal 0 HcmV?d00001 diff --git a/data/ens.nc b/data/ens.nc new file mode 100644 index 0000000000000000000000000000000000000000..fefab66992c60c9b9773586aa2bce7d3bcb09454 GIT binary patch literal 2224 zcmeIye{{`t9LMop`)Ph27X6}AahjrZv^rFqZI{=&3a4xx9VNv$hYoQnx|IALS;*q< z5HeXaWA6Nx-&V%L@%}PVw1x;Z$&ZG5-p#Z+{nzQgzUMs7^Yi(B-@Etw{hoW4=whZCW92kzA*W%XoCf{n)Q^x;H%CsLE^=z0krRn+n6Ey z{4v@364|;DvbA@}R&S84dQn#JyUagdwjy4(yi~SqoGh=UEVod$WPmKEwk$hGw)kn; zqO-EBblJkTvIYBO^M}gjMakx_l+8(zWnPx~e6racWFH-oWsH)|Y%ZIzSvI|oY+5Z@ zdX{WzC)tz}vdNQVX{}@vi)0f9$;Q`{jm?vd=`I^xE_-)|?43tE-c^Zs0JkI3<6U_L zKj0v~z$z@lOpL=Yyn<&DkG8lA4Lsh0>o|)e*p2nbK_=2L9R2Y;IwJ-x5QSim*MA=0 zVIMYQ8Rj7!qc8})&;=dP3b!G`<6UtHCvgBfP=G9ah%tB_eb60oco5A|&*RO%iZeKj zBCN${n2m{e6RAjs8@#vtd(j9kk9T=Fj$scrA`f%%KD-!+7w{C?BN|N+=J77Oh~qG9 zgCCz@I^M$&^hQ_2q7Cju9gjD!A}%*3DXz`_@Hp3$sMvX>X|cZS)3H8Z=KucXJD64M ziVf*?u*Uzq|76+mc+ZUZgxp>6X(|2U^KmGpUqaB5b_r34#uMm{z8H=P$-abX$V3+M zum)SP8wYR1A3$uVtjVgChNI rm&fm}HQDbDF7mrW*@v+YXCJ{nGSVMgwzQ&SQj@OnEmO|N@yqxF74=!4 literal 0 HcmV?d00001 diff --git a/data/wav.nc b/data/wav.nc new file mode 100644 index 0000000000000000000000000000000000000000..fefab66992c60c9b9773586aa2bce7d3bcb09454 GIT binary patch literal 2224 zcmeIye{{`t9LMop`)Ph27X6}AahjrZv^rFqZI{=&3a4xx9VNv$hYoQnx|IALS;*q< z5HeXaWA6Nx-&V%L@%}PVw1x;Z$&ZG5-p#Z+{nzQgzUMs7^Yi(B-@Etw{hoW4=whZCW92kzA*W%XoCf{n)Q^x;H%CsLE^=z0krRn+n6Ey z{4v@364|;DvbA@}R&S84dQn#JyUagdwjy4(yi~SqoGh=UEVod$WPmKEwk$hGw)kn; zqO-EBblJkTvIYBO^M}gjMakx_l+8(zWnPx~e6racWFH-oWsH)|Y%ZIzSvI|oY+5Z@ zdX{WzC)tz}vdNQVX{}@vi)0f9$;Q`{jm?vd=`I^xE_-)|?43tE-c^Zs0JkI3<6U_L zKj0v~z$z@lOpL=Yyn<&DkG8lA4Lsh0>o|)e*p2nbK_=2L9R2Y;IwJ-x5QSim*MA=0 zVIMYQ8Rj7!qc8})&;=dP3b!G`<6UtHCvgBfP=G9ah%tB_eb60oco5A|&*RO%iZeKj zBCN${n2m{e6RAjs8@#vtd(j9kk9T=Fj$scrA`f%%KD-!+7w{C?BN|N+=J77Oh~qG9 zgCCz@I^M$&^hQ_2q7Cju9gjD!A}%*3DXz`_@Hp3$sMvX>X|cZS)3H8Z=KucXJD64M ziVf*?u*Uzq|76+mc+ZUZgxp>6X(|2U^KmGpUqaB5b_r34#uMm{z8H=P$-abX$V3+M zum)SP8wYR1A3$uVtjVgChNI rm&fm}HQDbDF7mrW*@v+YXCJ{nGSVMgwzQ&SQj@OnEmO|N@yqxF74=!4 literal 0 HcmV?d00001 diff --git a/docs/Makefile b/docs/Makefile index 41c270b..1a37590 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,20 +1,20 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = . -BUILDDIR = _build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 890680f..251d597 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,52 +1,52 @@ -# Configuration file for the Sphinx documentation builder. -# -# For the full list of built-in configuration values, see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Project information ----------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -from IHSetDean.__init__ import __version__ - - -project = "IHSetDean" -copyright = "2024, Lim, Changbin" -author = "Lim, Changbin" -version = release = __version__ - -html_context = { - "display_github": True, # Integrate GitHub - "github_user": "ihcantabria", # Username - "github_repo": "IHSetDean", # Repo name - "github_version": "main", # Version - "conf_py_path": "/docs/", -} - -# -- General configuration --------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration - -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.napoleon", - "sphinx_rtd_theme", - "myst_nb", - # 'sphinxcontrib.autodoc_pydantic', - "sphinx.ext.autosummary", -] -templates_path = ["_templates"] -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] - - -# -- Options for HTML output ------------------------------------------------- -# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output - -html_theme = "sphinx_rtd_theme" -html_theme_options = { - "display_version": True, - "style_external_links": False, -} -# html_theme = 'furo' -# html_theme = 'sphinx_book_theme' - -html_static_path = ["_static"] -html_logo = "" -html_title = " v" + release +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +from IHSetDean.__init__ import __version__ + + +project = "IHSetDean" +copyright = "2024, Lim, Changbin" +author = "Lim, Changbin" +version = release = __version__ + +html_context = { + "display_github": True, # Integrate GitHub + "github_user": "ihcantabria", # Username + "github_repo": "IHSetDean", # Repo name + "github_version": "main", # Version + "conf_py_path": "/docs/", +} + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "sphinx_rtd_theme", + "myst_nb", + # 'sphinxcontrib.autodoc_pydantic', + "sphinx.ext.autosummary", +] +templates_path = ["_templates"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = "sphinx_rtd_theme" +html_theme_options = { + "display_version": True, + "style_external_links": False, +} +# html_theme = 'furo' +# html_theme = 'sphinx_book_theme' + +html_static_path = ["_static"] +html_logo = "" +html_title = " v" + release diff --git a/docs/index.md b/docs/index.md index d91aad5..c6779fc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,21 +1,32 @@ -# IHSetDean - -## Summary - -Dean (1991) have proposed the concept of an equilibrium beach profile. Dean (1991) derived the equilibrium beach profile model with the wave energy dissipation similar to other previous works (e.g., Bruun, 1954). The equilibrium beach profile equation is very simple, but has been used by many researchers for coastal engineering. - -## Model formula - -Dean (1991) suggested a simple equilibrium beach profile equation based on the wave energy dissipation as follows: - -```text -h=Ay^(2/3) - -h : the water depth -y : the seaward distance -A : the Dean parameter -``` - -![Definition sketch of equilibrium beach profile model](_static/images/Imagen1.png) - -Fig. Definition sketch of equilibrium beach profile model (Dean, 1991). +# IHSetDean + +## Summary + +Dean (1991) have proposed the concept of an equilibrium beach profile. Dean (1991) derived the equilibrium beach profile model with the wave energy dissipation similar to other previous works (e.g., Bruun, 1954). The equilibrium beach profile equation is very simple, but has been used by many researchers for coastal engineering. + +## Model formula + +Miller and Dean (2004) suggested a simple shoreline evolution model based on the imbalance of shoreline change between an equilibrium shoreline change and shoreline position as follows: + +```text +(∂S(t))/∂t=k(S_eq (t)-S(t)) + +S(t) : the shoreline position at time t +S_eq : the equilibrium shoreline position +k : the calibration parameter for the rate at which the shoreline approaches equilibrium (k; k=k_a H_b^2; k=k_a H_b^3; k=k_a Ω) +``` + +Miller and Dean (2004) proposed an equilibrium shoreline change owing to the change of sea level (Fig. 4 1): + +```text +S_eq=-W^* (t)((0.068H_b+S)/(B+1.28H_b )) + +H_b : the breaking wave height +S : the change in local water level +B : the berm wave height +W^* : the width of the active surf zone +``` + +![Definition sketch of shoreline evolution](_static/images/Imagen1.png) + +Fig. 4 1. Definition sketch of shoreline evolution according the change of water level owing to storm surge and wave setup (Miller and Dean, 2004). \ No newline at end of file diff --git a/docs/make.bat b/docs/make.bat index b4f380c..8f6d24c 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -1,35 +1,35 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=. -set BUILDDIR=_build - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.https://www.sphinx-doc.org/ - exit /b 1 -) - -if "%1" == "" goto help - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=. +set BUILDDIR=_build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end popd \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 1ea4c1e..682d20a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,49 +1,49 @@ -[build-system] -requires = ["flit_core >=3.2,<4"] -build-backend = "flit_core.buildapi" - - -[project] -name = "IHSetDean" -authors = [{ name = "Lim, Changbin", email = "changbin.lim@unican.es" }] -maintainers = [{ name = "Lim, Changbin", email = "changbin.lim@unican.es" }] -readme = "README.md" -requires-python = ">=3.9" -classifiers = [ - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Physics", - "Development Status :: 1 - Planning", - "Programming Language :: Python", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", -] -dynamic = ["version", "description"] - -dependencies = ["numpy", "pytest >=7", "scipy"] - - -[project.optional-dependencies] -dev = ["flit", "black", "sphinx", "myst-nb", "sphinx_rtd_theme", "pre-commit"] - - -[project.urls] -documentation = "https://ihcantabria.github.io/IHSetDean/" -repository = "https://github.com/IHCantabria/IHSetDean" -changelog = "https://github.com/IHCantabria/IHSetDean/blob/main/CHANGELOG.md" - - -[project.scripts] -ihsetdean-tests = "IHSetDean.tests.__init__:run_tests" - - -[tool.pytest.ini_options] -addopts = "--durations=0 --durations-min=0.1" -testpaths = "src/tests" -markers = [ - "slow: marks tests as slow (deselect with '-m \"not slow\"')", - "serial", -] +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + + +[project] +name = "IHSetDean" +authors = [{ name = "Lim, Changbin", email = "changbin.lim@unican.es" }] +maintainers = [{ name = "Lim, Changbin", email = "changbin.lim@unican.es" }] +readme = "README.md" +requires-python = ">=3.9" +classifiers = [ + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Physics", + "Development Status :: 1 - Planning", + "Programming Language :: Python", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dynamic = ["version", "description"] + +dependencies = ["numpy", "pytest >=7", "scipy", "xarray"] + + +[project.optional-dependencies] +dev = ["flit", "black", "sphinx", "myst-nb", "sphinx_rtd_theme", "pre-commit"] + + +[project.urls] +documentation = "https://ihcantabria.github.io/IHSetDean/" +repository = "https://github.com/IHCantabria/IHSetDean" +changelog = "https://github.com/IHCantabria/IHSetDean/blob/main/CHANGELOG.md" + + +[project.scripts] +ihsetdean-tests = "IHSetDean.tests.__init__:run_tests" + + +[tool.pytest.ini_options] +addopts = "--durations=0 --durations-min=0.1" +testpaths = "src/tests" +markers = [ + "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "serial", +] diff --git a/src/IHSetDean/IHSetDean.py b/src/IHSetDean/IHSetDean.py index bb681b5..a98c457 100644 --- a/src/IHSetDean/IHSetDean.py +++ b/src/IHSetDean/IHSetDean.py @@ -1,62 +1,74 @@ -import numpy as np -from scipy.interpolate import interp1d - - -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 Dean(dp, zp, D50): - z = zp - zp[0] - d = dp - dp[0] - - # Profile with equidistant points - dp = np.linspace(0, dp[-1], 500).reshape(-1, 1) # 500 points - interp_func = interp1d(d, z, kind="linear", fill_value="extrapolate") - zp = interp_func(dp) - zp = zp[1:] - dp = dp[1:] - - ws = None - if D50 is not None: - ws = caida_grano(D50) - - Y = np.log(-zp) - Y2 = 2 / 3 * np.log(dp) - - fc = np.arange(-20, 20, 0.001) - Y2_grid, fc_grid = np.meshgrid(Y2, fc, indexing="ij") - Y2t = fc_grid + Y2_grid - - out = RMSEq(Y, Y2t) - I = np.argmin(out) - - A = np.exp(fc[I]) - kk = np.exp(fc[I] - np.log(ws**0.44)) if ws is not None else None - - hm = -A * dp ** (2 / 3) - err = RMSEq(zp, hm) - - Para = {"model": "Dean"} - Para["formulation"] = ["h= Ax.^(2/3)", "A=k ws^0.44"] - Para["name_coeffs"] = ["A", "k"] - Para["coeffs"] = [A, kk] - Para["RMSE"] = err - - model = { - "D": np.array([0] + list(dp.flatten())), - "Z": np.array([0] + list(hm.flatten())), - } - - return Para, model +import numpy as np +from scipy.interpolate import interp1d +import xarray as xr + +class cal_Dean(object): + """ + cal_Dean + + Configuration to calibrate and run the Dean profile. + + This class reads input datasets, performs its calibration. + """ + def __init__(self, path): + self.path = path + + cfg = xr.open_dataset(path+'config.nc') + ens = xr.open_dataset(path+'ens.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 + + def calibrate(self): + self.zp = self.zp - self.zp[0] + self.d = self.dp - self.dp[0] + + # Profile with equidistant points + dp = np.linspace(0, self.dp[-1], 500).reshape(-1, 1) + interp_func = interp1d(self.d, self.zp, kind="linear", fill_value="extrapolate") + zp = interp_func(dp) + zp = zp[1:] + dp = dp[1:] + + ws = None + if self.D50 is not None: + ws = caida_grano(self.D50) + + Y = np.log(-zp) + Y2 = 2 / 3 * np.log(dp) + + fc = np.arange(self.Ymin, self.Ymax, self.dY) + Y2_grid, fc_grid = np.meshgrid(Y2, fc, indexing="ij") + Y2t = fc_grid + Y2_grid + + out = RMSEq(Y, Y2t) + I = np.argmin(out) + + self.A = np.exp(fc[I]) + self.kk = np.exp(fc[I] - np.log(ws**0.44)) if ws is not None else None + self.dp_value = dp + + 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 Dean(self): + + self.hm = -self.A * self.dp ** (2 / 3) + + return self diff --git a/src/IHSetDean/__init__.py b/src/IHSetDean/__init__.py index 8407dfe..cf64942 100644 --- a/src/IHSetDean/__init__.py +++ b/src/IHSetDean/__init__.py @@ -1,3 +1,3 @@ -""" Template """ - -__version__ = "0.1.0" +""" Template """ + +__version__ = "0.1.0" diff --git a/src/IHSetDean/__pycache__/IHSetDean.cpython-311.pyc b/src/IHSetDean/__pycache__/IHSetDean.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f93d4dfd710917430c4a8bc96faab8b54bfe49fc GIT binary patch literal 3080 zcmb^zOKcm*b$?uPxm-#lB}$g$N_EplG%VSs90YEosQSSX(g>+lH??3`pgAjQLvlq8 zsYX(lC|$I`Dqzqxpwx8XAWT~*4&;N6EqZ9tQ;*z$K!`yF7$}TFKo1JsT!I4an-xWR zl@`sRkKDI2Z{C02yx9*G#m@lz{{4OR4<3g3E1etz*Bm@O2ZOr|Vi22Q7Fl?687|8& z@+^b+pE8RA5&(OU2e63P1tumQP|^7qOMIGMP;u@eO0rFD^u;%yr@w%~U8X>3O?b1# zS7Z&an0DwmfH;`(Ti_!SwtNgjM@3dYi-0T1ZE$Hv4vWas9Chd%%jf|lw&c9e$OVDw zNefgt_8}k4r1q*oWAM+XetD0=?kbd z+gy9Q$Lwh+Ay|#vd1ZSEbjV6+?kU)W{8QWn5#DrvpWXxnd)wMihH3Aui`tSl7=zt{ zdPFSU3&cI-cVTU>wZ03w_FDR2kA!(l&0)#`#U>;+w0w-mAj}XUzlIA$$U;UT@$7ZN zUym1>dB*|D;ko+S!t5IEhH)o6`4}L`pRAN$d^f)HVr8<*-@EdFz4!7Xwib!ok$4@j zJXV*-YQh)}0(X)IdJNR66L=KL>Mn$0u!uc%yvoqPiadk};hmrgu5`2lq@|6xHZS6L zLH}OMX0?@=mJt{r4hinG6`6v!&0z=zk32|x=-mZB_ux5#qK9J)kHNT;42O_K0%Csl zj33UyJV}H0P!tXBc1J-v*2pjhcS4)!ij-EZ0|qOfwChE_|H6BM(`f{5URo0lAPM=A z?9N(Ia_Mbl#_$;u3OrQY+&3V{MSoE?WW&D&I*WlqsHq%YhSvz3$hG3q-pYlcoXAAb z#pg6(s@IT=V0*_;$aEOu?f93GbMdsZETSMiSZ=MfF5MIzT70q7=#Xix`dV!<T>bA}I0_M1;Cfw=;{U76z_fI&yg|1Hl2rrr1I| z9pF!ucDpaYE>QMbRChFV*W8pZX)E;qu!Th6wax*$S+T4^3{2-W-mfAB%0tljG^3xAHeH zj9$7#4aA|a>SFsII&5DjFvAD z?=tvOQ1w_h;ZTlnTRBY62w}Gfi->&mRk5_Zt|u|A794T1a6L}ApK9SCSES-CB^-;){#_G~oX=*>* zSGib8R9AjGUJK9J;kkNvuJmd{>N5MStJ{O+LAcN**_9eK&($o|9QaELefp4?6bfzwy z0Y7?9?fj@3ui{5DwVum%&*eH`p{sPoe52tHSyya-e`)%Ozr$j!vF(xaNNIW>tVq_^ zwu9whY0@!iV(Y8r^=+lBfYFij4{p8_E=MiSy13(ckGn5caP`u?4ZC-^-aBk}4%yIh(vPuoII zqyH;azH;_>7VW8otv6uSdwaeSiNYXy`#Z1`!OrpztTik7-b^+8Vc)O%J{b7TfITo; z9~iZxqqcIsuAJXjI{qimp@&z*Lk3W3_R!A+I<0Q=TQwo-d=SLE#G|igbDKv8Ba}~S zxy{j|YIRO^`(QXHz$vAV7)RDAu+M!j!HHeZs4wGLs4)61kY5CJ$g?clV8XTIe}nl( f&HXgB7l literal 0 HcmV?d00001 diff --git a/src/IHSetDean/__pycache__/IHSetDean.cpython-312.pyc b/src/IHSetDean/__pycache__/IHSetDean.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2673c4c2fcce9560529c475b9b25eacc5fdc7522 GIT binary patch literal 3976 zcma)9U2Idy6~2G|&o$UioGkkj6R}}Um#_&-Lt%Hb34xGBn^qgjk}Q&Skvndl&yGh%C2H-k!XYTdAc4*3W zB+r~V^PMwu&zzs}pG48kKpUB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D$SPwOr9;f3F;92>Rfy=dVb|=r~9eXJ={3eTGOR#C*u=$+P?8wTRqj<&o&=#9xWe< zm(J9__1>ADU;Co1&tMqYdf6bvPduR0kUwSNprXl}P^~t-MckDBIZ$WK+fm}@EV#ov d5K30rGN`{Q#`qgr`Hfb-BXeeGcmr2c{{Z7^qk;ec literal 0 HcmV?d00001 diff --git a/src/IHSetDean/tests/__pycache__/test_dean ori.cpython-312-pytest-8.0.2.pyc b/src/IHSetDean/tests/__pycache__/test_dean ori.cpython-312-pytest-8.0.2.pyc new file mode 100644 index 0000000000000000000000000000000000000000..41572ddb662bf6082b7370c9d4cace747689cd79 GIT binary patch literal 1969 zcmb6a&2QUO+|NlI+xh6ymeHnQ7Lm8KtSHi0N5>xa5SE7tB5RSRD147X0=J-g6E zjug-it%S7f)F5%l5mXNR37kPfSOIlVkTt5Y0q^4?Scuu`-glLmGTVLWI>yfQ4I2YpOM`%0&=(t!Sy(m{f9Z z1t%yBGyu=hH&EIhVp_d`l&wXVwPeXQM?fX^e@;yk*ll? zKgIQ~z*d3m#|fP&PT+JMccyhgJ75Rh%mIt`@4^P}b8YHZ2{i0x;P>fX0aQaQV?{h3 zdS>l_A}HeLk^P{jvqPsl6|h4c9Y)VoDQCs}92;?;Yg3xn=KPx0;l!%pDsP9CSUXEq zP~uh57Hn~I1ndzzV(M1HkFnA1b8V`0*^xX_&e1h_*6*leO>f)R=WN06_donZ-%m+= z!d5t_D5`WTJ$6(>t`xIg^ka5J>hpDNYRCLYKK&4`(Kf0I@I}#pRzW@#u*Q{$rRmLQuZd+J3O1f;R z5=(-cT2Ub)gw(U|$@-Q`0`sW}5?ozgTe$zu^VRdAKYyB)&@nqRBcV$7l@X&nDVc*a zGlP_!mQ08d03AismAGu0Dz;qPb;+d4>rxEUQ6pi!Br8xY3FjfVr4|WWGzbr6nTDKG zF}-J)4jl>7drri+jIyPgRu+m*WOFhUh*bmUN(Dp4DiN}#oL8xa#M5q8tyEmVxP(bh zHebS!DXVT9x?Gekut;%CF9<;frq=@tRAA?p39D$B4iW4hO}k0Bf=45eKkM}~K{|wM zox+qSc==MD!VQy-`QSg`csBR?`mLq0wS_xCPF`qZ_ciO?t$XVx&b5{6v~$zNSp~`( zEMYBal!@T(2rUr53gKx>W(wY9HRgG&>rrMm^KIXBE0(G)KH-I0`UxN3*>?E8Mvuc^ zY{(8j*i1P5&;dW{@S`n$jCu$==^c4@ewY7W?m}0ccZB}NRY!QaIq3*jnzAE|90(JR zFwqjGYBy=Xo4Z^s{i6_hG_X5Rzg>Uu_)cT8vHEeUIn)w{smts~d_7T5HgiE_#^5pPI11>P wf1^-RwsiGPd;>)Kr7{Nq{T@IFJ!6=M%=b+14@~z{=F(GU_=roOYwqH|0Xp&2vH$=8 literal 0 HcmV?d00001 diff --git a/src/IHSetDean/tests/__pycache__/test_dean.cpython-311-pytest-7.3.1.pyc b/src/IHSetDean/tests/__pycache__/test_dean.cpython-311-pytest-7.3.1.pyc new file mode 100644 index 0000000000000000000000000000000000000000..07f1420ec328c7975468077a642f24ec1572e50a GIT binary patch literal 2392 zcmb^zO>YxNbawqUyZ!+4RiH(LQa&si=K~DtN1B=dfM(rFpN`03ln>Jt&6-#O7AK)d7l3@i^2K}66|NpM%O8mWi^szysOflEX^UQLt| zE-vV}Bmpm?%T>7~yS%8LtfopSz++#dQkn>}C>MXq&0oz4Ow{TCr7M?bRqKMP)PTTR z%~Gi`Mk;O$TOa{z1it5s03RSr7zl6qI1$zWU-#(-gx3&k2ZpzdpXi)^zS|DWte?T8(9Bac`-$6Mo8w2y_) z2vj2A8Lz=@tn+(uMJ{uy~}c03&a9Nc>&(ZF_sq+jj5A(2c&wk2D>?bb*mX(vtH$_6}0eVpvDlk)=E z$+hRja0Ws<+(zWPY$=?Vf6~wo{tmQfcdrek2HmET#H1KwSl)H)q_H%XGlwQ7hB$gAXM&9g@HjZLoKZ|urIsr@n=?7{ zY%WcCp|XTtR|rJQ67%5OQfo}C84N>MrlC|+8UrQDOO-|Wi^SxQjU`Jptuh3iEmsr> zkg5i))T@RZ!(2&PDXu8@ zF5Jccb%(TL6+6;_)(J;?yFKPe$J&Y`o!pd0H>A<7H10^_&GX#s`MdFE@v)S=_vY%g z)jRjEx5ipC4-4(1UFoV8K)*eW>kk@gWsey4rSkxy*OBOCHaR~~cZvF6mDakTI7{ZHD(_MPvKcK7C;z4P5#p(QzjLf%NA_0RN@0=1YB~>xz7ZSCXDGi2Pka4(#2w-7~UHIY>T-%SE{i z!#5T*-GUZjDPE2~b)f7uN8T$?DDXU0Kc|`njp4IcVv9%L0&6U0Ry1SDYsOe@p$a&E zY`vb#y28BoKY;rGcvd+548088;Qj&8elI}) literal 0 HcmV?d00001 diff --git a/src/IHSetDean/tests/__pycache__/test_dean.cpython-312-pytest-8.0.2.pyc b/src/IHSetDean/tests/__pycache__/test_dean.cpython-312-pytest-8.0.2.pyc new file mode 100644 index 0000000000000000000000000000000000000000..61be80a8b873cd40f2d81247c2fbf414b27bf4dc GIT binary patch literal 1717 zcmb_c&uiOO9REtPWl3>TCr-WE8x5i9YLmvHkS?POO$XW19ySVH5A#xt?DuR-ktI)3 z=Gcegz(x{wXnINuh56W$9D3fru#3HTM7%Ou*eS3>LdOnekUhzEe&B7eu?PD8_`J_o z-ycs;KlJxYK-c$QF}XYk@QdqoSD<6O{+$Kb1O$lDAjNo^Epl0wfub+vXWSiDKLgI z9#AiI(PNE6NT^a5iQCc^t=wH+ZeAU0dnYAj_qpt&ykVM`SK}u+Z5xNx@m{oB%~5;= z2i0URPrcHMp&;s4m~JEk{~~e#o%xTEAvAb067{1&G=#!WxKuO`sThu_)4i3_nFQ7M zdvP35ul*%D(~F|vE&7GI3qh316Mg?bIj?&!KPAxF?a1F{^?JH-itahx6J?;nB;ML{ zu}>2W5pUhRgY7vi>-j&P9sKx7=Ju@e>*3+y-Y_L3IKrX|@qJ!YbXUsDG=k3>hKa1| znMowu@?_S~b4os`XGuWEb{6HPTn^UrijJ#%n^Wz}8M>X!$wfu05Wj^@C07+a%u=d& z&%KfzP8lotf=zrGLqmH)y9T}!$agp0pei>pvAE}61h)%~W-BYmE+j^YkXceRThT2N zyiuy8kGyEQRI#yTCuNIPU@L~6G;!HfY)r%>hy=QrM1x&=S~gAhgbBY)ExAJ2Ws|Um zMFxwqUD6C&Q!>d?#kC0E(OgNhNnno7$HEkC&xr7OI-oKleA!%_Q%oY-M!G#SB4lMP z?VbYh7Y&3p;`1Dl!b--JX^B1yYdIpA+1s)y7cIgsmFWB_?v9bLg+;>4r4rT=@p+}N zs6^N*eF{YyTQJJc;5F?6-h7a~ws7m_#GQ{mqpEZE6M4lhEM*ofGkXj!xZPWxOe0zv zZSsvUL(5yz@O9I@PVP_5nx%4|V;JToz}N5-jJ$yG3lM*Xkym1PZRkO4JyyTyj9qfZ z-aYVh@0|Y)IBBHD?@J)L+tKytw{O>Y2l!nGH6gSSX`D+m2NTZ|4G6Vh#t~v`;;s;D z3b9A;)#Hz6cZBhp-wB+pRaWn>+~2^P#zSK#a%m?JulZg9w;Egt?n1Z;;f;Is`Nr_& z7ECy&;4kWAXDI3nopVBi2Yyxv*L?c|@IsAsfL#?=#I^X^ zg$MEV_{P-c^uy^#bKlKBp0D5Ck;b2X*p!kjnEVIc(=S`nmFJ^PX{rTR9S~~Vs<0w_ KBbis}ApZmikC1Wz literal 0 HcmV?d00001 diff --git a/src/IHSetDean/tests/test_dean.py b/src/IHSetDean/tests/test_dean.py index dc96f77..725a0eb 100644 --- a/src/IHSetDean/tests/test_dean.py +++ b/src/IHSetDean/tests/test_dean.py @@ -1,24 +1,26 @@ -from scipy import io -import numpy as np -from IHSetDean import IHSetDean -from scipy.interpolate import interp1d - - -def test_Dean(): - - perfil = io.loadmat("./data/perfiles_cierre.mat") - p = 0 - d = perfil["perfil"]["d"][0][p].flatten() - d = d - d[0] - z = perfil["perfil"]["z"][0][p].flatten() - CM = perfil["perfil"]["CM_95"][0][p].flatten() - z = z - CM - di = np.linspace(d[0], d[-1], 100) - z = interp1d(d, z, kind="linear", fill_value="extrapolate")(di) - d = di - - D50 = perfil["perfil"]["D50"][0][p].flatten() - - # Assuming the 'ajuste_perfil' function is defined as in the previous code - pDeank, mDeank = IHSetDean.Dean(d, z, D50) - assert pDeank["RMSE"][0] == 0.4840710371023019 +from IHSetDean import IHSetDean +import xarray as xr +import os +import matplotlib.pyplot as plt + +config = xr.Dataset(coords={'dy': 0.001, # Calibrate + 'Ymin': -20, # Calibrate the minimum value + 'Ymax': 20, # Calibrate the maximum value + }) + +wrkDir = os.getcwd() +config.to_netcdf(wrkDir+'/data/config.nc', engine='netcdf4') +model = IHSetDean.cal_Dean(wrkDir+'/data/') +self = IHSetDean.Dean(model.calibrate()) + +plt.rcParams.update({'font.family': 'serif'}) +plt.rcParams.update({'font.size': 7}) +plt.rcParams.update({'font.weight': 'bold'}) +font = {'family': 'serif', + 'weight': 'bold', + 'size': 8} + +hk = [] +hk.append(plt.plot(self.dp, self.zp, '--k')[0]) +hk.append(plt.plot(self.dp, self.hm, linewidth=2)[0]) +plt.show() \ No newline at end of file