# Read an example Licor file included in the PhotoGEA package, calculate
# additional gas properties, calculate the Ball-Berry index, define a new column
# that uniquely identifies each curve, and then perform a fit to extract the
# Ball-Berry parameters from each curve.
licor_file <- read_gasex_file(
PhotoGEA_example_file_path('ball_berry_1.xlsx')
)
licor_file <- calculate_total_pressure(licor_file)
licor_file <- calculate_gas_properties(licor_file)
licor_file[,'species_plot'] <-
paste(licor_file[,'species'], '-', licor_file[,'plot'])
# Fit just one curve from the data set (it is rare to do this)
one_result <- fit_medlyn(
licor_file[licor_file[, 'species_plot'] == 'soybean - 1a', , TRUE]
)
# Fit all curves in the data set (it is more common to do this)
medlyn_results <- consolidate(by(
licor_file,
licor_file[, 'species_plot'],
fit_medlyn
))
# View the fitting parameters for each species / plot
col_to_keep <- c('species', 'plot', 'species_plot', 'medlyn_g0', 'medlyn_g1')
medlyn_results$parameters[ , col_to_keep]
# View the fits for each species / plot
lattice::xyplot(
gsw + gsw_fit ~ medlyn_index | species_plot,
data = medlyn_results$fits$main_data,
type = 'b',
pch = 16,
auto = TRUE,
xlab = paste('Medlyn index [', medlyn_results$fits$units$medlyn_index, ']'),
ylab = paste('Stomatal conductance to H2O [', medlyn_results$fits$units$gsw, ']')
)
Run the code above in your browser using DataLab