phytkit 0.1.0__cp39-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- phytkit/__init__.py +85 -0
- phytkit/__main__.py +19 -0
- phytkit/_phytkit.pyd +0 -0
- phytkit-0.1.0.dist-info/METADATA +57 -0
- phytkit-0.1.0.dist-info/RECORD +9 -0
- phytkit-0.1.0.dist-info/WHEEL +4 -0
- phytkit-0.1.0.dist-info/entry_points.txt +2 -0
- phytkit-0.1.0.dist-info/licenses/LICENSE +21 -0
- phytkit-0.1.0.dist-info/sboms/phytkit-py.cyclonedx.json +2361 -0
phytkit/__init__.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""phytkit: plant physiology model fitting.
|
|
2
|
+
|
|
3
|
+
The commands run the same Rust code as the `pk` command line and return the same
|
|
4
|
+
structure as its JSON output, as dicts::
|
|
5
|
+
|
|
6
|
+
import phytkit as pk
|
|
7
|
+
fit = pk.fit("photosynthesis", "leaf1.csv", model="fvcb")
|
|
8
|
+
fit["params"]["Vcmax25"]
|
|
9
|
+
|
|
10
|
+
For data already in memory, use `fit_arrays`, `fit_many` (parallel) and `predict`.
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import os
|
|
15
|
+
from typing import Any, Iterable, Mapping
|
|
16
|
+
|
|
17
|
+
from ._phytkit import PhytKitError, __version__, fit_arrays, fit_many, models, predict, run
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"PhytKitError", "__version__", "concat", "describe", "fit", "fit_arrays", "fit_many",
|
|
21
|
+
"li600_correct", "li600_estimate", "models", "predict", "run",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _flags(options: Mapping[str, Any]) -> list[str]:
|
|
26
|
+
"""Keyword arguments to `pk` flags: max_iter=400 -> --max-iter 400, fix=["gm"] -> --fix gm,
|
|
27
|
+
set={"gm": 1e6} -> --set gm=1000000, predicted=True -> --predicted. None is skipped."""
|
|
28
|
+
out: list[str] = []
|
|
29
|
+
for key, value in options.items():
|
|
30
|
+
if value is None or value is False:
|
|
31
|
+
continue
|
|
32
|
+
flag = "--" + key.rstrip("_").replace("_", "-")
|
|
33
|
+
if value is True:
|
|
34
|
+
out.append(flag)
|
|
35
|
+
elif isinstance(value, Mapping):
|
|
36
|
+
for k, v in value.items():
|
|
37
|
+
out += [flag, f"{k}={v!r}" if isinstance(v, float) else f"{k}={v}"]
|
|
38
|
+
elif isinstance(value, (list, tuple)):
|
|
39
|
+
# Repeatable flags (--survey, --no-constraint) take one value each.
|
|
40
|
+
for v in value:
|
|
41
|
+
out += [flag, os.fspath(v) if isinstance(v, os.PathLike) else str(v)]
|
|
42
|
+
else:
|
|
43
|
+
out += [flag, os.fspath(value) if isinstance(value, os.PathLike) else str(value)]
|
|
44
|
+
return out
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _paths(files: Iterable[str | os.PathLike]) -> list[str]:
|
|
48
|
+
return [os.fspath(f) for f in files]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def describe(model: str | None = None) -> dict:
|
|
52
|
+
"""Tools, models, parameters and constraints; or one model's details."""
|
|
53
|
+
return run(["describe"] + ([model] if model else []))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def fit(tool: str, *files: str | os.PathLike, **options: Any) -> dict | str:
|
|
57
|
+
"""Fit a tool's model to one or more files (`pk fit`).
|
|
58
|
+
|
|
59
|
+
tool: "photosynthesis", "stomatal", "hydraulics" or "soil".
|
|
60
|
+
options: model, fit=[...], fix=[...], set={...}, no_constraint=[...], constraints="none",
|
|
61
|
+
weight={...}, units, max_iter, group_by, survey=[...], stat, ref_ci, predicted, format.
|
|
62
|
+
One file returns that fit; several (or group_by) return a batch summary.
|
|
63
|
+
"""
|
|
64
|
+
for name in ("fit", "fix"):
|
|
65
|
+
if isinstance(options.get(name), (list, tuple)):
|
|
66
|
+
options[name] = ",".join(options[name])
|
|
67
|
+
return run(["fit", tool, *_paths(files), *_flags(options)])
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def li600_correct(file: str | os.PathLike, **options: Any) -> dict | str:
|
|
71
|
+
"""LI-600 energy-balance gsw correction (`pk li600 correct`).
|
|
72
|
+
options: sidedness, thermal_conductance, rows, out, format."""
|
|
73
|
+
return run(["li600", "correct", os.fspath(file), *_flags(options)])
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def li600_estimate(file: str | os.PathLike, **options: Any) -> dict | str:
|
|
77
|
+
"""A, Ci and Cc from LI-600 gsw and photosynthesis parameters (`pk li600 estimate`).
|
|
78
|
+
options: model, params (a file), set={...}, ca, absorptance, min_gsw, rows, out, format."""
|
|
79
|
+
return run(["li600", "estimate", os.fspath(file), *_flags(options)])
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def concat(*files: str | os.PathLike, **options: Any) -> dict | str:
|
|
83
|
+
"""Merge LI-6800 logs or CSVs under one header with a CurveID per file (`pk concat`).
|
|
84
|
+
options: out, format. Returns the merged CSV text unless out or format="json" is given."""
|
|
85
|
+
return run(["concat", *_paths(files), *_flags(options)])
|
phytkit/__main__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""`pk` from the Python package: the same command line, output and exit codes as the `pk` binary."""
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from ._phytkit import main as _main
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main() -> int:
|
|
8
|
+
text, code = _main(sys.argv[1:])
|
|
9
|
+
# Write UTF-8 bytes, like the binary. sys.stdout.write would encode with the console's
|
|
10
|
+
# code page on Windows (cp1252), which can't encode the Greek letters and dashes in
|
|
11
|
+
# `pk describe` and --help, and would also turn \n into \r\n.
|
|
12
|
+
sys.stdout.flush()
|
|
13
|
+
sys.stdout.buffer.write(text.encode("utf-8"))
|
|
14
|
+
sys.stdout.buffer.flush()
|
|
15
|
+
return code
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if __name__ == "__main__":
|
|
19
|
+
sys.exit(main())
|
phytkit/_phytkit.pyd
ADDED
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phytkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Intended Audience :: Science/Research
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Classifier: Programming Language :: Rust
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Summary: Plant physiology model fitting: photosynthesis, stomatal conductance, hydraulics and soil water retention.
|
|
13
|
+
Keywords: plant physiology,photosynthesis,FvCB,stomatal conductance,curve fitting,LI-6800,LI-600
|
|
14
|
+
Author: PlantSimulationLab
|
|
15
|
+
License: MIT
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
18
|
+
Project-URL: Documentation, https://plantsimulationlab.github.io/PhytKit/
|
|
19
|
+
Project-URL: Issues, https://github.com/PlantSimulationLab/PhytKit/issues
|
|
20
|
+
Project-URL: Source, https://github.com/PlantSimulationLab/PhytKit
|
|
21
|
+
|
|
22
|
+
# PhytKit
|
|
23
|
+
|
|
24
|
+
Plant physiology model fitting, written in Rust: photosynthesis (FvCB C3 and C4, empirical light
|
|
25
|
+
response), stomatal conductance (BTA, Medlyn), xylem vulnerability, pressure–volume curves, soil
|
|
26
|
+
water retention, and LI-600 porometer tools.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install phytkit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This installs the `phytkit` Python package and the `pk` command-line tool. Both return the same
|
|
33
|
+
JSON.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pk describe fvcb
|
|
37
|
+
pk fit photosynthesis leaf.csv --model fvcb
|
|
38
|
+
pk fit soil soil.csv --group-by sample --units kPa
|
|
39
|
+
pk li600 correct porometer.csv --sidedness 1.5
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
import phytkit as pk
|
|
44
|
+
|
|
45
|
+
pk.fit("photosynthesis", "leaf.csv", model="fvcb", fix=["gm"], max_iter=400) # same as `pk fit`
|
|
46
|
+
pk.fit_arrays("fvcb", {"Ci": ci, "Q": q, "T": t_kelvin}, a) # data in memory
|
|
47
|
+
pk.fit_many("fvcb", [(x1, y1), (x2, y2)], threads=8) # parallel batch
|
|
48
|
+
pk.predict("fvcb", {"Vcmax25": 90}, {"Ci": ci, "Q": q, "T": t_kelvin})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Failures raise `phytkit.PhytKitError`, with a stable `.code` and a `.hint`.
|
|
52
|
+
|
|
53
|
+
- Documentation: <https://plantsimulationlab.github.io/PhytKit/>
|
|
54
|
+
- Source and issues: <https://github.com/PlantSimulationLab/PhytKit>
|
|
55
|
+
|
|
56
|
+
MIT licensed.
|
|
57
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
phytkit/__init__.py,sha256=qfx3KFu2zJCxyAZsiuFa1277x-NdwR0eYCAwARQ9Z8I,3721
|
|
2
|
+
phytkit/__main__.py,sha256=ByqgBIYlUBidd858qbZ3FdCtgAFao_-RDtGv6N5vp8k,640
|
|
3
|
+
phytkit/_phytkit.pyd,sha256=P2DvgNLnRDoinYCEJaFsQKJPyeDv955mjAqkVlgD7jo,2048000
|
|
4
|
+
phytkit-0.1.0.dist-info/METADATA,sha256=PDJWyTHOJEwSjyIUbBdtecxNplVgy6hyp-Lb-APc75A,2193
|
|
5
|
+
phytkit-0.1.0.dist-info/WHEEL,sha256=xw8F9xBWUOgm5ym2S9tihj_bLJOb723bjhA0kdANo2I,95
|
|
6
|
+
phytkit-0.1.0.dist-info/entry_points.txt,sha256=DYHtvvfPyC_A-USKgQfmEtX-Wj5rvtt-7wE1a-Kw2hU,43
|
|
7
|
+
phytkit-0.1.0.dist-info/licenses/LICENSE,sha256=xVDAVzdPRTqQ4_zcI0pQxM3YFhX7GXg6w80z3Ehu-P8,1096
|
|
8
|
+
phytkit-0.1.0.dist-info/sboms/phytkit-py.cyclonedx.json,sha256=V9TR6RVi98jzH2xhE-jmdRjW1On34vW90HUOCyKH2_M,72574
|
|
9
|
+
phytkit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PlantSimulationLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|