Skip to content

Your first fit

This page fits the sample A–Ci curves that come with PhytKit, then walks through the result. Run the commands from the rust folder.

The data

examples/aci.csv holds six synthetic A–Ci curves, at two light levels and three leaf temperatures:

A,Ci,Qabs,Tleaf,CurveID
-0.0429,58.72,1500.0,20.0,1
2.9734,97.72,1500.0,20.0,1
...

PhytKit needs four columns for photosynthesis: A, Ci, light (Qabs, or Q) and leaf temperature (Tleaf, or T). Other columns are kept but ignored. A CurveID column tells PhytKit which rows belong to the same curve. See Input files for the full rules.

Fit

pk fit photosynthesis examples/aci.csv --model fvcb --set gm=1000000 --fix gm,alphaG

This fits the Farquhar–von Caemmerer–Berry C3 model. The two options:

  • --set gm=1000000 starts mesophyll conductance at a very large value.
  • --fix gm,alphaG holds it there, together with alphaG.

The result is an apparent fit, where the chloroplast CO₂ is taken to equal Ci. That's the common choice when you have no independent estimate of gm. See Photosynthesis models.

Read the result

pk prints one JSON object. The important parts:

{
  "ok": true,
  "command": "fit",
  "file": "aci.csv",
  "tool": "photosynthesis",
  "model": "fvcb",
  "n": 66,
  "mapping": { "A": "A", "Ci": "Ci", "Q": "Qabs", "T": "Tleaf" },
  "r2": 0.97194,
  "rmse": 2.186425,
  "iterations": 45,
  "converged": true,
  "fitted": ["Vcmax25", "Jmax25", "TPU25", "Rd25", "alpha", "theta", "..."],
  "params": { "Vcmax25": 97.804869, "Jmax25": 196.368808, "...": "..." },
  "warnings": [
    "Using A=\"A\", Ci=\"Ci\", light=\"Qabs\", T=\"Tleaf\".",
    "Treated \"Tleaf\" as °C and converted 66 value(s) to Kelvin.",
    "Per-curve constraints: 6 curve(s) via \"CurveID\"."
  ]
}
Field Meaning
n Number of rows fitted, after dropping incomplete ones
mapping Which file column was used for each input
r2, rmse Fit quality, on the measured A only
iterations, converged How the fitter finished; see How fitting works
fitted The parameters that were optimized
params Every parameter value, fitted or fixed
warnings What PhytKit assumed or changed. Read these.

The warnings here confirm that PhytKit:

  • used the columns you expected,
  • read Tleaf as °C and converted it to Kelvin, and
  • found 6 curves through CurveID.

The full list of output fields is in Output.

Get a table instead

--format csv prints one row per fit, which is handy for a spreadsheet:

pk fit photosynthesis examples/aci.csv --model fvcb --set gm=1000000 --fix gm,alphaG --format csv

Next steps