Skip to content

Commit af99f05

Browse files
committed
Merge branch 'develop'
2 parents 0a8d201 + fc799f3 commit af99f05

File tree

11 files changed

+206
-16
lines changed

11 files changed

+206
-16
lines changed

.coveragerc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[report]
2+
exclude_lines =
3+
# Have to re-enable the standard pragma
4+
pragma: no cover
5+
6+
# Don't complain about missing debug-only code:
7+
def __repr__
8+
if self\.debug
9+
10+
# Don't complain if tests don't hit defensive assertion code:
11+
raise AssertionError
12+
raise NotImplementedError
13+
14+
# Don't complain if non-runnable code isn't run:
15+
if 0:
16+
if __name__ == .__main__.:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ wheels/
2424
*.egg-info/
2525
.installed.cfg
2626
*.egg
27+
pip-wheel-metadata/
2728

2829
# PyInstaller
2930
# Usually these files are written by a python script from a template

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ repos:
33
rev: stable
44
hooks:
55
- id: black
6-
language_version: python3.6
6+
language_version: python3.7

.readthedocs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ sphinx:
1616
# Optionally build your docs in additional formats such as PDF and ePub
1717
formats: all
1818

19+
build:
20+
image: latest
21+
1922
# Optionally set the version of Python and requirements required to build your docs
2023
python:
24+
version: 3.7
2125
install:
22-
- method: pip
23-
path: .
26+
- requirements: docs/requirements.txt

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
install:
2+
poetry install
3+
4+
docs:
5+
poetry run sphinx-build -M html ".\docs" ".\docs\_build"
6+
7+
# Requirements.txt needed to build docs on readthedocs.io
8+
freeze-requirements:
9+
poetry run pip freeze --exclude-editable > ./docs/requirements.txt
10+
11+
#
12+
bump:
13+
poetry version
14+
@echo "Remember to increase version in py_wave_runup/__init__.py"
15+
16+
17+
###############################
18+
# Help command
19+
20+
.DEFAULT_GOAL := help
21+
.PHONY: help
22+
23+
# Refer to https://gist.github.com/prwhite/8168133
24+
25+
#COLORS
26+
GREEN := $(shell tput -Txterm setaf 2)
27+
WHITE := $(shell tput -Txterm setaf 7)
28+
YELLOW := $(shell tput -Txterm setaf 3)
29+
RESET := $(shell tput -Txterm sgr0)
30+
31+
# Add the following 'help' target to your Makefile
32+
# And add help text after each target name starting with '\#\#'
33+
# A category can be added with @category
34+
HELP_FUN = \
35+
%help; \
36+
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
37+
print "usage: make [target]\n\n"; \
38+
for (sort keys %help) { \
39+
print "${WHITE}$$_:${RESET}\n"; \
40+
for (@{$$help{$$_}}) { \
41+
$$sep = " " x (32 - length $$_->[0]); \
42+
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
43+
}; \
44+
print "\n"; }
45+
46+
help: ##@other Show this help.
47+
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)

docs/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# Add any Sphinx extension module names here, as strings. They can be
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
33-
extensions = ["sphinx.ext.autodoc"]
33+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.mathjax", "sphinx.ext.napoleon"]
3434

3535
# Add any paths that contain templates here, relative to this directory.
3636
templates_path = ["_templates"]
@@ -62,6 +62,9 @@
6262
pygments_style = "sphinx"
6363

6464

65+
# Autodoc options
66+
67+
# Define what classes to skip
6568
def autodoc_skip_member(app, what, name, obj, skip, options):
6669
exclusions = ("RunupModel",)
6770
exclude = name in exclusions
@@ -70,3 +73,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
7073

7174
def setup(app):
7275
app.connect("autodoc-skip-member", autodoc_skip_member)
76+
77+
78+
# Define order
79+
autodoc_member_order = "bysource"

docs/requirements.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
alabaster==0.7.12
2+
aspy.yaml==1.2.0
3+
atomicwrites==1.3.0
4+
attrs==19.1.0
5+
Babel==2.6.0
6+
certifi==2019.3.9
7+
cfgv==1.6.0
8+
chardet==3.0.4
9+
codecov==2.0.15
10+
colorama==0.4.1
11+
coverage==4.5.3
12+
docutils==0.14
13+
filelock==3.0.10
14+
identify==1.4.1
15+
idna==2.8
16+
imagesize==1.1.0
17+
importlib-metadata==0.9
18+
importlib-resources==1.0.2
19+
Jinja2==2.10.1
20+
MarkupSafe==1.1.1
21+
more-itertools==5.0.0
22+
nodeenv==1.3.3
23+
numpy==1.16.2
24+
packaging==19.0
25+
pluggy==0.9.0
26+
pre-commit==1.15.1
27+
py==1.8.0
28+
Pygments==2.3.1
29+
pyparsing==2.4.0
30+
pytest==4.4.0
31+
pytest-cov==2.6.1
32+
pytest-runner==4.4
33+
pytz==2019.1
34+
PyYAML==5.1
35+
requests==2.21.0
36+
six==1.12.0
37+
snowballstemmer==1.2.1
38+
Sphinx==2.0.1
39+
sphinxcontrib-applehelp==1.0.1
40+
sphinxcontrib-devhelp==1.0.1
41+
sphinxcontrib-htmlhelp==1.0.1
42+
sphinxcontrib-jsmath==1.0.1
43+
sphinxcontrib-qthelp==1.0.2
44+
sphinxcontrib-serializinghtml==1.1.3
45+
toml==0.10.0
46+
tox==3.8.6
47+
urllib3==1.24.1
48+
virtualenv==16.4.3
49+
zipp==0.3.3

py_wave_runup/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.0"
1+
__version__ = "0.1.2"

py_wave_runup/models.py

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33
import numpy as np
44

55

6-
class RunupModel(object):
6+
class RunupModel(metaclass=ABCMeta):
77
"""
88
Abstract base class which our empirical runup models will inherit from
99
"""
1010

11-
__metaclass__ = ABCMeta
12-
1311
doi = None
1412

1513
def __init__(self, Hs=None, Tp=None, beta=None, Lp=None):
1614
"""
17-
Test
18-
19-
:param Hs: description
20-
:param Tp: description
21-
:param beta: description
22-
:param Lp: description
15+
Args:
16+
Hs (:obj:`float` or :obj:`list`): Significant wave height. In order to
17+
account for energy dissipation in the nearshore, transform the wave to
18+
the nearshore, then reverse-shoal to deep water.
19+
beta (:obj:`float` or :obj:`list`): Beach slope. Typically defined as the
20+
slope between the region of :math:`\\pm2\\sigma` where :math:`\\sigma`
21+
is the standard deviation of the continuous water level record.
22+
Tp (:obj:`float` or :obj:`list`): Peak wave period.
23+
Must be defined if :attr:`Lp` is not defined.
24+
Lp (:obj:`float` or :obj:`list`): Peak wave length
25+
Must be definied if :attr:`Tp` is not defined.
2326
"""
2427

2528
self.Hs = Hs
@@ -87,11 +90,48 @@ def swash(self):
8790

8891

8992
class Stockdon2006(RunupModel):
93+
"""
94+
95+
This class implements the empirical wave runup model from:
96+
97+
Stockdon, H. F., Holman, R. A., Howd, P. A., & Sallenger, A. H. (2006).
98+
Empirical parameterization of setup, swash, and runup. Coastal Engineering,
99+
53(7), 573–588. https://doi.org/10.1016/j.coastaleng.2005.12.005
100+
101+
Examples:
102+
Calculate 2% exceedence runup level, including setup component and swash
103+
component given Hs=4m, Tp=11s, beta=0.1.
104+
105+
>>> from py_wave_runup.models import Stockdon2006
106+
>>> sto06 = Stockdon2006(Hs=4, Tp=11, beta=0.1)
107+
>>> sto06.R2
108+
2.54
109+
>>> sto06.setup
110+
0.96
111+
>>> sto06.swash
112+
2.64
113+
"""
90114

91115
doi = "10.1016/j.coastaleng.2005.12.005"
92116

93117
@property
94118
def R2(self):
119+
"""
120+
Returns:
121+
The 2% exceedence runup level. For dissipative beaches (i.e.
122+
:math:`\\zeta < 0.3`) Eqn (18) from the paper is used:
123+
124+
.. math:: R_{2} = 0.043(H_{s}L_{p})^{0.5}
125+
126+
For intermediate and reflective beaches (i.e. :math:`\\zeta > 0.3`),
127+
the function returns the result from Eqn (19):
128+
129+
.. math::
130+
131+
R_{2} = 1.1 \\left( 0.35 \\beta (H_{s}L_{p})^{0.5} + \\frac{H_{s}L_{p}(
132+
0.563 \\beta^{2} +0.004)^{0.5}}{2} \\right)
133+
"""
134+
95135
# Generalized runup (Eqn 19)
96136
result = 1.1 * (
97137
0.35 * self.beta * (self.Hs * self.Lp) ** 0.5
@@ -109,24 +149,50 @@ def R2(self):
109149

110150
@property
111151
def setup(self):
152+
"""
153+
Returns:
154+
The setup level using Eqn (10):
155+
156+
.. math:: \\bar{\\eta} = 0.35 \\beta (H_{s}L_{p})^{0.5}
157+
158+
159+
"""
112160
result = 0.35 * self.beta * (self.Hs * self.Lp) ** 0.5
113161
result = self._return_one_or_array(result)
114162
return result
115163

116164
@property
117165
def sinc(self):
166+
"""
167+
Returns:
168+
Incident component of swash using Eqn (11):
169+
170+
.. math:: S_{inc} = 0.75 \\beta (H_{s}L_{p})^{0.5}
171+
"""
118172
result = 0.75 * self.beta * (self.Hs * self.Lp) ** 0.5
119173
result = self._return_one_or_array(result)
120174
return result
121175

122176
@property
123177
def sig(self):
178+
"""
179+
Returns:
180+
Infragravity component of swash using Eqn (12):
181+
182+
.. math:: S_{ig} = 0.06 (H_{s}L_{p})^{0.5}
183+
"""
124184
result = 0.06 * (self.Hs * self.Lp) ** 0.5
125185
result = self._return_one_or_array(result)
126186
return result
127187

128188
@property
129189
def swash(self):
190+
"""
191+
Returns:
192+
Total amount of swash using Eqn (7):
193+
194+
.. math:: S = \\sqrt{S_{inc}^{2}+S_{ig}^{2}}
195+
"""
130196
result = np.sqrt(self.sinc ** 2 + self.sig ** 2)
131197
result = self._return_one_or_array(result)
132198
return result

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "py-wave-runup"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "Empirical wave runup models implemented in Python"
55
authors = ["Chris Leaman"]
66
license = "GPL-3.0+"

0 commit comments

Comments
 (0)