Skip to main content

PhyTorch is a PyTorch-based modeling toolkit for fitting common plant physiological models of photosynthesis, stomatal conductance, leaf hydraulics, and optical properties.

Project description

PhyTorch

A Comprehensive Physiological Plant Modeling Toolkit

License: GPL v3 Python PyTorch

PhyTorch is a PyTorch-based package for modeling plant physiological processes. It provides efficient, GPU-accelerated implementations of models for photosynthesis, stomatal conductance, leaf hydraulics, and optical properties.

Features

  • Photosynthesis Models: FvCB (Farquhar-von Caemmerer-Berry) model with flexible temperature and light response functions
  • Stomatal Conductance: Multiple empirical and semi-empirical models (Medlyn, Ball-Woodrow-Berry, Buckley-Mott-Farquhar)
  • Leaf Optical Properties: PROSPECT model for leaf spectral reflectance and transmittance
  • Leaf Hydraulics: Coming soon - Models for leaf water transport and hydraulic conductance
  • GPU Acceleration: Leverage PyTorch for fast parameter optimization on CPU or GPU
  • Automatic Differentiation: Efficient gradient-based optimization for model fitting

Installation

From PyPI (recommended)

pip install phytorch

From source

git clone https://github.com/PlantSimulationLab/phytorch.git
cd phytorch
pip install -e .

Quick Start

Photosynthesis (FvCB Model)

from phytorch import photosynthesis as fvcb
import pandas as pd

# Load your A-Ci curve data
df = pd.read_csv('your_aci_data.csv')
lcd = fvcb.initLicordata(df, preprocess=True)

# Initialize and fit the FvCB model
model = fvcb.model(lcd, LightResp_type=2, TempResp_type=2)
result = fvcb.fit(model, learn_rate=0.08, maxiteration=20000)

# View fitted parameters
print(f"Vcmax25 = {result.params['Vcmax25']:.2f} μmol/m²/s")
print(f"Jmax25 = {result.params['Jmax25']:.2f} μmol/m²/s")

Stomatal Conductance

from phytorch import stomatalconductance as stomatal
import pandas as pd

# Load stomatal conductance data
df = pd.read_csv('your_gs_data.csv')
scd = stomatal.initscdata(df, preprocess=True)

# Fit Medlyn model
model = stomatal.model(scd, model_type='MED')
result = stomatal.fit(model, learn_rate=0.01, maxiteration=10000)

# View fitted parameters
print(f"g0 = {result.params['g0']:.4f} mol/m²/s")
print(f"g1 = {result.params['g1']:.2f}")

Package Structure

phytorch/
├── photosynthesis/      # FvCB photosynthesis models
├── stomatalconductance/ # Stomatal conductance models
├── leafoptics/          # PROSPECT leaf optical properties
├── leafhydraulics/      # Leaf hydraulics (under development)
├── data/                # Example datasets
└── util.py              # Utility functions

Documentation

Full documentation is available at https://phytorch.org

Citation

If you use PhyTorch in your research, please cite:

Lei, T., Rizzo, K. T., & Bailey, B. N. (2025). PhoTorch: A robust and generalized
biochemical photosynthesis model fitting package. (In preparation)

Credits

PhyTorch is an extension and reorganization of PhoTorch, developed by:

  • Tong Lei
  • Kyle T. Rizzo
  • Brian N. Bailey

License

PhyTorch is licensed under the GNU General Public License v3.0. See LICENSE for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Contact

For questions or issues, please open an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phytorch_lib-0.1.1.tar.gz (319.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phytorch_lib-0.1.1-py3-none-any.whl (323.2 kB view details)

Uploaded Python 3

File details

Details for the file phytorch_lib-0.1.1.tar.gz.

File metadata

  • Download URL: phytorch_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 319.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for phytorch_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b611166637007951fde89f0016a8230b52e1e1f2a4104ed8c1b1bfb40d561fde
MD5 3ac95188dfd2886d1ecefb269d9f62cb
BLAKE2b-256 a6a829c952c54ad773f084f8e1ce26cf4284f30f3b53cbb83625762511acc5cc

See more details on using hashes here.

File details

Details for the file phytorch_lib-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: phytorch_lib-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 323.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for phytorch_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 61811824035d9a06a9eb20c786b75afb0b8ab9352e9cc561073fdb9e473dd059
MD5 b0f3737a035d4d89356969250bc35277
BLAKE2b-256 fde47de7c5801d856ef2c49501eb88bd062eb9b49e5013df82f5c65c2bf57991

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page