Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python 3.12 to tests; remove lint #41

Merged
merged 17 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .github/workflows/lint.yml

This file was deleted.

6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
Expand All @@ -31,7 +31,3 @@ jobs:
- name: Test
run: |
nox -s test

# - name: Test Notebooks
# run: |
# nox -s test-notebooks
40 changes: 11 additions & 29 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.2.0
hooks:
- id: black
name: black
Expand All @@ -23,16 +23,16 @@ repos:
additional_dependencies: [".[jupyter]"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.3
rev: 1.7.1
hooks:
- id: nbqa-pyupgrade
args: ["--py38-plus"]
args: ["--py310-plus"]
- id: nbqa-isort
- id: nbqa-flake8
args: ["--extend-ignore=E402"]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -46,26 +46,26 @@ repos:
)

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
description: Strip output from jupyter notebooks
args: [--drop-empty-cells]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.15.1
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py310-plus]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
files: \.py$
args: ["--force-single-line-imports"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
Expand All @@ -83,21 +83,3 @@ repos:
.*requirements(-\w+)?.(in|txt)|
MANIFEST.in
)

- repo: https://github.com/regebro/pyroma
rev: "4.1"
hooks:
- id: pyroma
args: ["-d", "--min=10", "."]
additional_dependencies:
- numpy
- cython

- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
args: ["--ignore=.nox,build", "--no-build-isolation"]
additional_dependencies:
- numpy
- cython
13 changes: 0 additions & 13 deletions MANIFEST.in

This file was deleted.

88 changes: 57 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
[![DOI](https://zenodo.org/badge/310435424.svg)](https://zenodo.org/doi/10.5281/zenodo.10003561)
![[DOI][doi-link]][doi-badge]


[barrier3d-github]:https://github.com/UNC-CECL/Barrier3D
[brie-github]: https://github.com/UNC-CECL/brie
[cascade-figure]: https://user-images.githubusercontent.com/57640439/226623608-d0c58437-d44f-4dca-8f43-0b92623fcda6.png
[chom-github]: https://github.com/UNC-CECL/CHOM
[doi-badge]: https://zenodo.org/badge/310435424.svg
[doi-link]: https://zenodo.org/doi/10.5281/zenodo.10003561
[nox-docs]: https://nox.thea.codes/
[preprint-doi]: https://doi.org/10.31223/X5P947
[zip-download]: https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip


🌀 🌊 🏄‍♀️ 🏚️ 🌀 🌊 🏄‍♀️ 🏚️ 🌀 🌊 🏄‍♀️ 🏚️ 🌀 🌊 🏄‍♀️ 🏚️
# cascade
Expand All @@ -15,10 +27,10 @@ are incorporated in *cascade* in two separate modules. The first module simulate
pavement damage during overwashing events, including rebuilding roadways at sufficiently low elevations to allow for
burial by overwash, constructing large dunes, and relocating the road into the barrier interior. The second module
incorporates management strategies for maintaining a coastal community, including beach nourishment, dune construction,
and overwash removal. For a full description of model dynamics, please see "The Future of Developed
Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by Anarde et al., (2024, [Earth ArXiv preprint](https://doi.org/10.31223/X5P947)).
and overwash removal. For a full description of model dynamics, please see *"The Future of Developed
Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by Anarde et al., (2024, [Earth ArXiv preprint][preprint-doi])*.

![ModelTimeLoop-01](https://user-images.githubusercontent.com/57640439/226623608-d0c58437-d44f-4dca-8f43-0b92623fcda6.png)
![ModelTimeLoop-01][cascade-figure]

In development: *cascade* represents decisions about coastal land-use (e.g., housing markets) and community-level
mitigation measures using an empirically-grounded agent-based real estate model – the Coastal Home Ownership Model (*chom*).
Expand All @@ -42,19 +54,23 @@ on local wave and sediment characteristics as well as the offshore wave climate
Lorenzo-Trueba & Ashton, 2014; Ortiz & Ashton, 2016). For ease of model coupling, *brie* and *chom* were rewritten in Python
and all models (*barrier3d*, *brie*, *chom*) were appended with a basic-model interface with the help of the
Community Surface Dynamics Modeling System. The repositories for the models coupled within *cascade* are noted here:
- *barrier3d*: [GitHub Python Repository - Version 2.0 (BMI)](https://github.com/UNC-CECL/Barrier3D)
- *brie*: [GitHub Python Repository - Version 1.0 (BMI)](https://github.com/UNC-CECL/brie)
- *chom*: [GitHub Python Repository - Version 0.0.1.dev0 (BMI)](https://github.com/UNC-CECL/CHOM)
- *barrier3d*: [GitHub Python Repository - Version 2.0 (BMI)][barrier3d-github]
- *brie*: [GitHub Python Repository - Version 1.0 (BMI)][brie-github]
- *chom*: [GitHub Python Repository - Version 0.0.1.dev0 (BMI)][chom-github]

## Installation

To install the latest release of *cascade* using *pip*, simply run the following in your terminal of choice:

pip install coastal-cascade
```bash
pip install coastal-cascade
```

You can also use `conda`:

conda install coastal-cascade
```bash
conda install coastal-cascade
```

### From Source

Expand All @@ -64,51 +80,61 @@ need to get *cascade*'s source code, and then install *cascade* from that code.

To get the source code you can either clone the repository with *git*:

git clone git@github.com/UNC-CECL/cascade
```bash
git clone git@github.com:UNC-CECL/cascade
```

or download a [zip file](https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip):
or download a [zip file][zip-download]:

curl -OL https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip
```bash
curl -OL https://github.com/UNC-CECL/CASCADE/archive/refs/heads/main.zip
```

Once you have a copy of the source code, you can install it into your current
environment,

pip install -e .
```bash
pip install -e .
```

We use [nox] to automate routine maintenance tasks like running the tests,
removing lint, etc. Install [nox] with *pip*::
We use [nox-docs] to automate routine maintenance tasks like running the tests,
removing lint, etc. Install [nox-docs] with *pip*::

pip install nox
```bash
pip install nox
```

When you're done making changes, you can now run [nox] to check that the tests
When you're done making changes, you can now run [nox-docs] to check that the tests
pass and that there isn't any lint:

nox -s test # run the unit tests
nox -s test-notebooks # test that the notebooks run successfully
nox -s lint # find and, where possible, remove lint (black, flake8, etc.)
```bash
nox -s test # run the unit tests
nox -s test-notebooks # test that the notebooks run successfully
nox -s lint # find and, where possible, remove lint (black, flake8, etc.)
```

To run all of the above in a single command:

nox

[nox]: https://nox.thea.codes/
```bash
nox
```

## Example simulations
This ReadMe corresponds to the version of *cascade* used for the simulations detailed in
*"The Future of Developed Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by
Anarde et al., (2024, [Earth ArXiv preprint](https://doi.org/10.31223/X5P947))* -- namely, v1.0.0. For a more complete
This ReadMe corresponds to the version of *cascade* used for the simulations detailed in
*"The Future of Developed Barrier Systems - Part I: Pathways Toward Uninhabitability, Drowning, and Rebound" by
Anarde et al., (2024, [Earth ArXiv preprint][preprint-doi])* -- namely, v1.0.0. For a more complete
set of example model runs and description of module functionality, we direct the use to the examples
provided in `notebooks`.

Example (default) data inputs for cascade are provided in the `data` directory:
```
```python
from cascade.cascade import Cascade

datadir = "data/"
```
To initialize an instance of *cascade* with no human dynamics, 3 barrier segments (each 500-m long), and
default *barrier3d* and *brie* parameters:
```
```python
cascade = Cascade(
datadir,
name="no_human_dynamics_3_barrier_segments",
Expand All @@ -120,7 +146,7 @@ cascade = Cascade(
)
```
To initialize an instance of *cascade* with roadway barrier management on 1 barrier segment:
```
```python
cascade = Cascade(
datadir,
name="roadway_mgmt_1_barrier_segments",
Expand All @@ -132,7 +158,7 @@ cascade = Cascade(
)
```
To initialize *cascade* with community barrier management on 1 barrier segment:
```
```python
cascade = Cascade(
datadir,
name="community_mgmt_1_barrier_segments",
Expand All @@ -144,7 +170,7 @@ cascade = Cascade(
)
```
Once initialized, a *cascade* time loop can be completed as follows:
```
```python
for time_step in range(cascade.time_step_count - 1):
cascade.update()
if cascade.b3d_break:
Expand Down
22 changes: 12 additions & 10 deletions cascade/beach_dune_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
initial beach slope defined in Barrier3D to develop the storm series. This beach
width is then modified dynamically via nourishment and shoreface dynamics.
"""

import copy
import math

import numpy as np

from .roadway_manager import rebuild_dunes, set_growth_parameters
from .roadway_manager import rebuild_dunes
from .roadway_manager import set_growth_parameters

dm3_to_m3 = 1000 # convert from cubic decameters to cubic meters

Expand Down Expand Up @@ -292,9 +294,9 @@ def filter_overwash(
else:
# spread overwash removed from roadway equally over the adjacent dune cells
total_overwash_removal_dune_volume = sum(overwash_removal_dune) # array of dam
total_overwash_removal_dune_volume[
total_overwash_removal_dune_volume < 0
] = 0 # don't let it erode a dune
total_overwash_removal_dune_volume[total_overwash_removal_dune_volume < 0] = (
0 # don't let it erode a dune
)
number_dune_cells = np.size(post_storm_yxz_dune_grid, 1)
overwash_volume_to_dune = np.transpose(
[total_overwash_removal_dune_volume / number_dune_cells] * number_dune_cells
Expand All @@ -304,9 +306,9 @@ def filter_overwash(

# don't allow dunes to exceed a maximum height (limits 10-m dunes after big
# storms...yikes!); assume the rest of the sand disappears
new_dune_domain[
new_dune_domain > artificial_maximum_dune_height
] = artificial_maximum_dune_height
new_dune_domain[new_dune_domain > artificial_maximum_dune_height] = (
artificial_maximum_dune_height
)

# dam^3
total_overwash_removal = (
Expand Down Expand Up @@ -499,9 +501,9 @@ def abandonment_cleanup_tasks(

# turn dune migration back on
barrier3d.dune_migration_on = True
self._dune_migration_on[
self._time_index - 1
] = barrier3d.dune_migration_on # keep track!
self._dune_migration_on[self._time_index - 1] = (
barrier3d.dune_migration_on
) # keep track!

# set the shoreline change aggregate to the dam (cell) fraction
barrier3d.SCRagg[self._time_index - 1] = (barrier3d.x_s % 1) * -1
Expand Down
4 changes: 3 additions & 1 deletion cascade/brie_coupler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
In future versions, the coupled model will incorporate tidal inlet dynamics
within BRIE (i.e., the inlet model will be turned on).
"""

import math
import pathlib

import numpy as np
from barrier3d import Barrier3d
from brie import Brie
from yaml import dump, full_load
from yaml import dump
from yaml import full_load


def set_yaml(var_name, new_vals, file_name):
Expand Down
Loading
Loading