wave-shoaling-physics 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wave_shoaling_physics-0.1.3/LICENSE +21 -0
- wave_shoaling_physics-0.1.3/PKG-INFO +26 -0
- wave_shoaling_physics-0.1.3/README.md +9 -0
- wave_shoaling_physics-0.1.3/pyproject.toml +24 -0
- wave_shoaling_physics-0.1.3/setup.cfg +4 -0
- wave_shoaling_physics-0.1.3/tests/test_core.py +22 -0
- wave_shoaling_physics-0.1.3/wave_shoaling/__init__.py +5 -0
- wave_shoaling_physics-0.1.3/wave_shoaling/core.py +59 -0
- wave_shoaling_physics-0.1.3/wave_shoaling_physics.egg-info/PKG-INFO +26 -0
- wave_shoaling_physics-0.1.3/wave_shoaling_physics.egg-info/SOURCES.txt +11 -0
- wave_shoaling_physics-0.1.3/wave_shoaling_physics.egg-info/dependency_links.txt +1 -0
- wave_shoaling_physics-0.1.3/wave_shoaling_physics.egg-info/requires.txt +2 -0
- wave_shoaling_physics-0.1.3/wave_shoaling_physics.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tu Nombre
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wave-shoaling-physics
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Gravity wave mechanics: dispersion, shoaling and coastal breaking with real-time marine data
|
|
5
|
+
Author-email: Adrian Hernandez <adrian.hernandezv@alumni.mondragon.edu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: physics,waves,shoaling,oceanography
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests>=2.28.0
|
|
15
|
+
Requires-Dist: numpy>=1.22.0
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# Wave Shoaling Physics
|
|
19
|
+
Library for modeling the propagation and shoaling of ocean waves. Requires entering coordinates explicitly to analyze any point on the planet.
|
|
20
|
+
|
|
21
|
+
## Usage example
|
|
22
|
+
```python
|
|
23
|
+
from wave_shoaling import fetch_marine_data, calculate_shoaling
|
|
24
|
+
|
|
25
|
+
# The user MUST provide the exact coordinates (no default values)
|
|
26
|
+
mar = fetch_marine_data(latitude=39.60, longitude=-9.07) # Ex: Nazaré, Portugal
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Wave Shoaling Physics
|
|
2
|
+
Library for modeling the propagation and shoaling of ocean waves. Requires entering coordinates explicitly to analyze any point on the planet.
|
|
3
|
+
|
|
4
|
+
## Usage example
|
|
5
|
+
```python
|
|
6
|
+
from wave_shoaling import fetch_marine_data, calculate_shoaling
|
|
7
|
+
|
|
8
|
+
# The user MUST provide the exact coordinates (no default values)
|
|
9
|
+
mar = fetch_marine_data(latitude=39.60, longitude=-9.07) # Ex: Nazaré, Portugal
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "wave-shoaling-physics"
|
|
7
|
+
version = "0.1.3"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Adrian Hernandez", email = "adrian.hernandezv@alumni.mondragon.edu"}
|
|
10
|
+
]
|
|
11
|
+
description = "Gravity wave mechanics: dispersion, shoaling and coastal breaking with real-time marine data"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
license = {text = "MIT"}
|
|
15
|
+
keywords = ["physics", "waves", "shoaling", "oceanography"]
|
|
16
|
+
dependencies = [
|
|
17
|
+
"requests>=2.28.0",
|
|
18
|
+
"numpy>=1.22.0",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Operating System :: OS Independent",
|
|
24
|
+
]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from wave_shoaling.core import solve_dispersion, calculate_shoaling
|
|
3
|
+
|
|
4
|
+
def test_dispersion_deep_water():
|
|
5
|
+
omega = 1.0
|
|
6
|
+
depth = 500.0
|
|
7
|
+
k = solve_dispersion(omega, depth)
|
|
8
|
+
expected_k = (omega ** 2) / 9.80665
|
|
9
|
+
assert np.isclose(k, expected_k, rel_tol=1e-3)
|
|
10
|
+
|
|
11
|
+
def test_calculate_shoaling_physics():
|
|
12
|
+
res = calculate_shoaling(hs_deep=2.0, tp=10.0, depth_coastal=5.0)
|
|
13
|
+
assert res["power_kw_per_meter"] > 0
|
|
14
|
+
assert isinstance(res["is_breaking"], bool)
|
|
15
|
+
|
|
16
|
+
def test_invalid_depth():
|
|
17
|
+
try:
|
|
18
|
+
solve_dispersion(omega=1.0, depth=-10.0)
|
|
19
|
+
except ValueError:
|
|
20
|
+
pass
|
|
21
|
+
else:
|
|
22
|
+
raise AssertionError("Value Error")
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from typing import Dict, Any
|
|
2
|
+
import numpy as np
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
G = 9.80665
|
|
6
|
+
RHO_SEAWATER = 1025.0
|
|
7
|
+
|
|
8
|
+
def solve_dispersion(omega: float, depth: float, tol: float = 1e-6, max_iter: int = 100) -> float:
|
|
9
|
+
if depth <= 0:
|
|
10
|
+
raise ValueError("Depth must be a positive value.")
|
|
11
|
+
k = (omega ** 2) / G
|
|
12
|
+
for _ in range(max_iter):
|
|
13
|
+
th = np.tanh(k * depth)
|
|
14
|
+
f = (omega ** 2) - G * k * th
|
|
15
|
+
df = -G * th - G * k * depth * (1.0 - th ** 2)
|
|
16
|
+
k_next = k - f / df
|
|
17
|
+
if abs(k_next - k) < tol:
|
|
18
|
+
return float(k_next)
|
|
19
|
+
k = k_next
|
|
20
|
+
return float(k)
|
|
21
|
+
|
|
22
|
+
def calculate_shoaling(hs_deep: float, tp: float, depth_coastal: float) -> Dict[str, float]:
|
|
23
|
+
omega = 2.0 * np.pi / tp
|
|
24
|
+
k_deep = (omega ** 2) / G
|
|
25
|
+
cg_deep = 0.5 * (omega / k_deep)
|
|
26
|
+
k_coastal = solve_dispersion(omega, depth_coastal)
|
|
27
|
+
wavelength_coastal = (2.0 * np.pi) / k_coastal
|
|
28
|
+
kh = k_coastal * depth_coastal
|
|
29
|
+
phase_velocity = omega / k_coastal
|
|
30
|
+
cg_coastal = phase_velocity * 0.5 * (1.0 + (2.0 * kh) / np.sinh(2.0 * kh))
|
|
31
|
+
ks = np.sqrt(cg_deep / cg_coastal)
|
|
32
|
+
hs_coastal = hs_deep * ks
|
|
33
|
+
energy_density = (1.0 / 8.0) * RHO_SEAWATER * G * (hs_coastal ** 2)
|
|
34
|
+
power_kw_m = (energy_density * cg_coastal) / 1000.0
|
|
35
|
+
h_max_miche = 0.142 * wavelength_coastal * np.tanh(kh)
|
|
36
|
+
breaks = bool(hs_coastal >= h_max_miche)
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
"wavelength_coastal_m": round(float(wavelength_coastal), 2),
|
|
40
|
+
"shoaling_coefficient": round(float(ks), 3),
|
|
41
|
+
"hs_coastal_m": round(float(hs_coastal), 2),
|
|
42
|
+
"power_kw_per_meter": round(float(power_kw_m), 2),
|
|
43
|
+
"miche_breaking_limit_m": round(float(h_max_miche), 2),
|
|
44
|
+
"is_breaking": breaks,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
def fetch_marine_data(latitude: float, longitude: float) -> Dict[str, Any]:
|
|
48
|
+
"""Downloads data forcing the user to explicitly input latitude and longitude."""
|
|
49
|
+
url = f"https://marine-api.open-meteo.com/v1/marine?latitude={latitude}&longitude={longitude}¤t=wave_height,wave_period,wave_direction"
|
|
50
|
+
res = requests.get(url, timeout=10)
|
|
51
|
+
res.raise_for_status()
|
|
52
|
+
current = res.json().get("current", {})
|
|
53
|
+
return {
|
|
54
|
+
"latitude": latitude,
|
|
55
|
+
"longitude": longitude,
|
|
56
|
+
"wave_height_m": current.get("wave_height", 1.5),
|
|
57
|
+
"wave_period_s": current.get("wave_period", 10.0),
|
|
58
|
+
"wave_direction_deg": current.get("wave_direction", 315.0),
|
|
59
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wave-shoaling-physics
|
|
3
|
+
Version: 0.1.3
|
|
4
|
+
Summary: Gravity wave mechanics: dispersion, shoaling and coastal breaking with real-time marine data
|
|
5
|
+
Author-email: Adrian Hernandez <adrian.hernandezv@alumni.mondragon.edu>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: physics,waves,shoaling,oceanography
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests>=2.28.0
|
|
15
|
+
Requires-Dist: numpy>=1.22.0
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# Wave Shoaling Physics
|
|
19
|
+
Library for modeling the propagation and shoaling of ocean waves. Requires entering coordinates explicitly to analyze any point on the planet.
|
|
20
|
+
|
|
21
|
+
## Usage example
|
|
22
|
+
```python
|
|
23
|
+
from wave_shoaling import fetch_marine_data, calculate_shoaling
|
|
24
|
+
|
|
25
|
+
# The user MUST provide the exact coordinates (no default values)
|
|
26
|
+
mar = fetch_marine_data(latitude=39.60, longitude=-9.07) # Ex: Nazaré, Portugal
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
tests/test_core.py
|
|
5
|
+
wave_shoaling/__init__.py
|
|
6
|
+
wave_shoaling/core.py
|
|
7
|
+
wave_shoaling_physics.egg-info/PKG-INFO
|
|
8
|
+
wave_shoaling_physics.egg-info/SOURCES.txt
|
|
9
|
+
wave_shoaling_physics.egg-info/dependency_links.txt
|
|
10
|
+
wave_shoaling_physics.egg-info/requires.txt
|
|
11
|
+
wave_shoaling_physics.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
wave_shoaling
|