### Install photosynthesis from GitHub Source: https://github.com/cdmuir/photosynthesis/blob/main/README.md Use this command to install the latest version of the photosynthesis package directly from GitHub using the remotes package. ```r install.packages("remotes") remotes::install_github("cdmuir/photosynthesis") ``` -------------------------------- ### Example: Fitting and Compiling Data Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/compile_data.html This example demonstrates how to read data, fit multiple curves using fit_many, and then compile the resulting graphs using compile_data for subsequent plotting. It requires data to be loaded and processed into a suitable format for fitting functions. ```R # Read in your data # Note that this data is coming from data supplied by the package # hence the complicated argument in read.csv() # This dataset is a CO2 by light response curve for a single sunflower data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) # Define a grouping factor based on light intensity to split the ACi # curves data$Q_2 <- as.factor((round(data$Qin, digits = 0))) # Convert leaf temperature to K data$T_leaf <- data$Tleaf + 273.15 # Fit many curves fits <- fit_many( data = data, varnames = list( A_net = "A", T_leaf = "T_leaf", C_i = "Ci", PPFD = "Qin" ), funct = fit_aci_response, group = "Q_2" ) #> Warning: `fit_many()` was deprecated in photosynthesis 2.1.3. | | | 0% | |========= | 12% | |================== | 25% | |========================== | 38% | |=================================== | 50% | |============================================ | 62% | |==================================================== | 75% | |============================================================= | 88% | |======================================================================| 100% # Compile graphs into a list for plotting fits_graphs <- compile_data(fits, list_element = 2 ) # Plot one graph from the compiled list plot(fits_graphs[[1]]) #> Warning: Removed 12 rows containing missing values or values outside the scale range #> (`geom_line()`). ``` -------------------------------- ### Example: Running and Graphing a 2-Parameter Sensitivity Analysis Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/analyze_sensitivity.html This example demonstrates how to use analyze_sensitivity to explore the relationship between gamma_star25, g_mc25, and V_cmax. It involves reading data, preparing it, running the sensitivity analysis, and then visualizing the results using ggplot2. ```R # Read in your data # Note that this data is coming from data supplied by the package # hence the complicated argument in read.csv() # This dataset is a CO2 by light response curve for a single sunflower data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) # Define a grouping factor based on light intensity to split the ACi # curves data$Q_2 <- as.factor((round(data$Qin, digits = 0))) # Convert leaf temperature to K data$T_leaf <- data$Tleaf + 273.15 # Run a sensitivity analysis on gamma_star and mesophyll conductance # at 25 Celsius for one individual curve # pars <- analyze_sensitivity( # data = data[data$Q_2 == 1500, ], # funct = fit_aci_response, # varnames = list( # A_net = "A", # T_leaf = "T_leaf", # C_i = "Ci", # PPFD = "Qin" # ), # useg_mct = TRUE, # test1 = "gamma_star25", # element_out = 1, # test2 = "g_mc25", # fitTPU = TRUE, # Ea_gamma_star = 0, # Ea_g_mc = 0, # values1 = seq( # from = 20, # to = 40, # by = 2 # ), # values2 = seq( # from = 0.5, # to = 2, # by = 0.1 # ) # ) # Graph V_cmax # ggplot(pars, aes(x = gamma_star25, y = g_mc25, z = V_cmax)) + # geom_tile(aes(fill = V_cmax)) + # labs( # x = expression(Gamma * "*"[25] ~ "(" * mu * mol ~ mol^ # { # -1 # } * ")"), # y = expression(g[m][25] ~ "(" * mu * mol ~ m^{ # -2 # } ~ s^{ # -1 # } ~ Pa^ # { # -1 # } * ")") # ) + # scale_fill_distiller(palette = "Greys") + # geom_contour(colour = "Black", size = 1) + # theme_bw() # # } ``` -------------------------------- ### Typical Hypostomatous Leaf Model Setup Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/articles/modeling-recommendations.html Configures parameters for a typical hypostomatous leaf model, setting cuticular conductance to zero and all stomatal and mesophyll conductance to the lower surface. Use this for simplified models where stomata are only on one leaf surface. ```R library(photosynthesis) bake_par = make_bakepar() # temperature response parameters constants = make_constants(use_tealeaves = FALSE) # physical constants # leaf parameters leaf_par = make_leafpar( replace = list( # Set cuticular conductance to 0 g_uc = set_units(0, mol / m^2 / s), # All conductance through lower stomata and mesophyll k_mc = set_units(0, 1), k_sc = set_units(0, 1) ), use_tealeaves = FALSE ) enviro_par = make_enviropar(use_tealeaves = FALSE) # environmental parameters photo(leaf_par, enviro_par, bake_par, constants, use_tealeaves = FALSE) | dplyr::select(g_sc, A) | knitr::kable(caption = "Stomatal conductance to CO2 (g_sc) and net photosynthetic carbon assimilation (A) from C3 photosynthesis model.") ``` -------------------------------- ### FvCB Function Example Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/FvCB.html Demonstrates how to set up parameters and use the FvCB function for calculating photosynthetic CO2 assimilation. Ensure all necessary parameter objects are created and baked before calling FvCB. ```R bake_par = make_bakepar() constants = make_constants(use_tealeaves = FALSE) enviro_par = make_enviropar(use_tealeaves = FALSE) leaf_par = make_leafpar(use_tealeaves = FALSE) leaf_par = bake(leaf_par, enviro_par, bake_par, constants) pars = c(leaf_par, enviro_par, constants) C_chl = set_units(246.0161, umol / mol) FvCB(C_chl, pars) ``` -------------------------------- ### R: Photosynthesis with Tealeaves Package Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/articles/photosynthesis-introduction.html This example demonstrates how to set up parameters and run the photosynthesis model using the tealeaves package for leaf temperature calculation. It requires setting `use_tealeaves = TRUE` and providing additional parameters for the tealeaves model. The code is not evaluated on CRAN due to potential issues but can be run locally. ```R # NOTE: parallel example is not evaluated because it was causing an issue with CRAN, but you can copy-and-paste the code to run on your own machine. # You will need to set use_tealeaves = TRUE when making parameters because additional parameters are needed for tealeaves. bake_par = make_bakepar() constants = make_constants(use_tealeaves = TRUE) enviro_par = make_enviropar( replace = list( T_air = set_units(seq(288.15, 313.15, 1), K) ), use_tealeaves = TRUE ) leaf_par = make_leafpar(replace = list( g_sc = set_units(c(0.2, 0.4), mol / m^2 / s) ), use_tealeaves = TRUE ) ph = photosynthesis(leaf_par, enviro_par, bake_par, constants, use_tealeaves = TRUE, progress = FALSE, quiet = TRUE, parallel = TRUE) # Plot temperature and photosynthesis library(ggplot2) ## Drop units for plotting ph %<>% mutate_if(~ is(.x, "units"), drop_units) %>% mutate(`g[s]` = ifelse(g_sc == 0.2, "low", "high")) ggplot(ph, aes(T_air, T_leaf, color = `g[s]`)) + geom_line(size = 2, lineend = "round") + geom_abline(slope = 1, intercept = 0, linetype = "dotted") + scale_color_discrete(name = expression(g[s])) + xlab(expression(paste(T[air], " [K] "))) + ylab(expression(paste(T[leaf], " [K] "))) + theme_bw() + NULL ggplot(ph, aes(T_air, A, color = `g[s]`)) + geom_line(size = 2, lineend = "round") + scale_color_discrete(name = expression(g[s])) + xlab(expression(paste(T[leaf], " [K] "))) + ylab(expression(paste("A [", mu, "mol ", m^-2~s^-1, "]"))) + theme_bw() + NULL ``` -------------------------------- ### Install photosynthesis from CRAN Source: https://github.com/cdmuir/photosynthesis/blob/main/README.md Use this command to install the photosynthesis package from the Comprehensive R Archive Network (CRAN). ```r install.packages("photosynthesis") ``` -------------------------------- ### Example Data Output Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_many.html This shows the typical output structure for a single fit, including parameters and their associated values. It is often displayed after running a fitting function. ```R #> 6 0 8.94862 0.5509706 47.01527 16.63315 0.08692268 1000 NA -0.1565895 #> R_d_se cost citransition1 citransition2 V_cmax_pts J_max_pts #> 6 0.1264438 0.1194886 441.2967 1442.493 8 4 #> V_TPU_pts alpha alpha_g gamma_star25 Ea_gamma_star K_M25 Ea_K_M g_mc25 #> 6 0 0.24 0 42.75 37830 718.4 65508.28 0.08701 #> Ea_g_mc Oconc theta_J #> 6 0 21 0.85 ``` -------------------------------- ### Example: Fit and Print Single AQ Response Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/print_graphs.html Demonstrates reading data, fitting a single CO2 response curve, and printing the model summary, fitted parameters, and the generated graph. ```R # Read in your data # Note that this data is coming from data supplied by the package # hence the complicated argument in read.csv() # This dataset is a CO2 by light response curve for a single sunflower data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) # Fit many AQ curves # Set your grouping variable # Here we are grouping by CO2_s and individual data$C_s <- (round(data$CO2_s, digits = 0)) # For this example we need to round sequentially due to CO2_s setpoints data$C_s <- as.factor(round(data$C_s, digits = -1)) # To fit one AQ curve fit <- fit_aq_response(data[data$C_s == 600, ], varnames = list( A_net = "A", PPFD = "Qin" ) ) # Print model summary summary(fit[[1]]) #> #> Formula: A_net ~ aq_response(k_sat, phi_J, Q_abs = data$Q_abs, theta_J) - #> Rd #> #> Parameters: #> Estimate Std. Error t value Pr(>|t|) #> k_sat 21.167200 0.158332 133.69 1.88e-08 *** #> phi_J.Q_abs 0.051907 0.001055 49.18 1.02e-06 *** #> theta_J 0.775484 0.014920 51.98 8.20e-07 *** #> Rd.(Intercept) 0.668495 0.065235 10.25 0.000511 *** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Residual standard error: 0.05535 on 4 degrees of freedom #> #> Number of iterations to convergence: 5 #> Achieved convergence tolerance: 1.49e-08 #> # Print fitted parameters fit[[2]] #> A_sat phi_J theta_J Rd LCP resid_SSs #> k_sat 21.1672 0.05190746 0.7754836 0.6684953 12.97289 0.01225491 # Print graph fit[[3]] ``` -------------------------------- ### Fit a light-response curve using fit_photosynthesis Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_aq_response2.html Demonstrates fitting a light-response curve using the fit_photosynthesis function with the 'aq_response' photo_fun. This example shows data preparation, including setting grouping variables, and then fitting the model. The resulting 'fit' object is an 'nls' class object. ```R library(broom) library(dplyr) # # Attaching package: ‘dplyr’ # The following objects are masked from ‘package:stats’: # # filter, lag # The following objects are masked from ‘package:base’: # # intersect, setdiff, setequal, union library(photosynthesis) # Read in your data dat = system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis") |> read.csv() |> # Set grouping variable mutate(group = round(CO2_s, digits = 0)) |> # For this example, round sequentially due to CO2_s set points mutate(group = as.factor(round(group, digits = -1))) # Fit one light-response curve fit = fit_photosynthesis( .data = filter(dat, group == 600), .photo_fun = "aq_response", .vars = list(.A = A, .Q = Qabs) ) # The 'fit' object inherits class 'nls' and many methods can be used ## Model summary: summary(fit) ``` -------------------------------- ### Load photosynthesis package Source: https://github.com/cdmuir/photosynthesis/blob/main/README.md Load the photosynthesis package into your R session after installation to start using its functions. ```r library("photosynthesis") ``` -------------------------------- ### Fit Stomatal Conductance Models Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_gs_model.html This example demonstrates how to fit multiple stomatal conductance models using the fit_gs_model function. It includes reading data, converting relative humidity to a proportion, and specifying custom variable names for the model fitting process. Use this when you need to compare different stomatal conductance models for your dataset. ```R data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) # Convert RH to a proportion data$RH <- data$RHcham / 100 # Fit stomatal conductance models # Can specify a single model, or all as below fits <- fit_gs_model( data = data, varnames = list( A_net = "A", C_air = "Ca", g_sw = "gsw", RH = "RH", VPD = "VPDleaf" ), model = c( "BallBerry", "Leuning", "Medlyn_partial", "Medlyn_full" ) ) ``` -------------------------------- ### Parallel Photosynthesis Simulation with Future Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/articles/photosynthesis-introduction.html Accelerate photosynthesis simulations for multiple parameter sets by enabling parallel processing with the `parallel = TRUE` argument in the `photosynthesis` function. This requires setting up a `future::plan()`, such as `plan("multisession")`. Note: This example is commented out due to potential CRAN issues but can be run locally. ```R # NOTE: parallel example is not evaluated because it was causing an issue with CRAN, but you can copy-and-paste the code to run on your own machine. library(future) plan("multisession") # Set up plan # We'll use the `replace` argument to enter multiple atmospheric CO2 concentrations bake_par = make_bakepar() constants = make_constants(use_tealeaves = FALSE) enviro_par = make_enviropar( replace = list( C_air = set_units(seq(10, 2000, length.out = 20), umol / mol) ), use_tealeaves = FALSE ) leaf_par = make_leafpar(use_tealeaves = FALSE) ph = photosynthesis(leaf_par, enviro_par, bake_par, constants, use_tealeaves = FALSE, progress = FALSE, quiet = TRUE, parallel = TRUE) # Plot C_c versus A library(ggplot2) ## Drop units for plotting ph %<>% mutate_if(~ is(.x, "units"), drop_units) ggplot(ph, aes(C_chl, A)) + geom_line(size = 2) + xlab(expression(paste(C[chl], " [ppm] "))) + ylab(expression(paste("A [", mu, "mol ", m^-2~s^-1, "]"))) + theme_bw() + NULL ``` -------------------------------- ### Example: Reading and Fitting Temperature Response Data Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_t_response.html Demonstrates how to read temperature response data from a CSV file and then fit various temperature response models using the fit_t_response function. Ensure your data file contains the necessary columns for the parameter of interest and leaf temperature. ```R # Read in data data <- read.csv(system.file("extdata", "A_Ci_T_data.csv", package = "photosynthesis")) # Fit temperature response models fit_t_response(data) # Fit only the Medlyn model with specific starting parameters fit_t_response(data, model = "Medlyn", start = list(Ea = 40000, Par25 = 50, Hd = 2e+05, dS = 650)) # Fit the Medlyn model, setting Hd as a constant fit_t_response(data, model = "Medlyn", setvar = "Hd", hdset = 200000) # Fit the Medlyn model, setting dS as a constant fit_t_response(data, model = "Medlyn", setvar = "dS", dSset = 650) # Fit the MMRT model with custom starting parameters fit_t_response(data, model = "MMRT", start = list(dCp = 1, dG = 1, dH = 1)) # Fit the Heskel model with custom starting parameters fit_t_response(data, model = "Heskel", start = list(a = 1, b = 1, c = 1)) # Fit the Kruse model with custom starting parameters fit_t_response(data, model = "Kruse", start = list(dEa = 1, Ea_ref = 1, Par_ref = 1)) # Fit the Quadratic model fit_t_response(data, model = "Quadratic") # Fit the Topt model with custom starting parameters fit_t_response(data, model = "Topt", start = list(Ea = 40000, Par25 = 50, Hd = 2e+05)) # Fit the Arrhenius model fit_t_response(data, model = "Arrhenius") # } ``` -------------------------------- ### Example: Fit Many AQ Responses Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/print_graphs.html Demonstrates fitting multiple CO2 response curves from a dataset by grouping, using the `fit_many` function. ```R # Fit many curves fits <- fit_many( data = data, varnames = list( A_net = "A", PPFD = "Qin", group = "C_s" ), funct = fit_aq_response, group = "C_s" ) #> | | | 0% | |======== | 11% | |================ | 22% | ``` -------------------------------- ### Fit ACI Curve with Provided Data Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_aci_response.html This example demonstrates how to read data, preprocess it by defining a grouping factor and converting temperature to Kelvin, and then fit an ACI curve using the fit_aci_response function. It shows how to specify variable names for the model. ```R # Read in your data # Note that this data is coming from data supplied by the package # hence the complicated argument in read.csv() # This dataset is a CO2 by light response curve for a single sunflower data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) # Define a grouping factor based on light intensity to split the ACi # curves data$Q_2 <- as.factor((round(data$Qin, digits = 0))) # Convert leaf temperature to K data$T_leaf <- data$Tleaf + 273.15 # Fit ACi curve. Note that we are subsetting the dataframe # here to fit for a single value of Q_2 fit <- fit_aci_response(data[data$Q_2 == 1500, ], varnames = list( A_net = "A", T_leaf = "T_leaf", C_i = "Ci", PPFD = "Qin" ) ) ``` -------------------------------- ### Compute Sensitivity Measures Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/compute_sensitivity.html This example demonstrates how to use the compute_sensitivity function after obtaining sensitivity analysis results. It specifies the data, variable names for the parameters of interest, and their reference values to calculate sensitivity measures. ```R data <- read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) data$Q_2 <- as.factor((round(data$Qin, digits = 0))) data$T_leaf <- data$Tleaf + 273.15 # pars <- analyze_sensitivity( # data = data[data$Q_2 == 1500, ], # funct = fit_aci_response, # varnames = list( # A_net = "A", # T_leaf = "T_leaf", # C_i = "Ci", # PPFD = "Qin" # ), # useg_mct = TRUE, # test1 = "gamma_star25", # element_out = 1, # test2 = "g_mc25", # fitTPU = TRUE, # Ea_gamma_star = 0, # Ea_g_mc = 0, # values1 = seq( # from = 20, # to = 60, # by = 2 # ), # values2 = seq( # from = 0.2, # to = 2, # by = 0.1 # ) # ) par2 <- compute_sensitivity( data = pars, varnames = list( Par = "V_cmax", test1 = "gamma_star25", test2 = "g_mc25" ), test1_ref = 42, test2_ref = 1 ) ``` -------------------------------- ### Amphistomatous Leaf Model Setup Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/articles/modeling-recommendations.html Configures parameters for an amphistomatous leaf model, allowing for stomatal conductance on both surfaces and explicitly modeling internal airspace and liquid-phase conductances. Use this for models where stomata are present on both the upper and lower leaf surfaces. ```R library(photosynthesis) bake_par = make_bakepar() # temperature response parameters constants = make_constants(use_tealeaves = FALSE) # physical constants # leaf parameters leaf_par = make_leafpar( replace = list( # Set cuticular conductance to 0 g_uc = set_units(0, mol / m^2 / s), # Half of conductance through each surface k_mc = set_units(0, 1), # airspace conductance: define effective distance through airspace # See Nobel (2020) pg. 431 delta_ias_lower = set_units(100, um), delta_ias_upper = set_units(100, um), # liquid conductance: sum of cell wall, plasma membrane, and cytosol resistance # We are implicitly ignoring chloroplast resistance # See Nobel (2020) pg. 448-452 A_mes_A = set_units(20, 1), g_liqc25 = set_units(0.02, mol / m^2 / s), k_sc = set_units(1, 1) ), use_tealeaves = FALSE ) enviro_par = make_enviropar(use_tealeaves = FALSE) # environmental parameters photo(leaf_par, enviro_par, bake_par, constants, use_tealeaves = FALSE) | dplyr::select(g_sc, g_iasc_lower, g_iasc_upper, g_liqc, A) | knitr::kable(caption = "Stomatal conductance to CO2 (g_sc), internal airspace resistance through lower and upper surfaces (g_iasc_x), liquid-phase conductance (g_liqc), and net photosynthetic carbon assimilation (A) from C3 photosynthesis model.") ``` -------------------------------- ### Simulating Measurement Error with `simulate_error` Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/simulate_error.html This example demonstrates how to use the `simulate_error` function to add measurement errors to photosynthesis data. It first generates 'real' values using `photosynthesis()` and then applies simulated errors based on specified `chamber_pars`. Ensure parameters like `g_sc`, `g_uc`, `k_mc`, `k_sc`, and `k_uc` are set to meet the assumptions of `simulate_error`. ```R library(photosynthesis) # Use photosynthesis() to simulate 'real' values # `replace = ...` sets parameters to meet assumptions of `simulate_error()` lp = make_leafpar(replace = list( g_sc = set_units(0.1, mol/m^2/s), g_uc = set_units(0, mol/m^2/s), k_mc = set_units(0, 1), k_sc = set_units(0, 1), k_uc = set_units(0, 1) ), use_tealeaves = FALSE) ep = make_enviropar(replace = list( wind = set_units(Inf, m/s) ), use_tealeaves = FALSE) bp = make_bakepar() cs = make_constants(use_tealeaves = FALSE) chamber_pars = data.frame( flow = set_units(600, umol / s), leaf_area = set_units(6, cm ^ 2), sigma_CO2_s = 0.1, sigma_CO2_r = 0.1, sigma_H2O_s = 0.1, sigma_H2O_r = 0.1 ) ph = photosynthesis(lp, ep, bp, cs, use_tealeaves = FALSE, quiet = TRUE) | simulate_error(chamber_pars, n = 1L) ``` -------------------------------- ### Fit many A-Ci curves across light intensity groups Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_many.html This example demonstrates fitting A-Ci response curves to data grouped by light intensity. It involves reading data, defining a grouping factor, converting temperature units, and then applying `fit_many` with specific variable names and the `fit_aci_response` function. A progress bar is shown during fitting. ```R data = read.csv(system.file("extdata", "A_Ci_Q_data_1.csv", package = "photosynthesis" )) # Define a grouping factor based on light intensity to split the ACi # curves data$Q_2 = as.factor((round(data$Qin, digits = 0))) # Convert leaf temperature to K data$T_leaf = data$Tleaf + 273.15 # Fit many curves fits = fit_many( data = data, varnames = list( A_net = "A", T_leaf = "T_leaf", C_i = "Ci", PPFD = "Qin" ), funct = fit_aci_response, group = "Q_2" ) #> | | | 0% | |========= | 12% | |================== | 25% | |========================== | 38% | |=================================== | 50% | |============================================ | 62% | |==================================================== | 75% | |============================================================= | 88% | |======================================================================| 100% # Print the parameters # First set of double parentheses selects an individual group value # Second set selects an element of the sublist fits[[3]][[1]] #> Num V_cmax V_cmax_se J_max J J_se V_TPU V_TPU_se R_d ``` -------------------------------- ### Initialize Photosynthesis Parameters Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/make_parameters.html Initializes default parameters for bakepar, constants, enviropar, and leafpar. Use use_tealeaves = FALSE for standard leaf simulations. ```R bake_par = make_bakepar() constants = make_constants(use_tealeaves = FALSE) enviropar = make_enviropar(use_tealeaves = FALSE) leaf_par = make_leafpar(use_tealeaves = FALSE) ``` -------------------------------- ### parameter_names() Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Gets a vector of parameter names used in the photosynthesis package. ```APIDOC ## parameter_names() ### Description Get vector of parameter names. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters None explicitly documented in this snippet. ### Response Returns a character vector of parameter names. ### Response Example Not available in source. ``` -------------------------------- ### Get Citation Information Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/index.html Retrieve citation information for the photosynthesis package in R. ```r citation(package = 'photosynthesis') ``` -------------------------------- ### Get Stomatal Conductance to CO2 Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/CO2_conductance.html Calculates the stomatal conductance to CO2 for a specified leaf surface. ```APIDOC ## .get_gsc ### Description Calculates the stomatal conductance to CO2 (g_sc) for a specified leaf surface (lower or upper). ### Method Internal R function (not directly callable by users as a public API endpoint). ### Parameters #### Arguments * **pars**: Concatenated parameters (`leaf_par`, `enviro_par`, and `constants`). * **surface**: Leaf surface (lower or upper). * **unitless** (logical): If TRUE, units are not applied, potentially speeding up calculations but requiring correct input units. ``` -------------------------------- ### Get Mesophyll Conductance to CO2 Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/CO2_conductance.html Calculates the mesophyll conductance to CO2 for a specified leaf surface. ```APIDOC ## .get_gmc ### Description Calculates the mesophyll conductance to CO2 (g_mc) for a specified leaf surface (lower or upper). ### Method Internal R function (not directly callable by users as a public API endpoint). ### Parameters #### Arguments * **pars**: Concatenated parameters (`leaf_par`, `enviro_par`, and `constants`). * **surface**: Leaf surface (lower or upper). * **unitless** (logical): If TRUE, units are not applied, potentially speeding up calculations but requiring correct input units. ``` -------------------------------- ### Get Cuticular Conductance to CO2 Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/CO2_conductance.html Calculates the cuticular conductance to CO2 for a specified leaf surface. ```APIDOC ## .get_guc ### Description Calculates the cuticular conductance to CO2 (g_uc) for a specified leaf surface (lower or upper). ### Method Internal R function (not directly callable by users as a public API endpoint). ### Parameters #### Arguments * **pars**: Concatenated parameters (`leaf_par`, `enviro_par`, and `constants`). * **surface**: Leaf surface (lower or upper). * **unitless** (logical): If TRUE, units are not applied, potentially speeding up calculations but requiring correct input units. ``` -------------------------------- ### Calculate CO2 Supply and Demand Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/A_supply.html Demonstrates how to calculate CO2 supply and demand rates using the A_supply and A_demand functions. Requires setting up leaf, environmental, and constant parameters. ```R bake_par = make_bakepar() constants = make_constants(use_tealeaves = FALSE) enviro_par = make_enviropar(use_tealeaves = FALSE) leaf_par = make_leafpar(use_tealeaves = FALSE) leaf_par = bake(leaf_par, enviro_par, bake_par, constants) # Or bake with piping (need library(magrittr)) # leaf_par %<>% bake(enviro_par, bake_par, constants) enviro_par$T_air = leaf_par$T_leaf pars = c(leaf_par, enviro_par, constants) C_chl = set_units(350, umol/mol) A_supply(C_chl, pars) #> 12.0831 [umol/m^2/s] A_demand(C_chl, pars) #> 31.28078 [umol/m^2/s] ``` -------------------------------- ### Get default model for 'r_light' Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/models.html Retrieves the default model name for the 'r_light' function. This function is used for fitting light response curves. ```R get_default_model("r_light") #> [1] "walker_ort_2015" ``` -------------------------------- ### Get default model for 'aq_response' Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/models.html Retrieves the default model name for the 'aq_response' function. This function is used for fitting light response curves. ```R get_default_model("aq_response") #> [1] "marshall_biscoe_1980" ``` -------------------------------- ### Bake Photosynthesis Parameters Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/bake.html Demonstrates the process of creating and baking photosynthesis parameters. Use this to set environmental conditions and leaf properties to calculate final photosynthetic rates. Ensure necessary helper functions like `make_bakepar`, `make_constants`, and `make_enviropar` are called. ```r bake_par = make_bakepar() constants = make_constants(use_tealeaves = FALSE) enviro_par = make_enviropar(use_tealeaves = FALSE) leaf_par = make_leafpar( replace = list(T_leaf = set_units(293.15, K)), use_tealeaves = FALSE ) baked_leafpar = bake(leaf_par, enviro_par, bake_par, constants) baked_leafpar$V_cmax25 #> 150 [umol/m^2/s] baked_leafpar$V_cmax #> 104.7069 [umol/m^2/s] ``` -------------------------------- ### analyze_sensitivity() Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Runs two-parameter sensitivity analyses for photosynthesis models. ```APIDOC ## analyze_sensitivity() ### Description Runs 2-parameter sensitivity analyses. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters None explicitly documented in this snippet. ### Response Returns results of the sensitivity analysis. ### Response Example Not available in source. ``` -------------------------------- ### Get Boundary Layer Conductance to CO2 Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/CO2_conductance.html Calculates the boundary layer conductance to CO2 for a specified leaf surface, based on mass and heat transfer principles. ```APIDOC ## .get_gbc ### Description Calculates the boundary layer conductance to CO2 (g_bc) for a specified leaf surface. Calculations are based on mass and heat transfer principles. ### Method Internal R function (not directly callable by users as a public API endpoint). ### Parameters #### Arguments * **pars**: Concatenated parameters (`leaf_par`, `enviro_par`, and `constants`). * **surface**: Leaf surface (lower or upper). * **unitless** (logical): If TRUE, units are not applied, potentially speeding up calculations but requiring correct input units. * **use_legacy_version** (logical): If TRUE, uses the legacy model version (<2.1.0). Defaults to FALSE. ``` -------------------------------- ### Get Total Conductance to CO2 Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/CO2_conductance.html Calculates the total conductance to CO2 based on provided parameters. This function sums the conductances of the lower and upper leaf portions. ```APIDOC ## .get_gtc ### Description Calculates the total conductance to CO2 (g_tc) by summing the conductances of the lower and upper leaf portions. ### Method Internal R function (not directly callable by users as a public API endpoint). ### Parameters #### Arguments * **pars**: Concatenated parameters (`leaf_par`, `enviro_par`, and `constants`). * **unitless** (logical): If TRUE, units are not applied, potentially speeding up calculations but requiring correct input units. * **use_legacy_version** (logical): If TRUE, uses the legacy model version (<2.1.0). Defaults to FALSE. ``` -------------------------------- ### make_parameters functions (make_leafpar(), make_enviropar(), make_bakepar(), make_constants()) Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Creates lists of parameters for use with the photosynthesis package. ```APIDOC ## make_parameters functions (make_leafpar(), make_enviropar(), make_bakepar(), make_constants()) ### Description Make lists of parameters for the photosynthesis package. ### Method Not applicable (R functions) ### Endpoint Not applicable (R functions) ### Parameters None explicitly documented in this snippet. ### Response Returns parameter lists. ### Response Example Not available in source. ``` -------------------------------- ### photosynthesis() and photo() Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Simulates C3 photosynthesis. ```APIDOC ## photosynthesis() and photo() ### Description Simulate C3 photosynthesis. ### Method Not applicable (R functions) ### Endpoint Not applicable (R functions) ### Parameters None explicitly documented in this snippet. ### Response Returns simulated C3 photosynthesis values. ### Response Example Not available in source. ``` -------------------------------- ### Get Leaf Parameter Names Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/parameter_names.html Retrieves a character vector of parameter names related to leaf properties. This is useful for understanding which parameters are associated with leaf-level calculations when not using tealeaves for leaf temperature. ```r parameter_names("leaf", use_tealeaves = FALSE) #> [1] "A_mes_A" "J_max25" "K_C25" "K_O25" #> [5] "R_d25" "T_leaf" "V_cmax25" "V_tpu25" #> [9] "delta_ias_lower" "delta_ias_upper" "g_liqc25" "g_mc25" #> [13] "g_sc" "g_uc" "gamma_star25" "k_mc" #> [17] "k_sc" "k_uc" "leafsize" "phi_J" #> [21] "theta_J" ``` -------------------------------- ### Run Minimum Photosynthesis Simulation Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/articles/photosynthesis-introduction.html This snippet demonstrates how to run a basic photosynthetic rate simulation using default parameters from the 'photosynthesis' package. It requires loading the 'dplyr', 'magrittr', and 'photosynthesis' libraries. ```R library(dplyr) library(magrittr) library(photosynthesis) # Leaving the make_* functions empty will automatically default to defaults # parameters. bake_par = make_bakepar() # temperature response parameters constants = make_constants(use_tealeaves = FALSE) # physical constants leaf_par = make_leafpar(use_tealeaves = FALSE) # leaf parameters enviro_par = make_enviropar(use_tealeaves = FALSE) # environmental parameters photo(leaf_par, enviro_par, bake_par, constants, quiet = TRUE, use_tealeaves = FALSE) ``` -------------------------------- ### Environmental Parameters Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/make_parameters.html Creates a list of environmental parameters. Use `replace` to override defaults and `use_tealeaves` to enable leaf energy balance calculations. ```R make_enviropar(replace = NULL, use_tealeaves) ``` -------------------------------- ### Get Default Calculated Parameter Function Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/calculated-parameters.html Use this function to retrieve the default R function associated with a specific calculated parameter name. The function expects a character string representing the parameter's name. ```R get_f_parameter(.f_name) ``` -------------------------------- ### Baking (Temperature Response) Parameters Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/make_parameters.html Creates a list of parameters related to temperature response curves. Use `replace` to override defaults. ```R make_bakepar(replace = NULL) ``` -------------------------------- ### Stomatal conductance models (gs_mod_ballberry(), gs_mod_leuning(), gs_mod_opti(), gs_mod_optifull()) Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Provides implementations of various stomatal conductance models. ```APIDOC ## Stomatal conductance models (gs_mod_ballberry(), gs_mod_leuning(), gs_mod_opti(), gs_mod_optifull()) ### Description Implementations of stomatal conductance models. ### Method Not applicable (R functions) ### Endpoint Not applicable (R functions) ### Parameters None explicitly documented in this snippet. ### Response Returns results from stomatal conductance models. ### Response Example Not available in source. ``` -------------------------------- ### Fit Photosynthesis with Yin et al. (2011) Model Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/fit_r_light2.html Estimates parameters using the Yin et al. (2011) model for light respiration. Requires A-phiPSII-Q data and specifies lower and upper bounds for Q. ```R # Yin et al. (2011) model fit = fit_photosynthesis( .data = acq_data, .photo_fun = "r_light", .model = "yin_etal_2011", .vars = list(.A = A, .phiPSII = PhiPS2, .Q = Qin), Q_lower = 20, Q_upper = 250 ) # The 'fit' object inherits class 'lm' and many methods can be used ## Model summary: summary(fit) ``` -------------------------------- ### Constants for Diffusion and Thermodynamics Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/make_parameters.html Creates a list of physical constants used in diffusion and thermodynamic calculations. Use `replace` to override defaults and `use_tealeaves` to enable leaf energy balance calculations. ```R make_constants(replace = NULL, use_tealeaves) ``` -------------------------------- ### photo_parameters Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Defines input parameters for simulating C3 photosynthesis using the photosynthesis() function. ```APIDOC ## photo_parameters ### Description Input parameters to simulate C3 photosynthesis using the photosynthesis() function. ### Method Not applicable (R object/structure) ### Endpoint Not applicable (R object/structure) ### Parameters None explicitly documented in this snippet. ### Response Defines the structure for photosynthesis simulation parameters. ### Response Example Not available in source. ``` -------------------------------- ### FvCB() Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/index.html Implements the Farquhar-von Caemmerer-Berry (FvCB) C3 photosynthesis model. ```APIDOC ## FvCB() ### Description Implements the Farquhar-von Caemmerer-Berry (FvCB) C3 photosynthesis model. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters None explicitly documented in this snippet. ### Response Returns simulation results from the FvCB model. ### Response Example Not available in source. ``` -------------------------------- ### Leaf Parameters Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/reference/make_parameters.html Creates a list of leaf-related parameters. Use `replace` to override defaults and `use_tealeaves` to enable leaf energy balance calculations. ```R make_leafpar(replace = NULL, use_tealeaves) ``` -------------------------------- ### Run Sensitivity Analysis on GammaStar and Mesophyll Conductance Source: https://github.com/cdmuir/photosynthesis/blob/main/docs/articles/sensitivity-analysis.html Performs a sensitivity analysis on GammaStar and mesophyll conductance at 25 Celsius for a single curve. It requires specifying the data, the fitting function, variable names, and the ranges for the parameters to test. The `useg_mct` argument should be set to TRUE when testing mesophyll conductance. ```R #Run a sensitivity analysis on GammaStar and mesophyll conductance #at 25 Celsius for one individual curve pars <- analyze_sensitivity(data = data[data$Q_2 == 1500, ], funct = fit_aci_response, varnames = list(A_net = "A", T_leaf = "T_leaf", C_i = "Ci", PPFD = "Qin"), useg_mct = TRUE, test1 = "gamma_star25", element_out = 1, test2 = "g_mc25", fitTPU = TRUE, Ea_gamma_star = 0, Ea_g_mc = 0, values1 = seq(from = 20, to = 60, by = 4), values2 = seq(from = 0.2, to = 2, by = 0.1)) ```