Skip to content

Commit 8a1f951

Browse files
committed
remove lint
1 parent 28fae64 commit 8a1f951

18 files changed

+146
-197
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ A spatially explicit exploratory model of coastal barrier evolution.
66

77
### Full documentation for Barrier3D is available at: <https://unc-cecl.github.io/Barrier3D/>
88

9-
There are two primary branches for this repository:
10-
- `Barrier3D-v1.0` -- Created by Ian Reeves and used for all simulations in Reeves et al., 2021 (GRL)
9+
There are two primary branches for this repository:
10+
- `Barrier3D-v1.0` -- Created by Ian Reeves and used for all simulations in Reeves et al., 2021 (GRL)
1111
- `master` -- Contains a basical model interface, written by Eric Hutton and Katherine Anarde and used in Anarde et al., (in prep). This branch contains an abbreviated copy of `Barrier3D-v1.0` for testing purposes.

barrier3d/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
from .load_input import load_inputs
66

77
__all__ = [
8-
"__version__", "Barrier3d", "Barrier3dBmi", "Barrier3dConfiguration", "load_inputs"
8+
"__version__",
9+
"Barrier3d",
10+
"Barrier3dBmi",
11+
"Barrier3dConfiguration",
12+
"load_inputs",
913
]

barrier3d/barrier3d.py

+26-32
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import copy
12
import math
3+
import random
4+
25
import numpy as np
6+
37
from .load_input import load_inputs
4-
import random
5-
import copy
68

79

810
class Barrier3dError(Exception):
@@ -61,7 +63,7 @@ def DuneGrowth(self, DuneDomain, t):
6163
Qdg = 0
6264
# Grow dune
6365
for q in range(self._DuneWidth):
64-
reduc = 1 / (Cf ** q)
66+
reduc = 1 / (Cf**q)
6567
G = (
6668
self._growthparam
6769
* DuneDomain[t - 1, :, q]
@@ -197,7 +199,6 @@ def Shrubs(
197199
self._BarrierLength
198200
): # Loop through each row of island width (i.e. from ocean to mainland side of island)
199201
if 0 in ShrubDomainAll:
200-
201202
# For all cells with a shrub
202203
FemaleShrubs = ShrubDomainFemale[:, k]
203204
fruiting_shrub = [
@@ -831,7 +832,7 @@ def __init__(self, **kwds):
831832

832833
if len(kwds) > 0:
833834
raise ValueError(
834-
"unrecognized keywords ({0})".format(", ".join(kwds.keys()))
835+
"unrecognized keywords ({})".format(", ".join(kwds.keys()))
835836
)
836837

837838
# ### Initialize Shrubs
@@ -927,7 +928,6 @@ def from_yaml(cls, path_to_yaml, prefix="barrier3d"):
927928
return cls(**load_inputs(path_to_yaml, prefix=prefix, fmt="yaml"))
928929

929930
def update(self):
930-
931931
# ###########################################
932932
# ### increase sea level and start new time step
933933
# ###########################################
@@ -1002,7 +1002,6 @@ def update(self):
10021002

10031003
# ### Individual Storm Impacts
10041004
for n in range(numstorm): # Loop through each individual storm
1005-
10061005
# ###########################################
10071006
# ### Dune Erosion
10081007

@@ -1013,7 +1012,7 @@ def update(self):
10131012
# Find overwashed dunes and gaps
10141013
Dow = [
10151014
index
1016-
for index, value in enumerate((DuneDomainCrest + self._BermEl))
1015+
for index, value in enumerate(DuneDomainCrest + self._BermEl)
10171016
if value < Rhigh[n]
10181017
]
10191018
gaps = self.DuneGaps(
@@ -1022,7 +1021,6 @@ def update(self):
10221021

10231022
for d in range(len(Dow)): # Loop through each overwashed dune cell
10241023
for w in range(self._DuneWidth):
1025-
10261024
# Calculate dune elevation loss
10271025
Rnorm = Rhigh[n] / (
10281026
self._DuneDomain[self._time_index, Dow[d], w]
@@ -1113,11 +1111,14 @@ def update(self):
11131111
# Set Domain
11141112
duration = dur[n] * substep
11151113
width = (
1116-
np.shape(self._InteriorDomain)[0] + 1 + self._bay_routing_width
1114+
np.shape(self._InteriorDomain)[0] + 1 + self._bay_routing_width
11171115
) # (dam) Add one for Dunes and 25 for bay
11181116
Elevation = np.zeros([duration, width, self._BarrierLength])
11191117
Dunes = Dunes_prestorm + self._BermEl
1120-
Bay = np.ones([self._bay_routing_width, self._BarrierLength]) * -self._BayDepth
1118+
Bay = (
1119+
np.ones([self._bay_routing_width, self._BarrierLength])
1120+
* -self._BayDepth
1121+
)
11211122
Elevation[0, :, :] = np.vstack([Dunes, self._InteriorDomain, Bay])
11221123

11231124
# Initialize Memory Storage Arrays
@@ -1159,7 +1160,6 @@ def update(self):
11591160

11601161
# ### Run Flow Routing Algorithm
11611162
for TS in range(duration):
1162-
11631163
ShrubDomainWidth = np.shape(self._ShrubDomainFemale)[0]
11641164
DeadDomainWidth = np.shape(self._ShrubDomainDead)[0]
11651165

@@ -1179,7 +1179,6 @@ def update(self):
11791179

11801180
for i in range(self._BarrierLength):
11811181
if Discharge[TS, d, i] > 0:
1182-
11831182
Q0 = Discharge[TS, d, i]
11841183

11851184
# ### Calculate Slopes
@@ -1207,7 +1206,6 @@ def update(self):
12071206
# ### Calculate Discharge To Downflow Neighbors
12081207
# One or more slopes positive
12091208
if S1 > 0 or S2 > 0 or S3 > 0:
1210-
12111209
if S1 < 0:
12121210
S1 = 0
12131211
if S2 < 0:
@@ -1217,29 +1215,29 @@ def update(self):
12171215

12181216
Q1 = (
12191217
Q0
1220-
* S1 ** self._nn
1218+
* S1**self._nn
12211219
/ (
1222-
S1 ** self._nn
1223-
+ S2 ** self._nn
1224-
+ S3 ** self._nn
1220+
S1**self._nn
1221+
+ S2**self._nn
1222+
+ S3**self._nn
12251223
)
12261224
)
12271225
Q2 = (
12281226
Q0
1229-
* S2 ** self._nn
1227+
* S2**self._nn
12301228
/ (
1231-
S1 ** self._nn
1232-
+ S2 ** self._nn
1233-
+ S3 ** self._nn
1229+
S1**self._nn
1230+
+ S2**self._nn
1231+
+ S3**self._nn
12341232
)
12351233
)
12361234
Q3 = (
12371235
Q0
1238-
* S3 ** self._nn
1236+
* S3**self._nn
12391237
/ (
1240-
S1 ** self._nn
1241-
+ S2 ** self._nn
1242-
+ S3 ** self._nn
1238+
S1**self._nn
1239+
+ S2**self._nn
1240+
+ S3**self._nn
12431241
)
12441242
)
12451243

@@ -1249,7 +1247,6 @@ def update(self):
12491247

12501248
# No slopes positive, one or more equal to zero
12511249
elif S1 == 0 or S2 == 0 or S3 == 0:
1252-
12531250
pos = 0
12541251
if S1 == 0:
12551252
pos += 1
@@ -1276,7 +1273,6 @@ def update(self):
12761273

12771274
# All slopes negative
12781275
else:
1279-
12801276
Q1 = (
12811277
Q0
12821278
* abs(S1) ** (-self._nn)
@@ -1490,7 +1486,6 @@ def update(self):
14901486
SedFluxOut[TS, d, i] = Qs_out
14911487

14921488
else: # If cell is subaqeous, exponentially decay dep. of remaining sed across bay
1493-
14941489
if inundation == 0:
14951490
Cbb = self._Cbb_r
14961491
else:
@@ -1654,7 +1649,6 @@ def update(self):
16541649
)
16551650

16561651
def update_dune_domain(self):
1657-
16581652
# ###########################################
16591653
# ### update dune domain (erode/prograde) based on on shoreline change
16601654
# ###########################################
@@ -1953,11 +1947,11 @@ def RSLR(self):
19531947
@RSLR.setter
19541948
def RSLR(self, value):
19551949
self._RSLR = value
1956-
1950+
19571951
@property
19581952
def SL(self):
19591953
return self._SL
1960-
1954+
19611955
@property
19621956
def Hd_AverageTS(self):
19631957
return self._Hd_AverageTS

barrier3d/bmi.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010

1111
class Barrier3dBmi(Bmi):
12-
1312
_name = "Barrier3D"
1413
_input_var_names = ()
1514
_output_var_names = (

barrier3d/cli.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
import os
43
import pathlib
54
from functools import partial
@@ -39,7 +38,7 @@ def __init__(self, bmi, output_interval=1, filepath="output.csv"):
3938
self._steps = 0
4039

4140
with open(filepath, mode="w") as fp:
42-
print("# version: {0}".format(__version__), file=fp)
41+
print(f"# version: {__version__}", file=fp)
4342
print(
4443
",".join(
4544
[
@@ -117,7 +116,7 @@ def run(dry_run: bool, verbose: bool) -> None:
117116
# message.append("missing Barrier3D configuration file: {0}".format(config_file))
118117
if (run_dir / "output.csv").exists():
119118
message.append(
120-
"Barrier3D output file already exists: {0}".format(run_dir / "output.csv")
119+
"Barrier3D output file already exists: {}".format(run_dir / "output.csv")
121120
)
122121
if message:
123122
err(os.linesep.join(message))
@@ -136,7 +135,7 @@ def run(dry_run: bool, verbose: bool) -> None:
136135
with click.progressbar(
137136
range(n_steps),
138137
label=" ".join(["🚀", str(run_dir)]),
139-
item_show_func=lambda step: "step {0} of {1}".format(
138+
item_show_func=lambda step: "step {} of {}".format(
140139
int(0 if step is None else step), n_steps
141140
),
142141
) as bar:

barrier3d/tools/input_files.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import bisect
2727
import pathlib
2828
import random
29-
from distfit import distfit
3029

3130
import matplotlib.pyplot as plt
3231
import numpy as np
32+
from distfit import distfit
3333

3434
from ..load_input import _guess_format
3535

@@ -64,13 +64,14 @@ def yearly_storms(
6464
if fmt == "npy":
6565
StormList = np.load(datadir / storm_list_name, allow_pickle=True)
6666
elif fmt == "csv":
67-
StormList = np.loadtxt(datadir / storm_list_name, delimiter=",", encoding='utf-8-sig')
67+
StormList = np.loadtxt(
68+
datadir / storm_list_name, delimiter=",", encoding="utf-8-sig"
69+
)
6870

6971
# pad with zeros until storms start
7072
StormSeries = np.zeros([StormStart, 5])
7173

7274
for t in range(StormStart, model_years):
73-
7475
# Calculate number of storms in year
7576
numstorm = round(np.random.normal(mean_yearly_storms, SD_yearly_storms))
7677
if numstorm < 0:
@@ -206,7 +207,6 @@ def shift_storm_intensity(
206207
StormSeries = np.zeros([StormStart, 5])
207208

208209
for t in range(StormStart, model_years):
209-
210210
# Calculate number of storms in year
211211
numstorm = max(0, round(np.random.normal(mean_yearly_storms, SD_yearly_storms)))
212212
stormTS = np.zeros([numstorm, 5])
@@ -342,14 +342,12 @@ def frequency_storms(
342342
StormSeries = np.zeros([StormStart, 5])
343343

344344
for t in range(StormStart, model_years):
345-
346345
# only allow for one storm per year
347346
numstorm = 1
348347
stormTS = np.zeros([numstorm, 5])
349348

350349
# Select storms for year
351350
if t % return_period == 0:
352-
353351
stormTS[0, 0] = t
354352
stormTS[0, 1] = Rhigh[id]
355353
stormTS[0, 2] = Rlow[id]

barrier3d/tools/plot.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
def plot_dune_height(dune_height, max_dune_height):
6-
76
dune_crest = dune_height.max(axis=2)
87

98
fig = plt.figure(figsize=(14, 8))
@@ -60,7 +59,6 @@ def plot_ElevTMAX(
6059
DeadPercentCoverTS,
6160
DuneWidth,
6261
):
63-
6462
TMAX = TMAX - 1
6563
Dunes = (DuneDomain[TMAX, :, :] + BermEl) * 10
6664
Dunes = np.rot90(Dunes)

0 commit comments

Comments
 (0)