Skip to content

Commit

Permalink
Merge pull request #20 from mcflugen/mcflugen/v0.2.3b0
Browse files Browse the repository at this point in the history
Release v0.2.3
  • Loading branch information
mcflugen authored Nov 22, 2023
2 parents 438f527 + cc13548 commit 9197e71
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 68 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
rev: 1.7.0
hooks:
- id: nbqa-pyupgrade
args: ["--py39-plus"]
args: ["--py310-plus"]
- id: nbqa-isort
- id: nbqa-flake8
args: ["--extend-ignore=E402"]
Expand All @@ -55,7 +55,7 @@ repos:
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
args: [--py310-plus]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
Expand Down
17 changes: 17 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,20 @@
<!-- towncrier-draft-entries:: Not yet released -->

<!-- towncrier release notes start -->

## [0.2.3](https://github.com/mcflugen/compaction/tree/0.2.3) - 2023-11-21


### Other Changes and Additions

- Set up [towncrier](https://towncrier.readthedocs.io/en/stable/index.html)
to manage the changelog. [#16](https://github.com/mcflugen/compaction/issues/16)
- Added a [pre-commit](https://pre-commit.com/) hook file for running
the linters. [#16](https://github.com/mcflugen/compaction/issues/16)
- Added a [nox](https://nox.thea.codes/en/stable/) file for routine
project management like running the tests and linting. [#16](https://github.com/mcflugen/compaction/issues/16)
- Added GitHub Actions for running the continuous integration tests, which
includes running the tests and linters. [#16](https://github.com/mcflugen/compaction/issues/16)
- Moved static project metadata from *setup.py* to the now standard
*pyproject.toml*. [#16](https://github.com/mcflugen/compaction/issues/16)
- Added support for Python 3.12 and dropped support for Python 3.9. [#19](https://github.com/mcflugen/compaction/issues/19)
105 changes: 68 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[![Test][test_badge]][test_workflow]
[test_badge]: https://github.com/mcflugen/compaction/actions/workflows/test.yml/badge.svg
[test_workflow]: https://github.com/mcflugen/compaction/actions/workflows/test.yml


# compaction: Compact layers of sediment

Compact a column of sediment following Bahr et al., 2001.

Cite as::

@article{bahr2001exponential,
title={Exponential approximations to compacted sediment porosity profiles},
author={Bahr, David B and Hutton, Eric WH and Syvitski, James PM and Pratson, Lincoln F},
journal={Computers \& Geosciences},
volume={27},
number={6},
pages={691--700},
year={2001},
publisher={Pergamon}
}
Cite as,

```bibtex
@article{bahr2001exponential,
title={Exponential approximations to compacted sediment porosity profiles},
author={Bahr, David B and Hutton, Eric WH and Syvitski, James PM and Pratson, Lincoln F},
journal={Computers \& Geosciences},
volume={27},
number={6},
pages={691--700},
year={2001},
publisher={Pergamon}
}
```

## Requirements

Expand All @@ -43,27 +43,35 @@ which *Compaction* will be installed. This, although not necessary, will
isolate the installation so that there won't be conflicts with your
base *Python* installation. This can be done with *conda* as:

$ conda create -n compaction python=3
$ conda activate compaction
```bash
conda create -n compaction python=3
conda activate compaction
```

## Stable Release

*Compaction*, and its dependencies, can be installed either with *pip*
or *conda*. Using *pip*:

$ pip install compaction
```bash
pip install compaction
```

Using *conda*:

$ conda install compaction -c conda-forge
```bash
conda install compaction -c conda-forge
```

### From Source

After downloading the *Compaction* source code, run the following from
*Compaction*'s top-level folder (the one that contains *setup.py*) to
install *Compaction* into the current environment:

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

## Input Files

Expand All @@ -73,12 +81,17 @@ The main *Compaction* input file is a yaml-formatted text file that lists
constants used by *Compaction*. Running the following will print a sample
*Compaction* configuration file:

$ compact show config
c: 5.0e-08
porosity_max: 0.5
porosity_min: 0.0
rho_grain: 2650.0
rho_void: 1000.0
```
compact show config
```

```yaml
c: 5.0e-08
porosity_max: 0.5
porosity_min: 0.0
rho_grain: 2650.0
rho_void: 1000.0
```
### Porosity File
Expand All @@ -87,11 +100,16 @@ sediment layers to be compacted as a two-column CSV file. The first
column is layer thickness (in meters) and the second the porosity of
the sediment in that layer. A sample porosity file can be obtained with:
$ compact show porosity
# Layer Thickness [m], Porosity [-]
100.0,0.5
100.0,0.5
100.0,0.5
```bash
compact show porosity
```

```
# Layer Thickness [m], Porosity [-]
100.0,0.5
100.0,0.5
100.0,0.5
```

## Output File

Expand All @@ -103,13 +121,26 @@ the input porosity file - a CSV file of layer thickness and porosity.
To run a simulation using the sample input files described above, you first
need to create a set of sample files:

$ sequence setup example
example/sequence.yaml
```
sequence setup example
```

```
example/sequence.yaml
```

You can now run the simulation:

$ sequence run example/sequence.yaml
# Layer Thickness [m], Porosity [-]
100.0,0.5
96.18666488709239,0.4801774231522433
92.78860257194452,0.4611407154102571
```bash
sequence run example/sequence.yaml
```

```
# Layer Thickness [m], Porosity [-]
100.0,0.5
96.18666488709239,0.4801774231522433
92.78860257194452,0.4611407154102571
```

[test_badge]: https://github.com/mcflugen/compaction/actions/workflows/test.yml/badge.svg
[test_workflow]: https://github.com/mcflugen/compaction/actions/workflows/test.yml
3 changes: 0 additions & 3 deletions news/16.misc.1

This file was deleted.

3 changes: 0 additions & 3 deletions news/16.misc.2

This file was deleted.

3 changes: 0 additions & 3 deletions news/16.misc.3

This file was deleted.

3 changes: 0 additions & 3 deletions news/16.misc.4

This file was deleted.

3 changes: 0 additions & 3 deletions news/16.misc.5

This file was deleted.

2 changes: 0 additions & 2 deletions news/19.misc

This file was deleted.

13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["cython~=3.0.0b3", "numpy", "setuptools", "wheel"]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -19,7 +19,7 @@ keywords = [
"numerical modeling",
"sediment compaction",
]
license = {file = "LICENSE.md"}
license = {text = "MIT"}
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
Expand All @@ -43,13 +43,13 @@ dependencies = [
"tomlkit",
"scipy",
]
dynamic = ["readme", "version"]
dynamic = ["readme" , "version"]

[project.urls]
homepage = "https://github.com/mcflugen/compaction"
documentation = "https://compaction.readthedocs.io"
repository = "https://github.com/mcflugen/compaction"
changelog = "https://github.com/mcflugen/compaction/blob/develop/CHANGES.rst"
changelog = "https://github.com/mcflugen/compaction/blob/master/NEWS.md"

[project.optional-dependencies]
dev = ["nox"]
Expand All @@ -71,8 +71,11 @@ compaction = "compaction.cli:compaction"
[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.dynamic]
readme = {file = ["README.md", "AUTHORS.md"]}
readme = {file = ["README.md", "AUTHORS.md"], content-type="text/markdown"}
version = {attr = "compaction._version.__version__"}

[tool.pytest.ini_options]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ select = B,C,E,F,W,T4,B9

[zest.releaser]
tag-format = v{version}
python-file-with-version = compaction/_version.py
python-file-with-version = src/compaction/_version.py

[coverage:run]
relative_files = True
2 changes: 1 addition & 1 deletion src/compaction/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "v0.3.0.dev0"
__version__ = "0.2.4.dev0"
4 changes: 2 additions & 2 deletions src/compaction/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import warnings
from functools import partial
from io import StringIO
from typing import Optional, TextIO
from typing import TextIO

import click
import numpy as np # type: ignore
Expand Down Expand Up @@ -88,7 +88,7 @@ def _tomlkit_to_popo(d):
return result


def load_config(stream: Optional[TextIO] = None):
def load_config(stream: TextIO | None = None):
"""Load compaction config file.
Parameters
Expand Down
4 changes: 1 addition & 3 deletions src/compaction/compaction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#! /usr/bin/env python
from typing import Optional

import numpy as np # type: ignore
from scipy.constants import g # type: ignore

Expand All @@ -15,7 +13,7 @@ def compact(
porosity_max: float = 1.0,
rho_void: float = 1000.0,
gravity: float = g,
return_dz: Optional[np.ndarray] = None,
return_dz: np.ndarray | None = None,
) -> np.ndarray:
"""Compact a column of sediment.
Expand Down

0 comments on commit 9197e71

Please sign in to comment.