2Photosynthesis parameter structures and data classes for PyHelios.
4This module provides Python data structures that mirror the C++ parameter
5classes used by the PhotosynthesisModel plugin, with proper defaults and
9from dataclasses
import dataclass, field
10from typing
import List, Optional, Union
14PHOTOSYNTHESIS_SPECIES = [
15 "Almond",
"Apple",
"Cherry",
"Prune",
"Pear",
16 "PistachioFemale",
"PistachioMale",
"Walnut",
18 "Elderberry",
"Toyon",
"Big_Leaf_Maple",
"Western_Redbud",
"Baylaurel",
"Olive",
19 "EasternRedbudSunlit",
"EasternRedbudShaded"
30 "pistachiofemale":
"PistachioFemale",
31 "pistachiomale":
"PistachioMale",
34 "elderberry":
"Elderberry",
36 "big_leaf_maple":
"Big_Leaf_Maple",
37 "western_redbud":
"Western_Redbud",
38 "baylaurel":
"Baylaurel",
40 "easternredbudsunlit":
"EasternRedbudSunlit",
41 "easternredbudshaded":
"EasternRedbudShaded",
44 "bigleafmaple":
"Big_Leaf_Maple",
45 "bigmaple":
"Big_Leaf_Maple",
46 "westernredbud":
"Western_Redbud",
47 "redbud":
"Western_Redbud",
48 "easternredbud":
"EasternRedbudSunlit",
49 "pistachio":
"PistachioFemale",
51 "cabernetSauvignon":
"Grape",
59 Temperature response parameters for photosynthetic processes.
61 These parameters define how photosynthetic rates vary with temperature
62 using the modified Arrhenius equation.
65 value_at_25C: Value of the parameter at 25°C
66 dHa: Activation energy (rate of increase parameter)
67 dHd: Deactivation energy (rate of decrease parameter)
68 Topt: Optimum temperature in Kelvin (10000K means no optimum)
70 value_at_25C: float = 100.0
76 """Validate parameter values after initialization."""
78 raise ValueError(
"value_at_25C must be finite")
79 if not math.isfinite(self.
dHa)
or self.
dHa < 0:
80 raise ValueError(
"dHa must be finite and non-negative")
81 if not math.isfinite(self.
dHd)
or self.
dHd < 0:
82 raise ValueError(
"dHd must be finite and non-negative")
83 if not math.isfinite(self.
Topt)
or self.
Topt < 0:
84 raise ValueError(
"Topt must be finite and non-negative")
90 Empirical photosynthesis model coefficients.
92 This model uses empirical relationships to estimate photosynthetic
93 rates based on environmental conditions.
96 Tref: Reference temperature (K)
97 Ci_ref: Reference CO2 concentration (μmol CO2/mol air)
98 Asat: Light-saturated photosynthetic rate (μmol/m²/s)
99 theta: Half-saturation light level (W/m²)
100 Tmin: Minimum temperature for photosynthesis (K)
101 Topt: Optimum temperature for photosynthesis (K)
102 q: Temperature response parameter (unitless)
103 R: Respiration temperature coefficient (μmol·K^0.5/m²/s)
104 ER: Respiration activation energy (1/K)
105 kC: CO2 response coefficient (unitless)
108 Ci_ref: float = 290.0
119 """Validate parameter values after initialization."""
121 raise ValueError(
"Reference temperature must be positive")
123 raise ValueError(
"Reference CO2 concentration must be positive")
125 raise ValueError(
"Light-saturated photosynthetic rate cannot be negative")
127 raise ValueError(
"Half-saturation light level must be positive")
129 raise ValueError(
"Minimum temperature must be positive")
131 raise ValueError(
"Optimum temperature must be positive")
133 raise ValueError(
"Minimum temperature must be less than optimum temperature")
135 raise ValueError(
"Temperature response parameter must be positive")
137 raise ValueError(
"Respiration coefficient cannot be negative")
139 raise ValueError(
"Respiration activation energy cannot be negative")
141 raise ValueError(
"CO2 response coefficient cannot be negative")
144 """Convert to float array for C++ interface."""
151 def from_array(cls, coefficients: List[float]) ->
'EmpiricalModelCoefficients':
152 """Create from float array (from C++ interface)."""
153 if len(coefficients) < 10:
154 raise ValueError(
"Need at least 10 coefficients for empirical model")
156 Tref=coefficients[0], Ci_ref=coefficients[1], Asat=coefficients[2],
157 theta=coefficients[3], Tmin=coefficients[4], Topt=coefficients[5],
158 q=coefficients[6], R=coefficients[7], ER=coefficients[8], kC=coefficients[9]
165 Farquhar-von Caemmerer-Berry photosynthesis model coefficients.
167 This model provides a mechanistic description of leaf photosynthesis
168 based on biochemical limitations and temperature responses.
170 Core Parameters (at 25°C):
171 Vcmax: Maximum carboxylation rate (μmol/m²/s, -1 = uninitialized)
172 Jmax: Maximum electron transport rate (μmol/m²/s, -1 = uninitialized)
173 alpha: Quantum efficiency of photosystem II (μmol electrons/μmol photons)
174 Rd: Dark respiration rate (μmol/m²/s, -1 = uninitialized)
175 O: Ambient oxygen concentration (mmol/mol)
176 TPU_flag: Enable triose phosphate utilization limitation (0/1)
178 Temperature Response Parameters:
179 c_*: Scaling factor for Arrhenius equation
180 dH_*: Activation energy for temperature response
192 c_Vcmax: float = 26.35
193 c_Jmax: float = 18.86
194 c_Gamma: float = 19.02
200 dH_Vcmax: float = 65.33
201 dH_Jmax: float = 46.36
202 dH_Gamma: float = 37.83
207 _vcmax_temp_response: Optional[PhotosyntheticTemperatureResponseParameters] = field(default=
None, init=
False)
208 _jmax_temp_response: Optional[PhotosyntheticTemperatureResponseParameters] = field(default=
None, init=
False)
209 _rd_temp_response: Optional[PhotosyntheticTemperatureResponseParameters] = field(default=
None, init=
False)
210 _alpha_temp_response: Optional[PhotosyntheticTemperatureResponseParameters] = field(default=
None, init=
False)
211 _theta_temp_response: Optional[PhotosyntheticTemperatureResponseParameters] = field(default=
None, init=
False)
214 """Validate parameter values after initialization."""
216 raise ValueError(
"Oxygen concentration must be positive")
218 raise ValueError(
"TPU_flag must be 0 or 1")
221 for param_name, value
in [
227 if not math.isfinite(value):
228 raise ValueError(f
"Temperature parameter {param_name} must be finite")
230 def setVcmax(self, vcmax_at_25c: float, dha: Optional[float] =
None,
231 topt: Optional[float] =
None, dhd: Optional[float] =
None) ->
None:
232 """Set Vcmax with temperature response (mimics C++ overloads)."""
246 self.
Vcmax = vcmax_at_25c
248 def setJmax(self, jmax_at_25c: float, dha: Optional[float] =
None,
249 topt: Optional[float] =
None, dhd: Optional[float] =
None) ->
None:
250 """Set Jmax with temperature response (mimics C++ overloads)."""
260 self.
Jmax = jmax_at_25c
262 def setRd(self, rd_at_25c: float, dha: Optional[float] =
None,
263 topt: Optional[float] =
None, dhd: Optional[float] =
None) ->
None:
264 """Set dark respiration with temperature response (mimics C++ overloads)."""
277 topt: Optional[float] =
None, dhd: Optional[float] =
None) ->
None:
278 """Set quantum efficiency with temperature response (mimics C++ overloads)."""
288 self.
alpha = alpha_at_25c
291 topt: Optional[float] =
None, dhd: Optional[float] =
None) ->
None:
292 """Set light response curvature with temperature response (mimics C++ overloads)."""
303 """Get Vcmax temperature response parameters."""
309 """Get Jmax temperature response parameters."""
315 """Get dark respiration temperature response parameters."""
321 """Get quantum efficiency temperature response parameters."""
327 """Get light response curvature temperature response parameters."""
333 """Convert to float array for C++ interface."""
343 def from_array(cls, coefficients: List[float]) ->
'FarquharModelCoefficients':
344 """Create from float array (from C++ interface)."""
345 if len(coefficients) < 18:
346 raise ValueError(
"Need at least 18 coefficients for Farquhar model")
349 Vcmax=coefficients[0], Jmax=coefficients[1], alpha=coefficients[2],
350 Rd=coefficients[3], O=coefficients[4], TPU_flag=int(coefficients[5]),
351 c_Vcmax=coefficients[6], dH_Vcmax=coefficients[7],
352 c_Jmax=coefficients[8], dH_Jmax=coefficients[9],
353 c_Rd=coefficients[10], dH_Rd=coefficients[11],
354 c_Kc=coefficients[12], dH_Kc=coefficients[13],
355 c_Ko=coefficients[14], dH_Ko=coefficients[15],
356 c_Gamma=coefficients[16], dH_Gamma=coefficients[17]
362 Validate and normalize species name for photosynthesis library.
365 species: Species name (case insensitive, supports aliases)
368 Normalized species name
371 ValueError: If species is not recognized
374 raise ValueError(
"Species name cannot be empty")
377 if species
in PHOTOSYNTHESIS_SPECIES:
381 species_lower = species.lower()
382 if species_lower
in SPECIES_ALIASES:
383 return SPECIES_ALIASES[species_lower]
386 for known_species
in PHOTOSYNTHESIS_SPECIES:
387 if known_species.lower() == species_lower:
391 available_species = sorted(set(list(PHOTOSYNTHESIS_SPECIES) + list(SPECIES_ALIASES.keys())))
393 f
"Unknown species '{species}'. Available species and aliases:\n"
394 f
" {', '.join(available_species[:8])}\n"
395 f
" {', '.join(available_species[8:16])}\n"
396 f
" {', '.join(available_species[16:])}"
401 """Get list of available species in the photosynthesis library."""
402 return sorted(PHOTOSYNTHESIS_SPECIES.copy())
406 """Get dictionary of species aliases."""
407 return SPECIES_ALIASES.copy()
Empirical photosynthesis model coefficients.
float Topt
Optimum temperature for photosynthesis (K)
float Tmin
Minimum temperature for photosynthesis (K)
float Asat
Light-saturated photosynthetic rate (μmol/m²/s)
__post_init__(self)
Validate parameter values after initialization.
float q
Temperature response parameter (unitless)
'EmpiricalModelCoefficients' from_array(cls, List[float] coefficients)
Create from float array (from C++ interface).
float R
Respiration temperature coefficient (μmol·K^0.5/m²/s)
List[float] to_array(self)
Convert to float array for C++ interface.
float Tref
Reference temperature (K)
float ER
Respiration activation energy (1/K)
float Ci_ref
Reference CO2 concentration (μmol CO2/mol air)
float theta
Half-saturation light level (W/m²)
float kC
CO2 response coefficient (unitless)
Farquhar-von Caemmerer-Berry photosynthesis model coefficients.
List[float] to_array(self)
Convert to float array for C++ interface.
None setVcmax(self, float vcmax_at_25c, Optional[float] dha=None, Optional[float] topt=None, Optional[float] dhd=None)
Set Vcmax with temperature response (mimics C++ overloads).
Optional _theta_temp_response
__post_init__(self)
Validate parameter values after initialization.
PhotosyntheticTemperatureResponseParameters getLightResponseCurvatureTempResponse(self)
Get light response curvature temperature response parameters.
Optional _vcmax_temp_response
None setQuantumEfficiency_alpha(self, float alpha_at_25c, Optional[float] dha=None, Optional[float] topt=None, Optional[float] dhd=None)
Set quantum efficiency with temperature response (mimics C++ overloads).
PhotosyntheticTemperatureResponseParameters getQuantumEfficiencyTempResponse(self)
Get quantum efficiency temperature response parameters.
Optional _rd_temp_response
PhotosyntheticTemperatureResponseParameters getVcmaxTempResponse(self)
Get Vcmax temperature response parameters.
Optional _alpha_temp_response
'FarquharModelCoefficients' from_array(cls, List[float] coefficients)
Create from float array (from C++ interface).
PhotosyntheticTemperatureResponseParameters getRdTempResponse(self)
Get dark respiration temperature response parameters.
Optional _jmax_temp_response
PhotosyntheticTemperatureResponseParameters getJmaxTempResponse(self)
Get Jmax temperature response parameters.
None setLightResponseCurvature_theta(self, float theta_at_25c, Optional[float] dha=None, Optional[float] topt=None, Optional[float] dhd=None)
Set light response curvature with temperature response (mimics C++ overloads).
None setRd(self, float rd_at_25c, Optional[float] dha=None, Optional[float] topt=None, Optional[float] dhd=None)
Set dark respiration with temperature response (mimics C++ overloads).
None setJmax(self, float jmax_at_25c, Optional[float] dha=None, Optional[float] topt=None, Optional[float] dhd=None)
Set Jmax with temperature response (mimics C++ overloads).
Temperature response parameters for photosynthetic processes.
float dHa
Activation energy (rate of increase parameter)
float dHd
Deactivation energy (rate of decrease parameter)
__post_init__(self)
Validate parameter values after initialization.
float value_at_25C
Value of the parameter at 25°C.
float Topt
Optimum temperature in Kelvin (10000K means no optimum)
List[str] get_available_species()
Get list of available species in the photosynthesis library.
str validate_species_name(str species)
Validate and normalize species name for photosynthesis library.
dict get_species_aliases()
Get dictionary of species aliases.