Skip to content

Commit

Permalink
Merge pull request #7 from martinvonk/dev
Browse files Browse the repository at this point in the history
Update main to v0.0.6
  • Loading branch information
martinvonk authored Jan 22, 2024
2 parents 4a1aac7 + 1f0d233 commit c9112f0
Show file tree
Hide file tree
Showing 18 changed files with 1,322 additions and 305 deletions.
169 changes: 169 additions & 0 deletions doc/examples/00_pedon_structure.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"**Package Structure**"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Python Packages"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"import inspect\n",
"import pedon as pe"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Pedon Structure\n",
"\n",
"Pedon knows three classes;\n",
"- Soil\n",
"- SoilModel\n",
"- SoilSample\n",
"\n",
"The Soil class encapsulates the SoilModel and SoilSample class. The soil class has the following attributes:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'name': str,\n",
" 'model': pedon.soilmodel.SoilModel | None,\n",
" 'sample': pedon.soil.SoilSample | None,\n",
" 'source': str | None,\n",
" 'description': str | None}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# main class\n",
"# containing both SoilModel and SoilSample\n",
"pe.Soil.__annotations__"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The name of the soil, the soil type (e.g. sand or clay) are strings. The source is the origin of the soil, and description contains extra information. The SoilModel is the relation between the pressure head, hydraulic conducitivity and water content. Possible SoilModels are:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Brooks',\n",
" 'Fredlund',\n",
" 'Gardner',\n",
" 'Genuchten',\n",
" 'Panday',\n",
" 'Protocol',\n",
" 'SoilModel']"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# classes for soil models\n",
"soilmodels = [\n",
" cls_name\n",
" for cls_name, cls_obj in inspect.getmembers(sys.modules[\"pedon.soilmodel\"])\n",
" if inspect.isclass(cls_obj)\n",
"]\n",
"soilmodels"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The SoilSample atttribute can contain measurements of the sand percentage `sand_p`, silt percentage `silt_p`, bulkd density `rho` or measurements of the pressure head `h` and the resulting hydraulic conductivity `k` or water content `theta`. "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'sand_p': float | None,\n",
" 'silt_p': float | None,\n",
" 'clay_p': float | None,\n",
" 'rho': float | None,\n",
" 'th33': float | None,\n",
" 'th1500': float | None,\n",
" 'om_p': float | None,\n",
" 'm50': float | None,\n",
" 'h': float | numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]] | None,\n",
" 'k': float | numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]] | None,\n",
" 'theta': float | numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]] | None}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# class for sample measurements\n",
"pe.SoilSample.__annotations__"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "pydon",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
161 changes: 161 additions & 0 deletions doc/examples/01_soil_models.ipynb

Large diffs are not rendered by default.

214 changes: 214 additions & 0 deletions doc/examples/02_datasets.ipynb

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions doc/examples/03_pedotransfer_functions.ipynb

Large diffs are not rendered by default.

418 changes: 418 additions & 0 deletions doc/examples/04_curve_fitting.ipynb

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Python package for (unsaturated) soil properties including pedotr
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.10"
dependencies = ["numpy", "matplotlib", "pandas", "scipy", "openpyxl"]
dependencies = ["numpy", "matplotlib", "pandas", "scipy"]
classifiers = [
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.10',
Expand All @@ -33,6 +33,33 @@ pytesting = ["pytest>=7", "pytest-cov", "pytest-sugar"]
coveraging = ["coverage"]
dev = ["pedon[linting,formatting,typing,pytesting]", "tox"]

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

[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

Expand All @@ -43,7 +70,7 @@ version = { attr = "pedon._version.__version__" }
where = ["src"]

[tool.setuptools.package-data]
"pedon.datasets" = ["*.xlsx"]
"pedon.datasets" = ["*.csv"]

[tool.black]
line-length = 88
Expand Down
53 changes: 13 additions & 40 deletions src/pedon/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,19 @@
"theta_s": 0.2,
"alpha": 0.001,
"n": 1.000001,
"l": -7,
"l": -7.0,
},
"p_max": {
"k_s": 100000.0,
"theta_r": 0.2,
"theta_s": 0.9,
"alpha": 0.20,
"n": 12,
"l": 8,
},
"swrc": {
"k_s": False,
"theta_r": True,
"theta_s": True,
"alpha": True,
"n": True,
"l": False,
"n": 12.0,
"l": 8.0,
},
},
dtype=float,
)
pGenuchten.loc[:, ["p_ini", "p_min", "p_max"]] = pGenuchten.loc[
:, ["p_ini", "p_min", "p_max"]
].astype(float)
pGenuchten.loc[:, "swrc"] = pGenuchten.loc[:, "swrc"].astype(bool)

pBrooks = DataFrame(
data={
Expand All @@ -51,21 +40,16 @@
"h_b": 0.0001,
"l": 0.1,
},
"p_max": {"k_s": 100000.0, "theta_r": 0.2, "theta_s": 0.5, "h_b": 100, "l": 5},
"swrc": {
"k_s": False,
"theta_r": True,
"theta_s": True,
"h_b": True,
"l": True,
"p_max": {
"k_s": 100000.0,
"theta_r": 0.2,
"theta_s": 0.5,
"h_b": 100.0,
"l": 5.0,
},
},
dtype=float,
)
pBrooks.loc[:, ["p_ini", "p_min", "p_max"]] = pBrooks.loc[
:, ["p_ini", "p_min", "p_max"]
].astype(float)
pBrooks.loc[:, "swrc"] = pBrooks.loc[:, "swrc"].astype(bool)

pPanday = DataFrame(
data={
"p_ini": {
Expand All @@ -89,23 +73,12 @@
"theta_r": 0.2,
"theta_s": 0.5,
"alpha": 0.30,
"beta": 12,
"beta": 12.0,
"brook": 50.0,
},
"swrc": {
"k_s": False,
"theta_r": True,
"theta_s": True,
"alpha": True,
"beta": True,
"brook": False,
},
},
dtype=float,
)
pPanday.loc[:, ["p_ini", "p_min", "p_max"]] = pPanday.loc[
:, ["p_ini", "p_min", "p_max"]
].astype(float)
pPanday.loc[:, "swrc"] = pPanday.loc[:, "swrc"].astype(bool)


def get_params(sm_name: str) -> DataFrame:
Expand Down
12 changes: 0 additions & 12 deletions src/pedon/datasets/Brooks.csv

This file was deleted.

63 changes: 0 additions & 63 deletions src/pedon/datasets/Genuchten.csv

This file was deleted.

Binary file removed src/pedon/datasets/Soil_Parameters.xlsx
Binary file not shown.
Binary file removed src/pedon/datasets/Staring_2001.xlsx
Binary file not shown.
Binary file removed src/pedon/datasets/Staring_2018.xlsx
Binary file not shown.
Loading

0 comments on commit c9112f0

Please sign in to comment.