Skip to main content

Python version of The Rothamsted carbon model (RothC) 26.3. RothC is a model for the turnover of organic carbon in non-waterlogged topsoil that allows for the effects of soil type, temperature, soil moisture and plant cover on the turnover process.

Project description

pyRothC

GitHub Repo stars Issues License

Python version of The Rothamsted carbon model (RothC) 26.3.


Documentation: Rothamsted RothC Model

Source Code: https://github.com/mishagrol/pyRothC


pyRothc is a Python version of The Rothamsted carbon model (RothC) 26.3.

RothC is a model for the turnover of organic carbon in non-waterlogged topsoil that allows for the effects of soil type, temperature, soil moisture and plant cover on the turnover process.

Inspired by SoilR version SoilR RothC

Requirements

Python 3.7+

SciPy

NumPy

Pandas

Installation

$ pip install pyRothC

Example

Below is an example of how the RothC class should be used. It needs matplotlib library to be installed in order to draw the graphs.

import numpy as np
import matplotlib.pyplot as plt

from pyRothC.RothC import RothC


Temp=np.array([-0.4, 0.3, 4.2, 8.3, 13.0, 15.9,18.0, 
                17.5, 13.4, 8.7, 3.9,  0.6])
Precip=np.array([49, 39, 44, 41, 61, 58,
                71, 58, 51,48, 50, 58])
Evp=np.array([12, 18, 35, 58, 82, 90,
            97, 84, 54, 31,14, 10])

soil_thick=25  #Soil thickness (organic layer topsoil), in cm
SOC=69.7       #Soil organic carbon in Mg/ha 
clay=48        #Percent clay
input_carbon=2.7   #Annual C inputs to soil in Mg/ha/yr

IOM=0.049*SOC**(1.139) # Falloon et al. (1998)

rothC = RothC(temperature=Temp, 
             precip=Precip, 
             evaporation=Evp,
             clay = 48,
             input_carbon=input_carbon,
             pE=1.0,
             C0=np.array([0, 0, 0, 0, IOM]))

df = rothC.compute()
df.index = rothC.t
fig, ax = plt.subplots(1,1,figsize=(6,4))
df.plot(ax=ax)
ax.set_ylabel('C stocks (Mg/ha)')
ax.set_ylabel('Years')
plt.show()

Testing

If you need to run the test suite, first install the package in "editable" mode with the test optional dependencies:

git clone git@github.com:mishagrol/pyRothC.git
cd pyRothC
pip install -e ".[test]"

Now you can run the tests by simply running this command:

pytest tests

Structure of the RothC model

Credits: Theoretical Ecosystem Ecology group of the Max Planck Institute for Biogeochemistry

RothC

Equations

$$ \begin{aligned} & \frac{d \boldsymbol{C}}{\mathrm{d} t}=I\left(\begin{array}{c} \gamma \ 1-\gamma \ 0 \ 0 \ 0 \end{array}\right) +\left(\begin{array}{ccccc} -k_1 & 0 & 0 & 0 & 0 \ 0 & -k_2 & 0 & 0 & 0 \ a_{3,1} & a_{3,2} & -k_3+a_{3,3} & a_{3,4} & 0 \ a_{4,1} & a_{4,2} & a_{4,3} & -k_4+a_{4,4} & 0 \ 0 & 0 & 0 & 0 & 0 \end{array}\right)\left(\begin{array}{l} C_1 \ C_2 \ C_3 \ C_4 \ C_5 \end{array}\right) \ & \end{aligned} $$

Optional Dependencies

Matplotlib

License

This project is licensed under the terms of the CC0 1.0 Universal license.

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

pyRothC-0.0.3.tar.gz (179.4 kB view details)

Uploaded Source

Built Distributions

pyrothc-0.0.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

pyRothC-0.0.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file pyRothC-0.0.3.tar.gz.

File metadata

  • Download URL: pyRothC-0.0.3.tar.gz
  • Upload date:
  • Size: 179.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.9

File hashes

Hashes for pyRothC-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b59b1ffa4e52fd7a9f7834277515b509114e0f6a0bca51022d66c199b6d0f69c
MD5 8d070fe6bf8216e695a19ac8511da6ef
BLAKE2b-256 b5c968438400317a19bd07ec5845ae6ffa62c73a9d737a8cfdd7a51ff9ecda61

See more details on using hashes here.

Provenance

File details

Details for the file pyrothc-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyrothc-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.9

File hashes

Hashes for pyrothc-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 88ff08b785d580bd3c2e5c3a87dbfb4e467ef3dadc0ff1a4279cb254d5c460fd
MD5 c16ee97279c7f03bcab9d6f0b579fe28
BLAKE2b-256 84996fdf8e8d97ee93f90ec1a390d775e2b100997f78ccbf8a232b340eaaac3c

See more details on using hashes here.

Provenance

File details

Details for the file pyRothC-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pyRothC-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.9

File hashes

Hashes for pyRothC-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae7c6c692f2ccdb8f50b96dbfe6346e8506880849936904092c02fc240826225
MD5 f8c04978b0b1b8821d5411b5b589b44e
BLAKE2b-256 2462fd47b5da082963028f8edd6c7a8a9ef80de6840a5dc14e952dc2ea26c349

See more details on using hashes here.

Provenance

Supported by

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