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

Update to full poetry and add rosetta support #8

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
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
36 changes: 24 additions & 12 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# https://github.com/pypa/gh-action-pypi-publish
# https://github.com/py-why/dowhy/blob/main/.github/workflows/python-publish.yml

name: Upload Python Package

on:
release:
types: [created]
workflow_dispatch:

jobs:
deploy:
name: Upload release to PyPI
runs-on: ubuntu-latest

permissions:
id-token: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install Poetry
uses: abatilo/[email protected]

- name: Install Poetry Dynamic Versioning Plugin
run: pip install poetry-dynamic-versioning

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine build
run: poetry install

- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python3 -m build
python3 -m twine upload --repository pypi dist/*
poetry-dynamic-versioning
poetry build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
139 changes: 75 additions & 64 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,77 +1,83 @@
[build-system]
requires = ["setuptools>=64"]
build-backend = "setuptools.build_meta"
[tool.poetry]

[project]
name = "pedon"
dynamic = ["version"]
authors = [{ name = "Martin Vonk", email = "[email protected]" }]
version = "0.0.7"
description = "Python package for (unsaturated) soil properties including pedotransfer functions"
authors = ["martinvonk <[email protected]>"]
license = "MIT"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.10"
dependencies = ["numpy", "matplotlib", "pandas", "scipy"]
homepage = "https://pypi.org/project/pedon/"
repository = "https://github.com/martinvonk/pedon"
classifiers = [
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering :: Hydrology',
'Intended Audience :: Science/Research',
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering :: Hydrology',
'Intended Audience :: Science/Research',
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
include = [
{ path = "pedon/datasets/soilsamples.csv", format = [
"sdist",
"wheel",
] },
]

[project.urls]
homepage = "https://github.com/martinvonk/pedon"
repository = "https://github.com/martinvonk/pedon"
[tool.poetry.dependencies]
python = ">=3.10"
numpy = "*"
pandas = "*"
matplotlib = "*"
scipy = "*"
requests = "^2.32.2"

[project.optional-dependencies]
linting = ["flake8", "ruff"]
formatting = ["black[jupyter]", "isort"]
typing = ["mypy", "pandas-stubs"]
pytesting = ["pytest>=7", "pytest-cov", "pytest-sugar"]
coveraging = ["coverage"]
dev = ["pedon[linting,formatting,typing,pytesting]", "tox"]
[tool.poetry.group.dev.dependencies]
tox = "^4.15.0"
ipykernel = "^6.29.4"

[tool.poetry]
name = "pedonenv"
version = "0.0.0"
description = "Development Virtual Environment"
authors = ["poetry"]
[tool.poetry.group.linting]
optional = true

[tool.poetry.dependencies]
python = "^3.10"
numpy = "^1.3"
scipy = "^1.6"
pandas = "^2.0"
matplotlib = "^3.6"
openpyxl = "^3.0"
flake8 = "^6.1.0"
ruff = "^0.1.9"
black = { extras = ["jupyter"], version = "^23.12.1" }
isort = "^5.13.2"
mypy = "^1.8.0"
pandas-stubs = "^2.1.4.231218"
pytest = "^7.4.3"
pytest-cov = "^4.1.0"
pytest-sugar = "^0.9.7"
coverage = "^7.3.4"
tox = "^4.11.4"
setuptools = "^69.0.3"
ipykernel = "^6.28.0"

[tool.setuptools]
include-package-data = true

[tool.setuptools.dynamic]
version = { attr = "pedon._version.__version__" }

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

[tool.setuptools.package-data]
"pedon.datasets" = ["*.csv"]
[tool.poetry.group.linting.dependencies]
flake8 = "*"
ruff = "*"

[tool.poetry.group.formatting]
optional = true

[tool.poetry.group.formatting.dependencies]
black = { extras = ["jupyter"], version = "*" }
isort = "*"

[tool.poetry.group.typing]
optional = true

[tool.poetry.group.typing.dependencies]
mypy = "*"
pandas-stubs = "*"

[tool.poetry.group.pytesting]
optional = true

[tool.poetry.group.pytesting.dependencies]
pytest = ">=7"
pytest-cov = "*"
pytest-sugar = "*"

[tool.poetry.group.coveraging]
optional = true

[tool.poetry.group.coveraging.dependencies]
coverage = "*"

[tool.poetry-dynamic-versioning]
enable = true

[tool.poetry-dynamic-versioning.from-file]
source = "src/pedon/_version.py"
pattern = '__version__ = "(\d(\.\d)+)"'

[tool.black]
line-length = 88
Expand Down Expand Up @@ -129,3 +135,8 @@ legacy_tox_ini = """
ruff check src

"""


[build-system]
requires = ["poetry-core", "poetry-dynamic-versioning>=1.3.0"]
build-backend = "poetry.core.masonry.api"
25 changes: 25 additions & 0 deletions src/pedon/soil.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,31 @@ def cosby(self) -> Brooks:
l=round(labda, 5),
)

def rosetta(self, rosetta_version: int = 3) -> Genuchten:
"""Rosetta (Schaap et al., 2001) - Predicting soil water retention from soil"""

soildata = [
self.sand_p,
self.silt_p,
self.clay_p,
-9.9 if self.rho is None else self.rho,
-9.9 if self.th33 is None else self.th33,
-9.9 if self.th1500 is None else self.th1500,
]

data = {"soildata": [soildata]}
rjson = requests.post(
f"http://www.handbook60.org/api/v1/rosetta/{rosetta_version}", json=data
)
vgpar = rjson["van_genuchten_params"][0]
return Genuchten(
k_s=10 ** vgpar[4],
theta_r=vgpar[0],
theta_s=vgpar[1],
alpha=10 ** vgpar[2],
n=10 ** vgpar1[3],
)


@dataclass
class Soil:
Expand Down
Loading