diff --git a/README.md b/README.md index 02e37fc..5625986 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ The function processes the provided CSV file by: - Combining the `Date` and `Time` columns to create a `DateTime` column and ordering the data chronologically. - Calculating initial ETR values from `Pm.-Det.` and `Fm-Det.` rows using `calc_etr()`. - Iterating through all rows with `Action == "P.+F. SP"` to calculate ETR values for both `Y.I.` and `Y.II.` -- Optionally stopping at the recovery period if `remove_recovery = TRUE`. +- Stopping at the recovery period if `remove_recovery = TRUE`. #### Return @@ -179,7 +179,7 @@ The function processes the provided CSV file by: - Combining the `Date` and `Time` columns to create a `DateTime` column and ordering the data chronologically. - Extracting the initial Pm.-Det. measurement at `PAR = 0` to calculate the first ETR value. - Iterating through all rows with `Action == "P700 SP"` to calculate ETR values for Photosystem I (`Y.I.`). -- Optionally stopping at the recovery period if `remove_recovery = TRUE`. +- Stopping at the recovery period if `remove_recovery = TRUE`. #### Return @@ -236,7 +236,7 @@ The function processes the provided CSV file by: - Combining the `Date` and `Time` columns to create a `DateTime` column and ordering the data chronologically. - Extracting the initial **Fm-Det.** measurement at `PAR = 0` to calculate the first ETR value. - Iterating through all rows with `Action == "Fluo. SP"` to calculate ETR values for Photosystem II (`Y.II.`). -- Optionally stopping at the recovery period if `remove_recovery = TRUE`. +- Stopping at the recovery period if `remove_recovery = TRUE`. #### Return @@ -292,9 +292,12 @@ The function processes the provided CSV file by: - Validating the raw Junior-PAM data with `validate_junior_pam_data()`. - Renaming columns to standard names (`PAR`, `Y.II`.) if necessary. - Filtering rows where Type equals `"FO"` or `"F"`. -- Converting and ordering the `DateTime` column. +- Ordering by `Time (rel/ms)` column. - Iterating through all rows to calculate ETR values for `Y.II.` using `calc_etr()`. -- Optionally stopping at the recovery period if `remove_recovery = TRUE`. +- Stopping at the recovery period if `remove_recovery = TRUE`. + +To ensure the file is imported correctly, please export the CSV file using the default settings: +![Plot](img/export_junior_pam.png) #### Return @@ -963,7 +966,7 @@ plot_control_eilers_peeters_ETR_II <- plot_control( print(plot_control_eilers_peeters_ETR_II) ``` -![Plot](test-eilers_peeters_etr_II_modified_control_plot_20240925.jpg) +![Plot](img/test-eilers_peeters_etr_II_modified_control_plot_20240925.jpg) --- @@ -986,7 +989,7 @@ A plot displaying the original ETR and Yield values and the regression data from #### Examples ```r -test_data_file <- file.path(getwd(), "data", "20240925.csv") +test_data_file <- file.path(getwd(), "data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_II(data)) @@ -1003,7 +1006,7 @@ test_data_file <- file.path(getwd(), "data", "20240925.csv") ) ``` -![combo Plot](test_combo_plot_control_etr_II.jpg) +![combo Plot](img/test_combo_plot_control_etr_II.jpg) --- diff --git a/examples/Example_compare_models.R b/examples/Example_compare_models.R index e65a9a0..04a6a54 100644 --- a/examples/Example_compare_models.R +++ b/examples/Example_compare_models.R @@ -7,7 +7,7 @@ library("pam") #### read_dual_pam_data()#### # raw data file directory script_dir <- dirname(sys.frame(1)$ofile) -data_dir <- file.path(script_dir, "data", "bulk") +data_dir <- file.path(script_dir, "data", "dual_pam_data", "bulk") #### compare_regression_models_ETR_II#### compare_regression_models_ETR_II_result <- compare_regression_models_ETR_II(data_dir, read_dual_pam_data) diff --git a/examples/Example_multiple_data.R b/examples/Example_multiple_data.R index fc69ef3..e3d8c41 100644 --- a/examples/Example_multiple_data.R +++ b/examples/Example_multiple_data.R @@ -6,7 +6,7 @@ library("pam") #### raw data file directory#### script_dir <- dirname(sys.frame(1)$ofile) -data_dir <- file.path(script_dir, "data", "bulk") +data_dir <- file.path(script_dir, "data", "dual_pam_data", "bulk") output_dir <- file.path(script_dir, "output") dir.create(output_dir, showWarnings = FALSE) output_path_pdf <- file.path(output_dir, "eilers_peters_plot_control.pdf") diff --git a/img/export_junior_pam.png b/img/export_junior_pam.png new file mode 100644 index 0000000..28ffa71 Binary files /dev/null and b/img/export_junior_pam.png differ diff --git a/test-eilers_peeters_etr_II_modified_control_plot_20240925.jpg b/img/test-eilers_peeters_etr_II_modified_control_plot_20240925.jpg similarity index 100% rename from test-eilers_peeters_etr_II_modified_control_plot_20240925.jpg rename to img/test-eilers_peeters_etr_II_modified_control_plot_20240925.jpg diff --git a/test_combo_plot_control_etr_II.jpg b/img/test_combo_plot_control_etr_II.jpg similarity index 100% rename from test_combo_plot_control_etr_II.jpg rename to img/test_combo_plot_control_etr_II.jpg diff --git a/src/R/compare_regression_models.R b/src/R/compare_regression_models.R index facb739..59832d2 100644 --- a/src/R/compare_regression_models.R +++ b/src/R/compare_regression_models.R @@ -116,7 +116,7 @@ compare_regression_models <- function(data_dir, etr_type, read_func) { for (file in csv_files) { title <- basename(file) data <- do.call(read_func, list(csv_path = file)) - validate_data(data) + validate_intermediate_data(data) tryCatch( { diff --git a/src/R/device_dual_pam.R b/src/R/device_dual_pam.R new file mode 100644 index 0000000..57d7677 --- /dev/null +++ b/src/R/device_dual_pam.R @@ -0,0 +1,170 @@ +#' Read and Process DualPAM Data +#' +#' Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values, and returns a universal dataset. +#' +#' @param csv_path File path to the CSV file. +#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. +#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. +#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. +#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. +#' +#' @details +#' Calculates ETR using: +#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I or II)} \cdot \text{Yield (I or II)}} +#' +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} +#' +#' @return A \code{data.table} containing: +#' \itemize{ +#' \item \code{par}: Photosynthetically active radiation. +#' \item \code{yield_1}: Yield for photosystem I. +#' \item \code{yield_2}: Yield for photosystem II. +#' \item \code{etr_1}: Calculated ETR for photosystem I. +#' \item \code{etr_2}: Calculated ETR for photosystem II. +#' } +#' +#' @references{ +#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} +#' Heinz Walz GmbH, Effeltrich, Germany. +#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +#' } +#' @examples +#' path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") +#' data <- read_dual_pam_data(path) +#' @export +read_dual_pam_data <- function( + csv_path, + remove_recovery = TRUE, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5 +) { + if (fraction_photosystem_I + fraction_photosystem_II != 1) { + stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") + } + + tryCatch( + { + data <- utils::read.csv(csv_path, sep = ";", dec = ".") + data <- data.table::as.data.table(data) + + validate_dual_pam_data(data) + data <- data[data$ID == "SP", ] + + date_time_col_values <- c() + for (i in seq_len(nrow(data))) { + row <- data[i, ] + + date_time_row_value <- as.POSIXct( + paste(row$Date, row$Time, sep = " "), + tz = "GMT", "%d.%m.%y %H:%M:%S" + ) + date_time_col_values <- c(date_time_col_values, date_time_row_value) + } + + data$DateTime <- date_time_col_values + data <- data[order(data$DateTime), ] + + pm_det_row <- subset(data, data$PAR == 0 & data$Action == "Pm.-Det.") + yield_1_first <- pm_det_row$Y.I. + recalc_etr_1 <- calc_etr(yield_1_first, 0, etr_factor, fraction_photosystem_I) + + fm_det_row <- subset(data, data$PAR == 0 & data$Action == "Fm-Det.") + yield_2_first <- fm_det_row$Y.II. + recalc_etr_2 <- calc_etr(yield_2_first, 0, etr_factor, fraction_photosystem_II) + + + result <- data.table::data.table( + par = numeric(), + yield_1 = numeric(), + yield_2 = numeric(), + etr_1 = numeric(), + etr_2 = numeric() + ) + new_row <- list( + par = 0, + yield_1 = yield_1_first, + yield_2 = yield_2_first, + etr_1 = recalc_etr_1, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + + last_par <- as.numeric(0) + for (i in seq_len(nrow(data))) { + row <- data[i, ] + current_par <- row$PAR + + if (row$Action != "P.+F. SP") { + next + } + + if (remove_recovery && last_par != 0 && current_par < last_par) { + break + } + + yield_1 <- row$Y.I. + recalc_etr_1 <- calc_etr(yield_1, current_par, etr_factor, fraction_photosystem_I) + + yield_2 <- row$Y.II. + recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) + + new_row <- list( + par = current_par, + yield_1 = yield_1, + yield_2 = yield_2, + etr_1 = recalc_etr_1, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + + last_par <- current_par + } + + validate_intermediate_data(result) + return(result) + }, + warning = function(w) { + stop("Warning in file: ", csv_path, " Warning: ", w) + }, + error = function(e) { + stop("Error in file: ", csv_path, " Error: ", e) + } + ) +} + +validate_dual_pam_data <- function(data) { + validate_data_not_empty(data) + + if (!"ID" %in% colnames(data)) { + stop("required col 'ID' not found") + } + + if (!"PAR" %in% colnames(data)) { + stop("required col 'PAR' not found") + } + + if (!"Y.I." %in% colnames(data) && !"Y.II." %in% colnames(data)) { + stop("required col 'Y(I)' and 'Y(II)' not found") + } + + if (!"Action" %in% colnames(data)) { + stop("required col 'Action' not found") + } + + if (!"Date" %in% colnames(data)) { + stop("required col 'Date' not found") + } + + if (!"Time" %in% colnames(data)) { + stop("required col 'Time' not found") + } + + if (!"Pm.-Det." %in% data[["Action"]]) { + stop("required value 'Pm' not found in column 'Action'") + } + + if (!"Fm-Det." %in% data[["Action"]]) { + stop("required value 'Fm' not found in column 'Action'") + } +} diff --git a/src/R/device_dual_pam_single_channel_fluo.R b/src/R/device_dual_pam_single_channel_fluo.R new file mode 100644 index 0000000..176c3e4 --- /dev/null +++ b/src/R/device_dual_pam_single_channel_fluo.R @@ -0,0 +1,164 @@ +#' Read and Process DualPAM Data Single Chanel Mode Fluo +#' +#' Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values for Photosystem II, and returns a universal dataset. +#' +#' @param csv_path File path to the CSV file. +#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. +#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. +#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. +#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. +#' +#' @details +#' Calculates ETR using: +#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (II)} \cdot \text{Yield (II)}} +#' +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} +#' +#' @return A \code{data.table} containing: +#' \itemize{ +#' \item \code{par}: Photosynthetically active radiation. +#' \item \code{yield_1}: NA +#' \item \code{yield_2}: Yield for photosystem II. +#' \item \code{etr_1}: NA +#' \item \code{etr_2}: Calculated ETR for photosystem II. +#' } +#' +#' @references{ +#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} +#' Heinz Walz GmbH, Effeltrich, Germany. +#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +#' } +#' @examples +#' path <- file.path( +#' system.file("extdata/dual_pam_single_channel_fluo_data", package = "pam"), +#' "20260130_dual_pam_only_fluo.csv" +#' ) +#' data <- read_dual_pam_single_channel_fluo_data(path) +#' @export +read_dual_pam_single_channel_fluo_data <- function( + csv_path, + remove_recovery = TRUE, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5 +) { + if (fraction_photosystem_I + fraction_photosystem_II != 1) { + stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") + } + + tryCatch( + { + data <- utils::read.csv(csv_path, sep = ";", dec = ".") + data <- data.table::as.data.table(data) + + validate_dual_pam_single_channel_fluo_data(data) + data <- data[data$ID == "SP", ] + + date_time_col_values <- c() + for (i in seq_len(nrow(data))) { + row <- data[i, ] + + date_time_row_value <- as.POSIXct( + paste(row$Date, row$Time, sep = " "), + tz = "GMT", "%d.%m.%y %H:%M:%S" + ) + date_time_col_values <- c(date_time_col_values, date_time_row_value) + } + + data$DateTime <- date_time_col_values + data <- data[order(data$DateTime), ] + + fm_det_row <- subset(data, data$PAR == 0 & data$Action == "Fm-Det.") + yield_2_first <- fm_det_row$Y.II. + recalc_etr_2 <- calc_etr( + yield_2_first, 0, etr_factor, fraction_photosystem_II + ) + + + result <- data.table::data.table( + par = numeric(), + yield_1 = numeric(), + yield_2 = numeric(), + etr_1 = numeric(), + etr_2 = numeric() + ) + new_row <- list( + par = 0, + yield_1 = NA_real_, + yield_2 = yield_2_first, + etr_1 = NA_real_, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + + last_par <- as.numeric(0) + for (i in seq_len(nrow(data))) { + row <- data[i, ] + current_par <- row$PAR + + if (row$Action != "Fluo. SP") { + next + } + + if (remove_recovery && last_par != 0 && current_par < last_par) { + break + } + + yield_2 <- row$Y.II. + recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) + + new_row <- list( + par = current_par, + yield_1 = NA_real_, + yield_2 = yield_2, + etr_1 = NA_real_, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + + last_par <- current_par + } + + validate_intermediate_data(result) + return(result) + }, + warning = function(w) { + stop("Warning in file: ", csv_path, " Warning: ", w) + }, + error = function(e) { + stop("Error in file: ", csv_path, " Error: ", e) + } + ) +} + +validate_dual_pam_single_channel_fluo_data <- function(data) { + validate_data_not_empty(data) + + if (!"ID" %in% colnames(data)) { + stop("required col 'ID' not found") + } + + if (!"PAR" %in% colnames(data)) { + stop("required col 'PAR' not found") + } + + if (!"Y.II." %in% colnames(data)) { + stop("required col 'Y(II)' not found") + } + + if (!"Action" %in% colnames(data)) { + stop("required col 'Action' not found") + } + + if (!"Date" %in% colnames(data)) { + stop("required col 'Date' not found") + } + + if (!"Time" %in% colnames(data)) { + stop("required col 'Time' not found") + } + + if (!"Fm-Det." %in% data[["Action"]]) { + stop("required value 'Fm' not found in column 'Action'") + } +} diff --git a/src/R/device_dual_pam_single_channel_p700.R b/src/R/device_dual_pam_single_channel_p700.R new file mode 100644 index 0000000..0f6ff75 --- /dev/null +++ b/src/R/device_dual_pam_single_channel_p700.R @@ -0,0 +1,162 @@ +#' Read and Process DualPAM Data Single Chanel Mode P700 +#' +#' Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values for Photosystem I, and returns a universal dataset. +#' +#' @param csv_path File path to the CSV file. +#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. +#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. +#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. +#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. +#' +#' @details +#' Calculates ETR using: +#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I)} \cdot \text{Yield (I)}} +#' +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} +#' +#' @return A \code{data.table} containing: +#' \itemize{ +#' \item \code{par}: Photosynthetically active radiation. +#' \item \code{yield_1}: Yield for photosystem I +#' \item \code{yield_2}: NA +#' \item \code{etr_1}: Calculated ETR for photosystem I +#' \item \code{etr_2}: NA +#' } +#' +#' @references{ +#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} +#' Heinz Walz GmbH, Effeltrich, Germany. +#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +#' } +#' @examples +#' path <- file.path( +#' system.file("extdata/dual_pam_single_channel_p700_data", package = "pam"), +#' "20260130_01_dual_pam_only_p700.csv" +#' ) +#' data <- read_dual_pam_single_channel_p700_data(path) +#' @export +read_dual_pam_single_channel_p700_data <- function( + csv_path, + remove_recovery = TRUE, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5 +) { + if (fraction_photosystem_I + fraction_photosystem_II != 1) { + stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") + } + + tryCatch( + { + data <- utils::read.csv(csv_path, sep = ";", dec = ".") + data <- data.table::as.data.table(data) + + validate_dual_pam_single_channel_p700_data(data) + data <- data[data$ID == "SP", ] + + date_time_col_values <- c() + for (i in seq_len(nrow(data))) { + row <- data[i, ] + + date_time_row_value <- as.POSIXct( + paste(row$Date, row$Time, sep = " "), + tz = "GMT", "%d.%m.%y %H:%M:%S" + ) + date_time_col_values <- c(date_time_col_values, date_time_row_value) + } + + data$DateTime <- date_time_col_values + data <- data[order(data$DateTime), ] + + pm_det_row <- subset(data, data$PAR == 0 & data$Action == "Pm.-Det.") + yield_1_first <- pm_det_row$Y.I. + recalc_etr_1 <- calc_etr(yield_1_first, 0, etr_factor, fraction_photosystem_I) + + + result <- data.table::data.table( + par = numeric(), + yield_1 = numeric(), + yield_2 = numeric(), + etr_1 = numeric(), + etr_2 = numeric() + ) + new_row <- list( + par = 0, + yield_1 = yield_1_first, + yield_2 = NA_real_, + etr_1 = recalc_etr_1, + etr_2 = NA_real_ + ) + result <- rbind(result, new_row) + + last_par <- as.numeric(0) + for (i in seq_len(nrow(data))) { + row <- data[i, ] + current_par <- row$PAR + + if (row$Action != "P700 SP") { + next + } + + if (remove_recovery && last_par != 0 && current_par < last_par) { + break + } + + yield_1 <- row$Y.I. + recalc_etr_1 <- calc_etr(yield_1, current_par, etr_factor, fraction_photosystem_I) + + new_row <- list( + par = current_par, + yield_1 = yield_1, + yield_2 = NA_real_, + etr_1 = recalc_etr_1, + etr_2 = NA_real_ + ) + result <- rbind(result, new_row) + + last_par <- current_par + } + + validate_intermediate_data(result) + return(result) + }, + warning = function(w) { + stop("Warning in file: ", csv_path, " Warning: ", w) + }, + error = function(e) { + stop("Error in file: ", csv_path, " Error: ", e) + } + ) +} + +validate_dual_pam_single_channel_p700_data <- function(data) { + validate_data_not_empty(data) + + if (!"ID" %in% colnames(data)) { + stop("required col 'ID' not found") + } + + if (!"PAR" %in% colnames(data)) { + stop("required col 'PAR' not found") + } + + if (!"Y.I." %in% colnames(data)) { + stop("required col 'Y(I)' not found") + } + + if (!"Action" %in% colnames(data)) { + stop("required col 'Action' not found") + } + + if (!"Date" %in% colnames(data)) { + stop("required col 'Date' not found") + } + + if (!"Time" %in% colnames(data)) { + stop("required col 'Time' not found") + } + + if (!"Pm.-Det." %in% data[["Action"]]) { + stop("required value 'Pm.-Det.' not found in column 'Action'") + } +} diff --git a/src/R/device_junior_pam.R b/src/R/device_junior_pam.R new file mode 100644 index 0000000..92e8a5b --- /dev/null +++ b/src/R/device_junior_pam.R @@ -0,0 +1,125 @@ +#' Read and Process Junior PAM Data +#' +#' Reads raw CSV files generated by Junior PAM software, calculates electron transport rate (ETR) values, and returns a cleaned dataset. +#' +#' @param csv_path File path to the CSV file. +#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. +#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. +#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. +#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. +#' +#' @details +#' Calculates ETR II using: +#' \deqn{\text{ETR II} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (II)} \cdot \text{Yield (II)}} +#' +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file} +#' +#' @return A \code{data.table} containing: +#' \itemize{ +#' \item \code{par}: Photosynthetically active radiation. +#' \item \code{yield_1}: Yield for photosystem I. +#' \item \code{yield_2}: Yield for photosystem II. +#' \item \code{etr_1}: Calculated ETR for photosystem I. +#' \item \code{etr_2}: Calculated ETR for photosystem II. +#' } +#' +#' @references{ +#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} +#' Heinz Walz GmbH, Effeltrich, Germany. +#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +#' } +#' @examples +#' path <- file.path( +#' system.file("extdata/junior_pam_data", package = "pam"), +#' "2026_04_22_junior_pam.csv" +#' ) +#' data <- read_junior_pam_data(path) +#' @export +read_junior_pam_data <- function( + csv_path, + remove_recovery = TRUE, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5 +) { + if (fraction_photosystem_I + fraction_photosystem_II != 1) { + stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") + } + + tryCatch( + { + data <- utils::read.csv(csv_path, sep = ";", dec = ".", skip = 1, header = TRUE) + data <- data.table::as.data.table(data) + + validate_junior_pam_data(data) + + par_col <- grep("^.+\\.PAR$", names(data), value = TRUE)[1] + yield_2_col <- grep("^.+\\.Y\\.\\.II\\.$", names(data), value = TRUE)[1] + + data <- data[data$Type == "FO" | data$Type == "F", ] + data <- data[order(data$"Time..rel.ms."), ] + + result <- data.table::data.table( + par = numeric(), + yield_1 = numeric(), + yield_2 = numeric(), + etr_1 = numeric(), + etr_2 = numeric() + ) + last_par <- as.numeric(0) + for (i in seq_len(nrow(data))) { + row <- data[i, ] + current_par <- row[[par_col]] + + if (remove_recovery && last_par != 0 && current_par < last_par) { + break + } + + yield_2 <- row[[yield_2_col]] + recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) + + new_row <- list( + par = current_par, + yield_1 = NA_real_, + yield_2 = yield_2, + etr_1 = NA_real_, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + + last_par <- current_par + } + + validate_intermediate_data(result) + return(result) + }, + warning = function(w) { + stop("Warning in file: ", csv_path, " Warning: ", w) + }, + error = function(e) { + stop("Error in file: ", csv_path, " Error: ", e) + } + ) +} + +validate_junior_pam_data <- function(data) { + validate_data_not_empty(data) + + par_cols <- grep("^.+\\.PAR$", names(data), value = TRUE) + if (length(par_cols) == 0) { + stop("required col 'PAR' not found") + } else if (length(par_cols) > 1) { + stop(paste(length(par_cols), " 'PAR' cols found. Only supporting one 'PAR' column")) + } + + yield_cols <- grep("^.+\\.Y\\.\\.II\\.$", names(data), value = TRUE) + if (length(yield_cols) == 0) { + stop("required col 'Y (II)' not found") + } else if (length(yield_cols) > 1) { + stop(paste(length(yield_cols), " 'Y (II)' cols found. Only supporting one 'Y (II)' column")) + } + + if (!"Time..rel.ms." %in% colnames(data)) { + stop("required col 'Time (rel/ms)' not found") + } +} diff --git a/src/R/device_pam_2500.R b/src/R/device_pam_2500.R new file mode 100644 index 0000000..0389338 --- /dev/null +++ b/src/R/device_pam_2500.R @@ -0,0 +1,133 @@ +#' Read and Process PAM 2500 Data +#' +#' Reads raw CSV files generated by PAM 2500 software, calculates electron transport rate (ETR) values, and returns a cleaned dataset. +#' +#' @param csv_path File path to the CSV file. +#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. +#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. +#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. +#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. +#' +#' @details +#' Calculates ETR II using: +#' \deqn{\text{ETR II} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (II)} \cdot \text{Yield (II)}} +#' +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file} +#' +#' @return A \code{data.table} containing: +#' \itemize{ +#' \item \code{par}: Photosynthetically active radiation. +#' \item \code{yield_1}: Yield for photosystem I. +#' \item \code{yield_2}: Yield for photosystem II. +#' \item \code{etr_1}: Calculated ETR for photosystem I. +#' \item \code{etr_2}: Calculated ETR for photosystem II. +#' } +#' +#' @references{ +#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} +#' Heinz Walz GmbH, Effeltrich, Germany. +#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +#' } +#' @examples +#' path <- file.path(system.file("extdata/pam_2500_data", package = "pam"), "20260422_pam_2500.CSV") +#' data <- read_pam_2500_data(path) +#' @export +read_pam_2500_data <- function( + csv_path, + remove_recovery = TRUE, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5 +) { + if (fraction_photosystem_I + fraction_photosystem_II != 1) { + stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") + } + + tryCatch( + { + data <- utils::read.csv(csv_path, sep = ";", dec = ".") + data <- data.table::as.data.table(data) + + validate_pam_2500_data(data) + data <- data[grepl("^\\d+$", data$`No.`), ] + + date_time_col_values <- c() + for (i in seq_len(nrow(data))) { + row <- data[i, ] + + date_time_row_value <- as.POSIXct( + paste(row$Date, row$Time, sep = " "), + tz = "GMT", "%d.%m.%y %H:%M:%S" + ) + date_time_col_values <- c(date_time_col_values, date_time_row_value) + } + + data$DateTime <- date_time_col_values + data <- data[order(data$DateTime), ] + + result <- data.table::data.table( + par = numeric(), + yield_1 = numeric(), + yield_2 = numeric(), + etr_1 = numeric(), + etr_2 = numeric() + ) + last_par <- as.numeric(0) + for (i in seq_len(nrow(data))) { + row <- data[i, ] + current_par <- row$PAR + + if (remove_recovery && last_par != 0 && current_par < last_par) { + break + } + + yield_2 <- row$Y.II. + recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) + + new_row <- list( + par = current_par, + yield_1 = NA_real_, + yield_2 = yield_2, + etr_1 = NA_real_, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + + last_par <- current_par + } + + validate_intermediate_data(result) + return(result) + }, + warning = function(w) { + stop("Warning in file: ", csv_path, " Warning: ", w) + }, + error = function(e) { + stop("Error in file: ", csv_path, " Error: ", e) + } + ) +} + +validate_pam_2500_data <- function(data) { + validate_data_not_empty(data) + + if (!"No." %in% colnames(data)) { + stop("required col 'No.' not found") + } + + if (!"PAR" %in% colnames(data)) { + stop("required col 'PAR' not found") + } + + if (!"Date" %in% colnames(data)) { + stop("required col 'Date' not found") + } + + if (!"Time" %in% colnames(data)) { + stop("required col 'Time' not found") + } + + if (!"Y.II." %in% colnames(data)) { + stop("required col 'Y(II)' not found") + } +} diff --git a/src/R/device_universal_data.R b/src/R/device_universal_data.R new file mode 100644 index 0000000..ddc6941 --- /dev/null +++ b/src/R/device_universal_data.R @@ -0,0 +1,93 @@ +#' Read and Process Universal PAM Data +#' +#' Reads a standardized CSV file containing PAR and yield data for photosystem I and/or II, calculates electron transport rates (ETR), and returns a cleaned and validated dataset. The function is device-agnostic but requires a predefined column structure. +#' +#' @param csv_path File path to the CSV file. +#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. +#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR +#' to photosystem I. Default is \code{0.5}. +#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR +#' to photosystem II. Default is \code{0.5}. +#' +#' @details +#' Calculates ETR using: +#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I or II)} \cdot \text{Yield (I or II)}} +#' +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_universal_data} +#' +#' @return A \code{data.table} containing: +#' \itemize{ +#' \item \code{par}: Photosynthetically active radiation. +#' \item \code{yield_1}: Yield for photosystem I. +#' \item \code{yield_2}: Yield for photosystem II. +#' \item \code{etr_1}: Calculated ETR for photosystem I. +#' \item \code{etr_2}: Calculated ETR for photosystem II. +#' } +#' +#' @references{ +#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} +#' Heinz Walz GmbH, Effeltrich, Germany. +#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +#' } +#' @examples +#' path <- file.path(system.file("extdata", package = "pam"), "universal_data", "universal_data.csv") +#' data <- read_universal_data(path) +#' @export +read_universal_data <- function(csv_path, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5) { + if (fraction_photosystem_I + fraction_photosystem_II != 1) { + stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") + } + + data <- utils::read.csv(csv_path, sep = ";", dec = ".") + data <- data.table::as.data.table(data) + validate_universal_data(data) + + result <- data.table::data.table( + par = numeric(), + yield_1 = numeric(), + yield_2 = numeric(), + etr_1 = numeric(), + etr_2 = numeric() + ) + for (i in seq_len(nrow(data))) { + row <- data[i, ] + current_par <- row$par + + yield_1 <- row$yield_1 + recalc_etr_1 <- calc_etr(yield_1, current_par, etr_factor, fraction_photosystem_I) + + yield_2 <- row$yield_2 + recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) + + new_row <- list( + par = current_par, + yield_1 = yield_1, + yield_2 = yield_2, + etr_1 = recalc_etr_1, + etr_2 = recalc_etr_2 + ) + result <- rbind(result, new_row) + } + + validate_intermediate_data(result) + return(result) +} + +validate_universal_data <- function(data) { + validate_data_not_empty(data) + + if (!"par" %in% colnames(data)) { + stop("required col 'par' not found") + } + + if (!"yield_1" %in% colnames(data)) { + stop("required col 'yield_1' not found") + } + + if (!"yield_2" %in% colnames(data)) { + stop("required col 'yield_2' not found") + } +} diff --git a/src/R/eilers_peeters.R b/src/R/model_eilers_peeters.R similarity index 99% rename from src/R/eilers_peeters.R rename to src/R/model_eilers_peeters.R index d122966..db50ac0 100644 --- a/src/R/eilers_peeters.R +++ b/src/R/model_eilers_peeters.R @@ -132,7 +132,7 @@ eilers_peeters_generate_regression_internal <- function( ) { tryCatch( { - validate_data(data) + validate_intermediate_data(data) validate_etr_type(etr_type) if (!is.numeric(a_start_value)) { diff --git a/src/R/platt.R b/src/R/model_platt.R similarity index 99% rename from src/R/platt.R rename to src/R/model_platt.R index 19435ab..9fab2ed 100644 --- a/src/R/platt.R +++ b/src/R/model_platt.R @@ -137,7 +137,7 @@ platt_generate_regression_internal <- function( ) { tryCatch( { - validate_data(data) + validate_intermediate_data(data) validate_etr_type(etr_type) if (!is.numeric(alpha_start_value)) { diff --git a/src/R/vollenweider.R b/src/R/model_vollenweider.R similarity index 99% rename from src/R/vollenweider.R rename to src/R/model_vollenweider.R index aae0ece..485a3e8 100644 --- a/src/R/vollenweider.R +++ b/src/R/model_vollenweider.R @@ -147,7 +147,7 @@ vollenweider_generate_regression_internal <- function( tryCatch( { validate_etr_type(etr_type) - validate_data(data) + validate_intermediate_data(data) if (!is.numeric(pmax_start_value)) { stop("pmax start value is not a valid number") diff --git a/src/R/walsby.R b/src/R/model_walsby.R similarity index 99% rename from src/R/walsby.R rename to src/R/model_walsby.R index 341d0f2..b321458 100644 --- a/src/R/walsby.R +++ b/src/R/model_walsby.R @@ -136,7 +136,7 @@ walsby_generate_regression_internal <- function( beta_start_value = walsby_default_start_value_beta) { tryCatch( { - validate_data(data) + validate_intermediate_data(data) validate_etr_type(etr_type) if (!is.numeric(etr_max_start_value)) { diff --git a/src/R/combo_plot_control.R b/src/R/plot.R similarity index 52% rename from src/R/combo_plot_control.R rename to src/R/plot.R index c2c12ea..a3a88e3 100644 --- a/src/R/combo_plot_control.R +++ b/src/R/plot.R @@ -36,7 +36,7 @@ combo_plot_control <- function( name_list, color_list ) { - validate_data(data) + validate_intermediate_data(data) if (length(model_results) <= 0) { stop("empty model_results") @@ -228,3 +228,213 @@ combo_plot_control <- function( return(plot) } + + +plot_table <- function(model_result, entries_per_row) { + validate_model_result(model_result) + + custom_theme <- gridExtra::ttheme_minimal( + core = list( + fg_params = list( + cex = 0.7, + fontface = 3 + ), + bg_params = list( + fill = "lightgray", + col = "black" + ) + ), # font size for cell text + colhead = list( + fg_params = list(cex = 0.7), + bg_params = list( + fill = "lightgray", + col = "black" + ) + ), # font size for column headers + rowhead = list( + fg_params = list(cex = 0.7), + bg_params = list( + fill = "lightgray", + col = "black" + ) + ), # font size for row headers + ) + + tbl_list <- list() + row <- NULL + + row_count <- 1 + count <- 1 + + for (i in names(model_result)) { + if (i == "etr_type" || i == "etr_regression_data") { + next() + } + + value <- model_result[[i]] + + if (is.null(row)) { + row <- data.frame(tmp = NA) + } + + row[[i]] <- c(value) + + if (count == entries_per_row) { + row$tmp <- NULL + tbl_list[[row_count]] <- gridExtra::tableGrob( + row, + rows = NULL, + theme = custom_theme + ) + + row <- NULL + row_count <- row_count + 1 + count <- 1 + } else { + count <- count + 1 + } + } + + if (is.null(row) == FALSE) { + row$tmp <- NULL + tbl_list[[row_count]] <- gridExtra::tableGrob( + row, + rows = NULL, + theme = custom_theme + ) + } + + tbl <- cowplot::plot_grid( + plotlist = tbl_list, + ncol = 1 + ) + return(tbl) +} + +#' @title Plot Control +#' @description This function creates a control plot for the used model based on the provided data and model results. +#' +#' @param data A `data.table` containing the original ETR and yield data for the plot. +#' @param model_result A list containing the fitting results of the used model and the calculated parameters. +#' @param title A character string that specifies the title of the plot. +#' @param color A color specification for the regression line in the plot. +#' +#' @details +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#plot_control} +#' +#' @return A plot displaying the original ETR and Yield values and the regression data. A table below the plot shows the calculated data. +#' +#' @examples +#' path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") +#' data <- read_dual_pam_data(path) +#' +#' result <- eilers_peeters_generate_regression_ETR_I(data) +#' plot_control(data, result, "Control Plot") +#' +#' @export +plot_control <- function( + data, + model_result, + title, + color = "black" +) { + validate_intermediate_data(data) + validate_model_result(model_result) + + etr_type <- get_etr_type_from_model_result(model_result) + validate_etr_type(etr_type) + + yield <- NA_real_ + yield_name <- "" + if (etr_type == etr_1_type) { + yield <- "yield_1" + yield_name <- "Y(I)" + } else { + yield <- "yield_2" + yield_name <- "Y(II)" + } + + etr_regression_data <- get_etr_regression_data_from_model_result(model_result) + validate_etr_regression_data(etr_regression_data) + + max_etr <- max(etr_regression_data$prediction) + + plot <- ggplot2::ggplot(data, ggplot2::aes(x = data$par, y = get(etr_type))) + + ggplot2::geom_point() + + ggplot2::geom_line( + data = etr_regression_data, + ggplot2::aes( + x = etr_regression_data$par, + y = etr_regression_data$prediction + ), + color = color + ) + + ggplot2::geom_point(data = data, shape = 17, ggplot2::aes(y = get(yield) * max_etr)) + + ggplot2::geom_line(data = data, ggplot2::aes(y = get(yield) * max_etr)) + + ggplot2::labs(x = par_label, y = etr_label, title = eval(title)) + + ggplot2::scale_y_continuous( + sec.axis = ggplot2::sec_axis(~ . / max_etr, name = yield_name) + ) + + ggthemes::theme_base() + + ggplot2::theme( + plot.background = ggplot2::element_rect(fill = "white", color = NA), + panel.background = ggplot2::element_rect(fill = "white", color = NA) + ) + + + tbl <- plot_table(model_result, 4) + + plot <- cowplot::plot_grid( + plot, + tbl, + ncol = 1, + rel_heights = c(0.7, 0.3) + ) + return(plot) +} + +create_modified_model_result <- function( + etr_type, + etr_regression_data, + residual_sum_of_squares, + root_mean_squared_error, + relative_root_mean_squared_error, + a, + b, + c, + d, + alpha, + beta, + etrmax_with_photoinhibition, + etrmax_without_photoinhibition, + ik_with_photoinhibition, + ik_without_photoinhibition, + im_with_photoinhibition, + w, + ib, + etrmax_without_with_ratio +) { + result <- list( + etr_type = etr_type, + etr_regression_data = etr_regression_data, + residual_sum_of_squares = residual_sum_of_squares, + root_mean_squared_error = root_mean_squared_error, + relative_root_mean_squared_error = relative_root_mean_squared_error, + a = a, + b = b, + c = c, + d = d, + alpha = alpha, + beta = beta, + etrmax_with_photoinhibition = etrmax_with_photoinhibition, + etrmax_without_photoinhibition = etrmax_without_photoinhibition, + ik_with_photoinhibition = ik_with_photoinhibition, + ik_without_photoinhibition = ik_without_photoinhibition, + im_with_photoinhibition = im_with_photoinhibition, + w = w, + ib = ib, + etrmax_without_with_ratio = etrmax_without_with_ratio + ) + validate_modified_model_result(result) + return(result) +} diff --git a/src/R/read_pam_data.R b/src/R/read_pam_data.R deleted file mode 100644 index 5b76d2c..0000000 --- a/src/R/read_pam_data.R +++ /dev/null @@ -1,732 +0,0 @@ -#' Read and Process Universal PAM Data -#' -#' Reads a standardized CSV file containing PAR and yield data for photosystem I and/or II, calculates electron transport rates (ETR), and returns a cleaned and validated dataset. The function is device-agnostic but requires a predefined column structure. -#' -#' @param csv_path File path to the CSV file. -#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. -#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR -#' to photosystem I. Default is \code{0.5}. -#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR -#' to photosystem II. Default is \code{0.5}. -#' -#' @details -#' Calculates ETR using: -#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I or II)} \cdot \text{Yield (I or II)}} -#' -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_universal_data} -#' -#' @return A \code{data.table} containing: -#' \itemize{ -#' \item \code{par}: Photosynthetically active radiation. -#' \item \code{yield_1}: Yield for photosystem I. -#' \item \code{yield_2}: Yield for photosystem II. -#' \item \code{etr_1}: Calculated ETR for photosystem I. -#' \item \code{etr_2}: Calculated ETR for photosystem II. -#' } -#' -#' @references{ -#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} -#' Heinz Walz GmbH, Effeltrich, Germany. -#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -#' } -#' @examples -#' path <- file.path(system.file("extdata", package = "pam"), "universal_data", "universal_data.csv") -#' data <- read_universal_data(path) -#' @export -read_universal_data <- function(csv_path, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5) { - if (fraction_photosystem_I + fraction_photosystem_II != 1) { - stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") - } - - data <- utils::read.csv(csv_path, sep = ";", dec = ".") - data <- data.table::as.data.table(data) - validate_raw_intermediate_csv(data) - - result <- data.table::data.table( - par = numeric(), - yield_1 = numeric(), - yield_2 = numeric(), - etr_1 = numeric(), - etr_2 = numeric() - ) - for (i in seq_len(nrow(data))) { - row <- data[i, ] - current_par <- row$par - - yield_1 <- row$yield_1 - recalc_etr_1 <- calc_etr(yield_1, current_par, etr_factor, fraction_photosystem_I) - - yield_2 <- row$yield_2 - recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) - - new_row <- list( - par = current_par, - yield_1 = yield_1, - yield_2 = yield_2, - etr_1 = recalc_etr_1, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - } - - validate_data(result) - return(result) -} - -#' Read and Process DualPAM Data -#' -#' Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values, and returns a universal dataset. -#' -#' @param csv_path File path to the CSV file. -#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. -#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. -#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. -#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. -#' -#' @details -#' Calculates ETR using: -#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I or II)} \cdot \text{Yield (I or II)}} -#' -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} -#' -#' @return A \code{data.table} containing: -#' \itemize{ -#' \item \code{par}: Photosynthetically active radiation. -#' \item \code{yield_1}: Yield for photosystem I. -#' \item \code{yield_2}: Yield for photosystem II. -#' \item \code{etr_1}: Calculated ETR for photosystem I. -#' \item \code{etr_2}: Calculated ETR for photosystem II. -#' } -#' -#' @references{ -#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} -#' Heinz Walz GmbH, Effeltrich, Germany. -#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -#' } -#' @examples -#' path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") -#' data <- read_dual_pam_data(path) -#' @export -read_dual_pam_data <- function( - csv_path, - remove_recovery = TRUE, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5 -) { - if (fraction_photosystem_I + fraction_photosystem_II != 1) { - stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") - } - - tryCatch( - { - data <- utils::read.csv(csv_path, sep = ";", dec = ".") - data <- data.table::as.data.table(data) - - validate_dual_pam_data(data) - data <- data[data$ID == "SP", ] - - date_time_col_values <- c() - for (i in seq_len(nrow(data))) { - row <- data[i, ] - - date_time_row_value <- as.POSIXct( - paste(row$Date, row$Time, sep = " "), - tz = "GMT", "%d.%m.%y %H:%M:%S" - ) - date_time_col_values <- c(date_time_col_values, date_time_row_value) - } - - data$DateTime <- date_time_col_values - data <- data[order(data$DateTime), ] - - pm_det_row <- subset(data, data$PAR == 0 & data$Action == "Pm.-Det.") - yield_1_first <- pm_det_row$Y.I. - recalc_etr_1 <- calc_etr(yield_1_first, 0, etr_factor, fraction_photosystem_I) - - fm_det_row <- subset(data, data$PAR == 0 & data$Action == "Fm-Det.") - yield_2_first <- fm_det_row$Y.II. - recalc_etr_2 <- calc_etr(yield_2_first, 0, etr_factor, fraction_photosystem_II) - - - result <- data.table::data.table( - par = numeric(), - yield_1 = numeric(), - yield_2 = numeric(), - etr_1 = numeric(), - etr_2 = numeric() - ) - new_row <- list( - par = 0, - yield_1 = yield_1_first, - yield_2 = yield_2_first, - etr_1 = recalc_etr_1, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - - last_par <- as.numeric(0) - for (i in seq_len(nrow(data))) { - row <- data[i, ] - current_par <- row$PAR - - if (row$Action != "P.+F. SP") { - next - } - - if (remove_recovery && last_par != 0 && current_par < last_par) { - break - } - - yield_1 <- row$Y.I. - recalc_etr_1 <- calc_etr(yield_1, current_par, etr_factor, fraction_photosystem_I) - - yield_2 <- row$Y.II. - recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) - - new_row <- list( - par = current_par, - yield_1 = yield_1, - yield_2 = yield_2, - etr_1 = recalc_etr_1, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - - last_par <- current_par - } - - validate_data(result) - return(result) - }, - warning = function(w) { - stop("Warning in file: ", csv_path, " Warning: ", w) - }, - error = function(e) { - stop("Error in file: ", csv_path, " Error: ", e) - } - ) -} - -#' Read and Process DualPAM Data Single Chanel Mode P700 -#' -#' Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values for Photosystem I, and returns a universal dataset. -#' -#' @param csv_path File path to the CSV file. -#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. -#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. -#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. -#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. -#' -#' @details -#' Calculates ETR using: -#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I)} \cdot \text{Yield (I)}} -#' -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} -#' -#' @return A \code{data.table} containing: -#' \itemize{ -#' \item \code{par}: Photosynthetically active radiation. -#' \item \code{yield_1}: Yield for photosystem I -#' \item \code{yield_2}: NA -#' \item \code{etr_1}: Calculated ETR for photosystem I -#' \item \code{etr_2}: NA -#' } -#' -#' @references{ -#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} -#' Heinz Walz GmbH, Effeltrich, Germany. -#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -#' } -#' @examples -#' path <- file.path( -#' system.file("extdata/dual_pam_single_channel_p700_data", package = "pam"), -#' "20260130_01_efeutute_dual_pam_only_p700.csv" -#' ) -#' data <- read_dual_pam_single_channel_p700_data(path) -#' @export -read_dual_pam_single_channel_p700_data <- function( - csv_path, - remove_recovery = TRUE, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5 -) { - if (fraction_photosystem_I + fraction_photosystem_II != 1) { - stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") - } - - tryCatch( - { - data <- utils::read.csv(csv_path, sep = ";", dec = ".") - data <- data.table::as.data.table(data) - - validate_dual_pam_single_channel_p700_data(data) - data <- data[data$ID == "SP", ] - - date_time_col_values <- c() - for (i in seq_len(nrow(data))) { - row <- data[i, ] - - date_time_row_value <- as.POSIXct( - paste(row$Date, row$Time, sep = " "), - tz = "GMT", "%d.%m.%y %H:%M:%S" - ) - date_time_col_values <- c(date_time_col_values, date_time_row_value) - } - - data$DateTime <- date_time_col_values - data <- data[order(data$DateTime), ] - - pm_det_row <- subset(data, data$PAR == 0 & data$Action == "Pm.-Det.") - yield_1_first <- pm_det_row$Y.I. - recalc_etr_1 <- calc_etr(yield_1_first, 0, etr_factor, fraction_photosystem_I) - - - result <- data.table::data.table( - par = numeric(), - yield_1 = numeric(), - yield_2 = numeric(), - etr_1 = numeric(), - etr_2 = numeric() - ) - new_row <- list( - par = 0, - yield_1 = yield_1_first, - yield_2 = NA_real_, - etr_1 = recalc_etr_1, - etr_2 = NA_real_ - ) - result <- rbind(result, new_row) - - last_par <- as.numeric(0) - for (i in seq_len(nrow(data))) { - row <- data[i, ] - current_par <- row$PAR - - if (row$Action != "P700 SP") { - next - } - - if (remove_recovery && last_par != 0 && current_par < last_par) { - break - } - - yield_1 <- row$Y.I. - recalc_etr_1 <- calc_etr(yield_1, current_par, etr_factor, fraction_photosystem_I) - - new_row <- list( - par = current_par, - yield_1 = yield_1, - yield_2 = NA_real_, - etr_1 = recalc_etr_1, - etr_2 = NA_real_ - ) - result <- rbind(result, new_row) - - last_par <- current_par - } - - validate_data(result) - return(result) - }, - warning = function(w) { - stop("Warning in file: ", csv_path, " Warning: ", w) - }, - error = function(e) { - stop("Error in file: ", csv_path, " Error: ", e) - } - ) -} - -#' Read and Process DualPAM Data Single Chanel Mode Fluo -#' -#' Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values for Photosystem II, and returns a universal dataset. -#' -#' @param csv_path File path to the CSV file. -#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. -#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. -#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. -#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. -#' -#' @details -#' Calculates ETR using: -#' \deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (II)} \cdot \text{Yield (II)}} -#' -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} -#' -#' @return A \code{data.table} containing: -#' \itemize{ -#' \item \code{par}: Photosynthetically active radiation. -#' \item \code{yield_1}: NA -#' \item \code{yield_2}: Yield for photosystem II. -#' \item \code{etr_1}: NA -#' \item \code{etr_2}: Calculated ETR for photosystem II. -#' } -#' -#' @references{ -#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} -#' Heinz Walz GmbH, Effeltrich, Germany. -#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -#' } -#' @examples -#' path <- file.path( -#' system.file("extdata/dual_pam_single_channel_fluo_data", package = "pam"), -#' "20260130_efeutute_dual_pam_only_fluo.csv" -#' ) -#' data <- read_dual_pam_single_channel_fluo_data(path) -#' @export -read_dual_pam_single_channel_fluo_data <- function( - csv_path, - remove_recovery = TRUE, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5 -) { - if (fraction_photosystem_I + fraction_photosystem_II != 1) { - stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") - } - - tryCatch( - { - data <- utils::read.csv(csv_path, sep = ";", dec = ".") - data <- data.table::as.data.table(data) - - validate_dual_pam_single_channel_fluo_data(data) - data <- data[data$ID == "SP", ] - - date_time_col_values <- c() - for (i in seq_len(nrow(data))) { - row <- data[i, ] - - date_time_row_value <- as.POSIXct( - paste(row$Date, row$Time, sep = " "), - tz = "GMT", "%d.%m.%y %H:%M:%S" - ) - date_time_col_values <- c(date_time_col_values, date_time_row_value) - } - - data$DateTime <- date_time_col_values - data <- data[order(data$DateTime), ] - - fm_det_row <- subset(data, data$PAR == 0 & data$Action == "Fm-Det.") - yield_2_first <- fm_det_row$Y.II. - recalc_etr_2 <- calc_etr( - yield_2_first, 0, etr_factor, fraction_photosystem_II - ) - - - result <- data.table::data.table( - par = numeric(), - yield_1 = numeric(), - yield_2 = numeric(), - etr_1 = numeric(), - etr_2 = numeric() - ) - new_row <- list( - par = 0, - yield_1 = NA_real_, - yield_2 = yield_2_first, - etr_1 = NA_real_, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - - last_par <- as.numeric(0) - for (i in seq_len(nrow(data))) { - row <- data[i, ] - current_par <- row$PAR - - if (row$Action != "Fluo. SP") { - next - } - - if (remove_recovery && last_par != 0 && current_par < last_par) { - break - } - - yield_2 <- row$Y.II. - recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) - - new_row <- list( - par = current_par, - yield_1 = NA_real_, - yield_2 = yield_2, - etr_1 = NA_real_, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - - last_par <- current_par - } - - validate_data(result) - return(result) - }, - warning = function(w) { - stop("Warning in file: ", csv_path, " Warning: ", w) - }, - error = function(e) { - stop("Error in file: ", csv_path, " Error: ", e) - } - ) -} - -calc_etr <- function(yield, par, etr_factor, p_ratio) { - if (is.na(yield)) { - return(NA_real_) - } - - if (!is.numeric(yield)) { - stop("yield is not numeric") - } - - if (!is.numeric(par)) { - stop("par is not numeric") - } - - if (!is.numeric(etr_factor)) { - stop("etr_factor is not numeric") - } - - if (!is.numeric(p_ratio)) { - stop("p_ratio is not numeric") - } - - return(yield * par * etr_factor * p_ratio) -} - -#' Read and Process Junior PAM Data -#' -#' Reads raw CSV files generated by Junior PAM software, calculates electron transport rate (ETR) values, and returns a cleaned dataset. -#' -#' @param csv_path File path to the CSV file. -#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. -#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. -#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. -#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. -#' -#' @details -#' Calculates ETR II using: -#' \deqn{\text{ETR II} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (II)} \cdot \text{Yield (II)}} -#' -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file} -#' -#' @return A \code{data.table} containing: -#' \itemize{ -#' \item \code{par}: Photosynthetically active radiation. -#' \item \code{yield_1}: Yield for photosystem I. -#' \item \code{yield_2}: Yield for photosystem II. -#' \item \code{etr_1}: Calculated ETR for photosystem I. -#' \item \code{etr_2}: Calculated ETR for photosystem II. -#' } -#' -#' @references{ -#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} -#' Heinz Walz GmbH, Effeltrich, Germany. -#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -#' } -#' @examples -#' path <- file.path( -#' system.file("extdata/junior_pam_data", package = "pam"), -#' "junior_pam_20250613.csv" -#' ) -#' data <- read_junior_pam_data(path) -#' @export -read_junior_pam_data <- function( - csv_path, - remove_recovery = TRUE, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5 -) { - if (fraction_photosystem_I + fraction_photosystem_II != 1) { - stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") - } - - tryCatch( - { - data <- utils::read.csv(csv_path, sep = ";", dec = ".", skip = 1, header = TRUE) - data <- data.table::as.data.table(data) - - validate_junior_pam_data(data) - - par_col <- grep("PAR", names(data), value = TRUE) - if (length(par_col) == 1 && par_col != "PAR") { - data.table::setnames(data, old = par_col, new = "PAR") - } - - yield_2_col <- grep("Y..II.", names(data), value = TRUE) - if (length(yield_2_col) == 1 && yield_2_col != "Y..II.") { - data.table::setnames(data, old = yield_2_col, new = "Y.II.") - } - - data <- data[data$Type == "FO" | data$Type == "F", ] - data$Datetime <- as.POSIXct(data$Datetime, format = "%Y-%m-%d %H:%M:%OS", tz = "GMT") - - date_time_col_values <- c() - for (i in seq_len(nrow(data))) { - row <- data[i, ] - - date_time_row_value <- as.POSIXct( - paste(row$Date, row$Time, sep = " "), - tz = "GMT", "%d.%m.%y %H:%M:%S" - ) - date_time_col_values <- c(date_time_col_values, date_time_row_value) - } - data$DateTime <- date_time_col_values - data <- data[order(data$Datetime), ] - - result <- data.table::data.table( - par = numeric(), - yield_1 = numeric(), - yield_2 = numeric(), - etr_1 = numeric(), - etr_2 = numeric() - ) - last_par <- as.numeric(0) - for (i in seq_len(nrow(data))) { - row <- data[i, ] - current_par <- row$PAR - - if (remove_recovery && last_par != 0 && current_par < last_par) { - break - } - - yield_2 <- row$Y.II. - recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) - - new_row <- list( - par = current_par, - yield_1 = NA_real_, - yield_2 = yield_2, - etr_1 = NA_real_, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - - last_par <- current_par - } - - return(result) - }, - warning = function(w) { - stop("Warning in file: ", csv_path, " Warning: ", w) - }, - error = function(e) { - stop("Error in file: ", csv_path, " Error: ", e) - } - ) -} - -#' Read and Process PAM 2500 Data -#' -#' Reads raw CSV files generated by PAM 2500 software, calculates electron transport rate (ETR) values, and returns a cleaned dataset. -#' -#' @param csv_path File path to the CSV file. -#' @param remove_recovery Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}. -#' @param etr_factor Numeric. Factor for ETR calculation. Default is \code{0.84}. -#' @param fraction_photosystem_I Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}. -#' @param fraction_photosystem_II Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}. -#' -#' @details -#' Calculates ETR II using: -#' \deqn{\text{ETR II} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (II)} \cdot \text{Yield (II)}} -#' -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file} -#' -#' @return A \code{data.table} containing: -#' \itemize{ -#' \item \code{par}: Photosynthetically active radiation. -#' \item \code{yield_1}: Yield for photosystem I. -#' \item \code{yield_2}: Yield for photosystem II. -#' \item \code{etr_1}: Calculated ETR for photosystem I. -#' \item \code{etr_2}: Calculated ETR for photosystem II. -#' } -#' -#' @references{ -#' Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} -#' Heinz Walz GmbH, Effeltrich, Germany. -#' Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -#' } -#' @examples -#' path <- file.path(system.file("extdata/pam_2500_data", package = "pam"), "20260311_1(2).CSV") -#' data <- read_pam_2500_data(path) -#' @export -read_pam_2500_data <- function( - csv_path, - remove_recovery = TRUE, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5 -) { - if (fraction_photosystem_I + fraction_photosystem_II != 1) { - stop("The sum of fraction_photosystem_I and fraction_photosystem_II must be equal 1.") - } - - tryCatch( - { - data <- utils::read.csv(csv_path, sep = ";", dec = ".") - data <- data.table::as.data.table(data) - - validate_pam_2500_data(data) - data <- data[grepl("^\\d+$", data$`No.`), ] - - date_time_col_values <- c() - for (i in seq_len(nrow(data))) { - row <- data[i, ] - - date_time_row_value <- as.POSIXct( - paste(row$Date, row$Time, sep = " "), - tz = "GMT", "%d.%m.%y %H:%M:%S" - ) - date_time_col_values <- c(date_time_col_values, date_time_row_value) - } - - data$DateTime <- date_time_col_values - data <- data[order(data$DateTime), ] - - result <- data.table::data.table( - par = numeric(), - yield_1 = numeric(), - yield_2 = numeric(), - etr_1 = numeric(), - etr_2 = numeric() - ) - last_par <- as.numeric(0) - for (i in seq_len(nrow(data))) { - row <- data[i, ] - current_par <- row$PAR - - if (remove_recovery && last_par != 0 && current_par < last_par) { - break - } - - yield_2 <- row$Y.II. - recalc_etr_2 <- calc_etr(yield_2, current_par, etr_factor, fraction_photosystem_II) - - new_row <- list( - par = current_par, - yield_1 = NA_real_, - yield_2 = yield_2, - etr_1 = NA_real_, - etr_2 = recalc_etr_2 - ) - result <- rbind(result, new_row) - - last_par <- current_par - } - - return(result) - }, - warning = function(w) { - stop("Warning in file: ", csv_path, " Warning: ", w) - }, - error = function(e) { - stop("Error in file: ", csv_path, " Error: ", e) - } - ) -} diff --git a/src/R/util.R b/src/R/util.R index 1afb041..852dc93 100644 --- a/src/R/util.R +++ b/src/R/util.R @@ -30,291 +30,8 @@ get_residual_sum_of_squares_from_model_result <- function(model_result) { return(model_result[["residual_sum_of_squares"]]) } -plot_table <- function(model_result, entries_per_row) { - validate_model_result(model_result) - - custom_theme <- gridExtra::ttheme_minimal( - core = list( - fg_params = list( - cex = 0.7, - fontface = 3 - ), - bg_params = list( - fill = "lightgray", - col = "black" - ) - ), # font size for cell text - colhead = list( - fg_params = list(cex = 0.7), - bg_params = list( - fill = "lightgray", - col = "black" - ) - ), # font size for column headers - rowhead = list( - fg_params = list(cex = 0.7), - bg_params = list( - fill = "lightgray", - col = "black" - ) - ), # font size for row headers - ) - - tbl_list <- list() - row <- NULL - - row_count <- 1 - count <- 1 - - for (i in names(model_result)) { - if (i == "etr_type" || i == "etr_regression_data") { - next() - } - - value <- model_result[[i]] - - if (is.null(row)) { - row <- data.frame(tmp = NA) - } - - row[[i]] <- c(value) - - if (count == entries_per_row) { - row$tmp <- NULL - tbl_list[[row_count]] <- gridExtra::tableGrob( - row, - rows = NULL, - theme = custom_theme - ) - - row <- NULL - row_count <- row_count + 1 - count <- 1 - } else { - count <- count + 1 - } - } - - if (is.null(row) == FALSE) { - row$tmp <- NULL - tbl_list[[row_count]] <- gridExtra::tableGrob( - row, - rows = NULL, - theme = custom_theme - ) - } - - tbl <- cowplot::plot_grid( - plotlist = tbl_list, - ncol = 1 - ) - return(tbl) -} - -#' @title Plot Control -#' @description This function creates a control plot for the used model based on the provided data and model results. -#' -#' @param data A `data.table` containing the original ETR and yield data for the plot. -#' @param model_result A list containing the fitting results of the used model and the calculated parameters. -#' @param title A character string that specifies the title of the plot. -#' @param color A color specification for the regression line in the plot. -#' -#' @details -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#plot_control} -#' -#' @return A plot displaying the original ETR and Yield values and the regression data. A table below the plot shows the calculated data. -#' -#' @examples -#' path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") -#' data <- read_dual_pam_data(path) -#' -#' result <- eilers_peeters_generate_regression_ETR_I(data) -#' plot_control(data, result, "Control Plot") -#' -#' @export -plot_control <- function( - data, - model_result, - title, - color = "black") { - validate_data(data) - validate_model_result(model_result) - - etr_type <- get_etr_type_from_model_result(model_result) - validate_etr_type(etr_type) - - yield <- NA_real_ - yield_name <- "" - if (etr_type == etr_1_type) { - yield <- "yield_1" - yield_name <- "Y(I)" - } else { - yield <- "yield_2" - yield_name <- "Y(II)" - } - - etr_regression_data <- get_etr_regression_data_from_model_result(model_result) - validate_etr_regression_data(etr_regression_data) - - max_etr <- max(etr_regression_data$prediction) - - plot <- ggplot2::ggplot(data, ggplot2::aes(x = data$par, y = get(etr_type))) + - ggplot2::geom_point() + - ggplot2::geom_line( - data = etr_regression_data, - ggplot2::aes( - x = etr_regression_data$par, - y = etr_regression_data$prediction - ), - color = color - ) + - ggplot2::geom_point(data = data, shape = 17, ggplot2::aes(y = get(yield) * max_etr)) + - ggplot2::geom_line(data = data, ggplot2::aes(y = get(yield) * max_etr)) + - ggplot2::labs(x = par_label, y = etr_label, title = eval(title)) + - ggplot2::scale_y_continuous( - sec.axis = ggplot2::sec_axis(~ . / max_etr, name = yield_name) - ) + - ggthemes::theme_base() + - ggplot2::theme( - plot.background = ggplot2::element_rect(fill = "white", color = NA), - panel.background = ggplot2::element_rect(fill = "white", color = NA) - ) - - - tbl <- plot_table(model_result, 4) - - plot <- cowplot::plot_grid( - plot, - tbl, - ncol = 1, - rel_heights = c(0.7, 0.3) - ) - return(plot) -} - -create_modified_model_result <- function( - etr_type, - etr_regression_data, - residual_sum_of_squares, - root_mean_squared_error, - relative_root_mean_squared_error, - a, - b, - c, - d, - alpha, - beta, - etrmax_with_photoinhibition, - etrmax_without_photoinhibition, - ik_with_photoinhibition, - ik_without_photoinhibition, - im_with_photoinhibition, - w, - ib, - etrmax_without_with_ratio) { - result <- list( - etr_type = etr_type, - etr_regression_data = etr_regression_data, - residual_sum_of_squares = residual_sum_of_squares, - root_mean_squared_error = root_mean_squared_error, - relative_root_mean_squared_error = relative_root_mean_squared_error, - a = a, - b = b, - c = c, - d = d, - alpha = alpha, - beta = beta, - etrmax_with_photoinhibition = etrmax_with_photoinhibition, - etrmax_without_photoinhibition = etrmax_without_photoinhibition, - ik_with_photoinhibition = ik_with_photoinhibition, - ik_without_photoinhibition = ik_without_photoinhibition, - im_with_photoinhibition = im_with_photoinhibition, - w = w, - ib = ib, - etrmax_without_with_ratio = etrmax_without_with_ratio - ) - validate_modified_model_result(result) - return(result) -} - -#' Write Model Result CSV -#' @description -#' This function exports the intermediate data table, regression data, and model parameters into separate CSV files for easy access and further analysis. -#' -#' @param dest_dir A character string specifying the directory where the CSV files will be saved. -#' @param name A character string specifying the base name for the output files. -#' @param data A data.table containing the intermediate data used in the model. -#' @param model_result A list containing the model results, including parameter values and regression data. -#' -#' @details -#' This function generates three CSV files: -#' \enumerate{ -#' \item \strong{raw_data.csv:} Contains the original raw data used in the model. -#' \item \strong{regression_data.csv:} Includes the regression data with predicted electron transport rate (ETR) values. -#' \item \strong{model_result.csv:} Summarizes the parameter values derived from the model results (excluding regression data), such as \code{alpha} or \code{beta}. -#' } -#' The `name` parameter serves as a prefix for each file, ensuring clarity and organization in the output directory. -#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#write_model_result_csv} -#' -#' @return No return value, called for side effects -#' -#' @examples -#' path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") -#' data <- read_dual_pam_data(path) -#' -#' result <- eilers_peeters_generate_regression_ETR_I(data) -#' write_model_result_csv(tempdir(), "20240925", data, result) -#' -#' @export -write_model_result_csv <- function(dest_dir, name, data, model_result) { - data_dest <- file.path(dest_dir, paste(name, "_raw_data.csv", sep = "")) - regression_data_dest <- file.path(dest_dir, paste(name, "_regression_data.csv", sep = "")) - model_result_dest <- file.path(dest_dir, paste(name, "_model_result.csv", sep = "")) - - utils::write.csv( - data, - file = data_dest, - quote = TRUE, - row.names = FALSE - ) - - utils::write.csv( - get_etr_regression_data_from_model_result(model_result), - file = regression_data_dest, - quote = TRUE, - row.names = FALSE - ) - - df <- data.frame() - df[1, ] <- NA - - for (n in names(model_result)) { - if (n == "etr_regression_data" || n == "etr_type") { - next() - } - - entry <- data.frame( - stats::setNames( - list( - c(model_result[[n]]) - ), - c(n) - ) - ) - - df <- cbind(df, NewCol = entry) - } - - utils::write.csv( - df, - file = model_result_dest, - quote = TRUE, - row.names = FALSE - ) -} - get_etr_data_for_par_values <- function(data, etr_regression_data, etr_type) { - validate_data(data) + validate_intermediate_data(data) validate_etr_regression_data(etr_regression_data) validate_etr_type(etr_type) @@ -345,3 +62,27 @@ relative_root_mean_squared_error <- function(measured_predicted_etr_data) { relative_root_mean_squared_error <- root_mean_squared_error / mean(predicted_etr) return(relative_root_mean_squared_error) } + +calc_etr <- function(yield, par, etr_factor, p_ratio) { + if (is.na(yield)) { + return(NA_real_) + } + + if (!is.numeric(yield)) { + stop("yield is not numeric") + } + + if (!is.numeric(par)) { + stop("par is not numeric") + } + + if (!is.numeric(etr_factor)) { + stop("etr_factor is not numeric") + } + + if (!is.numeric(p_ratio)) { + stop("p_ratio is not numeric") + } + + return(yield * par * etr_factor * p_ratio) +} diff --git a/src/R/validation.R b/src/R/validation.R index 85a7639..cd45ac3 100644 --- a/src/R/validation.R +++ b/src/R/validation.R @@ -1,4 +1,4 @@ -validate_data <- function(data) { +validate_intermediate_data <- function(data) { if (is.null(data)) { stop("data is null") } @@ -28,7 +28,7 @@ validate_data <- function(data) { } } -validate_raw_intermediate_csv <- function(data) { +validate_data_not_empty <- function(data) { if (is.null(data)) { stop("data is null") } @@ -37,227 +37,13 @@ validate_raw_intermediate_csv <- function(data) { stop("data is not a valid data.table") } - if (!"par" %in% colnames(data)) { - stop("required col 'par' not found") - } - - if (!"yield_1" %in% colnames(data)) { - stop("required col 'yield_1' not found") - } - - if (!"yield_2" %in% colnames(data)) { - stop("required col 'yield_2' not found") - } -} - -validate_dual_pam_data <- function(data) { - if (is.null(data)) { - stop("data is null") - } - - if (!data.table::is.data.table(data)) { - stop("data is not a valid data.table") - } - - if (nrow(data) < 2) { - stop("no data rows") + if (nrow(data) == 0) { + stop("no rows in data") } if (ncol(data) == 0) { stop("no cols in data") } - - if (!"ID" %in% colnames(data)) { - stop("required col 'ID' not found") - } - - if (!"PAR" %in% colnames(data)) { - stop("required col 'PAR' not found") - } - - if (!"Y.I." %in% colnames(data) && !"Y.II." %in% colnames(data)) { - stop("required col 'Y(I)' and 'Y(II)' not found") - } - - if (!"Action" %in% colnames(data)) { - stop("required col 'Action' not found") - } - - if (!"Date" %in% colnames(data)) { - stop("required col 'Date' not found") - } - - if (!"Time" %in% colnames(data)) { - stop("required col 'Time' not found") - } - - if (!"Pm.-Det." %in% data[["Action"]]) { - stop("required value 'Pm' not found in column 'Action'") - } - - if (!"Fm-Det." %in% data[["Action"]]) { - stop("required value 'Fm' not found in column 'Action'") - } -} - -validate_dual_pam_single_channel_p700_data <- function(data) { - if (is.null(data)) { - stop("data is null") - } - - if (!data.table::is.data.table(data)) { - stop("data is not a valid data.table") - } - - if (nrow(data) < 2) { - stop("no data rows") - } - - if (ncol(data) == 0) { - stop("no cols in data") - } - - if (!"ID" %in% colnames(data)) { - stop("required col 'ID' not found") - } - - if (!"PAR" %in% colnames(data)) { - stop("required col 'PAR' not found") - } - - if (!"Y.I." %in% colnames(data)) { - stop("required col 'Y(I)' not found") - } - - if (!"Action" %in% colnames(data)) { - stop("required col 'Action' not found") - } - - if (!"Date" %in% colnames(data)) { - stop("required col 'Date' not found") - } - - if (!"Time" %in% colnames(data)) { - stop("required col 'Time' not found") - } - - if (!"Pm.-Det." %in% data[["Action"]]) { - stop("required value 'Pm.-Det.' not found in column 'Action'") - } -} - -validate_dual_pam_single_channel_fluo_data <- function(data) { - if (is.null(data)) { - stop("data is null") - } - - if (!data.table::is.data.table(data)) { - stop("data is not a valid data.table") - } - - if (nrow(data) < 2) { - stop("no data rows") - } - - if (ncol(data) == 0) { - stop("no cols in data") - } - - if (!"ID" %in% colnames(data)) { - stop("required col 'ID' not found") - } - - if (!"PAR" %in% colnames(data)) { - stop("required col 'PAR' not found") - } - - if (!"Y.II." %in% colnames(data)) { - stop("required col 'Y(II)' not found") - } - - if (!"Action" %in% colnames(data)) { - stop("required col 'Action' not found") - } - - if (!"Date" %in% colnames(data)) { - stop("required col 'Date' not found") - } - - if (!"Time" %in% colnames(data)) { - stop("required col 'Time' not found") - } - - if (!"Fm-Det." %in% data[["Action"]]) { - stop("required value 'Fm' not found in column 'Action'") - } -} - -validate_junior_pam_data <- function(data) { - if (is.null(data)) { - stop("data is null") - } - - if (!data.table::is.data.table(data)) { - stop("data is not a valid data.table") - } - - if (nrow(data) < 2) { - stop("no data rows") - } - - if (ncol(data) == 0) { - stop("no cols in data") - } - - if (!any(grepl("PAR", colnames(data)))) { - stop("required col 'PAR' not found") - } - - if (!any(grepl("Y..II.", colnames(data)))) { - stop("required col 'Y..II.' not found") - } - - if (!"Datetime" %in% colnames(data)) { - stop("required col 'Datetime' not found") - } -} - -validate_pam_2500_data <- function(data) { - if (is.null(data)) { - stop("data is null") - } - - if (!data.table::is.data.table(data)) { - stop("data is not a valid data.table") - } - - if (nrow(data) < 2) { - stop("no data rows") - } - - if (ncol(data) == 0) { - stop("no cols in data") - } - - if (!"No." %in% colnames(data)) { - stop("required col 'No.' not found") - } - - if (!"PAR" %in% colnames(data)) { - stop("required col 'PAR' not found") - } - - if (!"Date" %in% colnames(data)) { - stop("required col 'Date' not found") - } - - if (!"Time" %in% colnames(data)) { - stop("required col 'Time' not found") - } - - if (!"Y.II." %in% colnames(data)) { - stop("required col 'Y(II)' not found") - } } validate_etr_regression_data <- function(regression_data) { diff --git a/src/R/write_model_result_csv.R b/src/R/write_model_result_csv.R new file mode 100644 index 0000000..9331646 --- /dev/null +++ b/src/R/write_model_result_csv.R @@ -0,0 +1,75 @@ +#' Write Model Result CSV +#' @description +#' This function exports the intermediate data table, regression data, and model parameters into separate CSV files for easy access and further analysis. +#' +#' @param dest_dir A character string specifying the directory where the CSV files will be saved. +#' @param name A character string specifying the base name for the output files. +#' @param data A data.table containing the intermediate data used in the model. +#' @param model_result A list containing the model results, including parameter values and regression data. +#' +#' @details +#' This function generates three CSV files: +#' \enumerate{ +#' \item \strong{raw_data.csv:} Contains the original raw data used in the model. +#' \item \strong{regression_data.csv:} Includes the regression data with predicted electron transport rate (ETR) values. +#' \item \strong{model_result.csv:} Summarizes the parameter values derived from the model results (excluding regression data), such as \code{alpha} or \code{beta}. +#' } +#' The `name` parameter serves as a prefix for each file, ensuring clarity and organization in the output directory. +#' A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#write_model_result_csv} +#' +#' @return No return value, called for side effects +#' +#' @examples +#' path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") +#' data <- read_dual_pam_data(path) +#' +#' result <- eilers_peeters_generate_regression_ETR_I(data) +#' write_model_result_csv(tempdir(), "20240925", data, result) +#' +#' @export +write_model_result_csv <- function(dest_dir, name, data, model_result) { + data_dest <- file.path(dest_dir, paste(name, "_raw_data.csv", sep = "")) + regression_data_dest <- file.path(dest_dir, paste(name, "_regression_data.csv", sep = "")) + model_result_dest <- file.path(dest_dir, paste(name, "_model_result.csv", sep = "")) + + utils::write.csv( + data, + file = data_dest, + quote = TRUE, + row.names = FALSE + ) + + utils::write.csv( + get_etr_regression_data_from_model_result(model_result), + file = regression_data_dest, + quote = TRUE, + row.names = FALSE + ) + + df <- data.frame() + df[1, ] <- NA + + for (n in names(model_result)) { + if (n == "etr_regression_data" || n == "etr_type") { + next() + } + + entry <- data.frame( + stats::setNames( + list( + c(model_result[[n]]) + ), + c(n) + ) + ) + + df <- cbind(df, NewCol = entry) + } + + utils::write.csv( + df, + file = model_result_dest, + quote = TRUE, + row.names = FALSE + ) +} diff --git a/src/inst/extdata/dual_pam_single_channel_fluo_data/20260130_efeutute_dual_pam_only_fluo.csv b/src/inst/extdata/dual_pam_single_channel_fluo_data/20260130_dual_pam_only_fluo.csv similarity index 100% rename from src/inst/extdata/dual_pam_single_channel_fluo_data/20260130_efeutute_dual_pam_only_fluo.csv rename to src/inst/extdata/dual_pam_single_channel_fluo_data/20260130_dual_pam_only_fluo.csv diff --git a/src/inst/extdata/dual_pam_single_channel_p700_data/20260130_01_efeutute_dual_pam_only_p700.csv b/src/inst/extdata/dual_pam_single_channel_p700_data/20260130_01_dual_pam_only_p700.csv similarity index 100% rename from src/inst/extdata/dual_pam_single_channel_p700_data/20260130_01_efeutute_dual_pam_only_p700.csv rename to src/inst/extdata/dual_pam_single_channel_p700_data/20260130_01_dual_pam_only_p700.csv diff --git a/src/inst/extdata/junior_pam_data/2026_04_22_junior_pam.csv b/src/inst/extdata/junior_pam_data/2026_04_22_junior_pam.csv new file mode 100644 index 0000000..3f4f810 --- /dev/null +++ b/src/inst/extdata/junior_pam_data/2026_04_22_junior_pam.csv @@ -0,0 +1,20 @@ +26-04-22;10:44:04.000;WinControl (rev1255) report file +Time (rel/ms);Type;No.;2:F;2:Fm';2:PAR;2:Y (II);2:ETR +0;D;;Device Nr: #2, JUNIOR-PAM-III (CFMG0711B); +0;SLCS;;Light Curve start; +0;REG1;;#2: alpha: - , ETRm: - , Ik: - ( beta: - 0.001, ETRmPot: 76.798 ) (Platt et al. 1980); +0;REG2;;#2: alpha: 0.188, ETRm: 77.953, Ik: 414.611 (Jassby and Platt 1976); +1393;FO;1;130;506;0;0.743;0 +51389;F;2;278;489;50;0.431;9.1 +101375;F;3;317;472;90;0.328;12.4 +151366;F;4;211;342;130;0.383;20.9 +201357;F;5;178;304;180;0.414;31.3 +251347;F;6;164;284;250;0.423;44.4 +301335;F;7;159;248;380;0.359;57.3 +351325;F;8;148;210;570;0.295;70.6 +401305;F;9;144;183;840;0.213;75.1 +451323;F;10;140;164;1250;0.146;76.7 +501306;F;11;135;150;1640;0.1;68.9 +551299;F;12;131;143;2300;0.084;81.1 +601286;F;13;127;136;3000;0.066;83.2 +605163;SLCE;;Light Curve end; diff --git a/src/inst/extdata/junior_pam_data/junior_pam_20250613.csv b/src/inst/extdata/junior_pam_data/junior_pam_20250613.csv deleted file mode 100644 index 94e369e..0000000 --- a/src/inst/extdata/junior_pam_data/junior_pam_20250613.csv +++ /dev/null @@ -1,20 +0,0 @@ -25-06-13;10:50:28.000;WinControl (rev1242) report file -Datetime;Time (abs/ms);Time (rel/ms);Type;No.;1:F;1:Fm';1:PAR;1:Y (II);1:ETR -;0;D;;Device Nr: #1, JUNIOR-PAM-III (CFMG0710B); -2025-06-13 10:38:54.217;1749803934217;0;SLCS;;Light Curve start; -2025-06-13 10:38:54.217;1749803934217;0;REG1;;#1: alpha: 0.303, ETRm: 59.733, Ik: 197.268 ( beta: 0.001, ETRmPot: 61.486 ) (Platt et al. 1980); -2025-06-13 10:38:54.217;1749803934217;0;REG2;;#1: alpha: 0.238, ETRm: 58.397, Ik: 245.332 (Jassby and Platt 1976); -2025-06-13 10:38:55.603;1.7498e+012;1386;FO;1;124;584;0;0.788;0 -2025-06-13 10:39:35.598;1.7498e+012;41381;F;2;207;549;50;0.623;13.1 -2025-06-13 10:40:15.588;1.7498e+012;81371;F;3;207;512;90;0.596;22.5 -2025-06-13 10:40:55.576;1.7498e+012;121359;F;4;214;472;130;0.547;29.9 -2025-06-13 10:41:35.555;1.7498e+012;161338;F;5;204;396;180;0.485;36.7 -2025-06-13 10:42:15.549;1.7498e+012;201332;F;6;198;336;250;0.411;43.2 -2025-06-13 10:42:55.538;1.7498e+012;241321;F;7;196;286;380;0.315;50.3 -2025-06-13 10:43:35.534;1.7498e+012;281317;F;8;193;252;570;0.234;56 -2025-06-13 10:44:15.514;1.7498e+012;321297;F;9;189;226;840;0.164;57.9 -2025-06-13 10:44:55.507;1.7498e+012;361290;F;10;185;209;1250;0.115;60.4 -2025-06-13 10:45:35.495;1.7498e+012;401278;F;11;178;196;1640;0.092;63.4 -2025-06-13 10:46:15.491;1.7498e+012;441274;F;12;174;185;2300;0.059;57 -2025-06-13 10:46:55.496;1.7498e+012;481279;F;13;168;176;3000;0.045;56.7 -2025-06-13 10:46:58.974;1749804418974;484757;SLCE;;Light Curve end; diff --git a/src/inst/extdata/pam_2500_data/20260311_1(2).CSV b/src/inst/extdata/pam_2500_data/20260311_1(2).CSV deleted file mode 100644 index 6868c88..0000000 --- a/src/inst/extdata/pam_2500_data/20260311_1(2).CSV +++ /dev/null @@ -1,18 +0,0 @@ - -"t";"Date";"Time";"No.";"ML";"Temp.";"PAR";"F";"Fo'";"Fm'";"~Fo'";"Y(II)";"Y(NPQ)";"Y(NO)";"NPQ";"qN";"qP";"qL";"ETR";"Y4S";""; - 2;11.03.26;14:16:47;Type: LC - 4;11.03.26;14:16:48;default_60.par - 2;11.03.26;14:16:47;;1; 0.0;0;0.166;Fo: 0.166;Fm: 0.744 - 2;11.03.26;14:16:47;1;1; 0.0;0; 0.166; 0.000; 0.744; 0.166;0.777;0.000;0.223;0.000;0.000;1.000;1.000; 0.0;0.777 - 12;11.03.26;14:16:57;2;1; 0.0;5; 0.208; 0.194; 0.708; 0.164;0.706;0.014;0.280;0.051;0.111;0.973;0.907; 1.5;0.706 - 42;11.03.26;14:17:27;3;1; 0.0;9; 0.238; 0.184; 0.474; 0.147;0.498;0.182;0.320;0.570;0.498;0.814;0.629; 1.9;0.498 - 72;11.03.26;14:17:57;4;1; 0.0;34; 0.246; 0.180; 0.423; 0.142;0.418;0.251;0.331;0.759;0.580;0.728;0.533; 6.0;0.418 - 102;11.03.26;14:18:27;5;1; 0.0;67; 0.259; 0.174; 0.412; 0.141;0.371;0.281;0.348;0.806;0.588;0.643;0.432; 10.5;0.371 - 132;11.03.26;14:18:57;6;1; 0.0;104; 0.270; 0.168; 0.397; 0.139;0.320;0.317;0.363;0.874;0.604;0.555;0.345; 14.0;0.320 - 162;11.03.26;14:19:27;7;1; 0.0;144; 0.277; 0.177; 0.383; 0.137;0.277;0.351;0.372;0.943;0.644;0.515;0.329; 16.7;0.277 - 192;11.03.26;14:19:57;8;1; 0.0;201; 0.285; 0.172; 0.371; 0.136;0.232;0.385;0.383;1.005;0.656;0.432;0.261; 19.6;0.232 - 222;11.03.26;14:20:27;9;1; 0.0;274; 0.294; 0.169; 0.361; 0.134;0.186;0.419;0.395;1.061;0.668;0.349;0.201; 21.4;0.186 - 252;11.03.26;14:20:57;10;1; 0.0;366; 0.299; 0.171; 0.351; 0.133;0.148;0.450;0.402;1.120;0.689;0.289;0.165; 22.8;0.148 - 282;11.03.26;14:21:27;11;1; 0.0;477; 0.303; 0.170; 0.344; 0.132;0.119;0.474;0.407;1.163;0.699;0.236;0.132; 23.9;0.119 - 312;11.03.26;14:21:57;12;1; 0.0;622; 0.304; 0.169; 0.337; 0.131;0.098;0.493;0.409;1.208;0.709;0.196;0.109; 25.6;0.098 - 329;11.03.26;14:22:14;File: L_260311_141645.PWS diff --git a/src/inst/extdata/pam_2500_data/20260422_pam_2500.CSV b/src/inst/extdata/pam_2500_data/20260422_pam_2500.CSV new file mode 100644 index 0000000..663240e --- /dev/null +++ b/src/inst/extdata/pam_2500_data/20260422_pam_2500.CSV @@ -0,0 +1,18 @@ + +"t";"Date";"Time";"No.";"ML";"Temp.";"PAR";"F";"Fo'";"Fm'";"~Fo'";"Y(II)";"Y(NPQ)";"Y(NO)";"NPQ";"qN";"qP";"qL";"ETR";""; + 12;22.04.26;11:20:13;Type: LC + 14;22.04.26;11:20:14;default_60.par + 12;22.04.26;11:20:13;;2; 0.0;0;0.389;Fo: 0.389;Fm: 1.960 + 12;22.04.26;11:20:13;1;2; 0.0;0; 0.389; 0.000; 1.960; 0.389;0.802;0.000;0.198;0.000;0.000;1.000;1.000; 0.0 + 42;22.04.26;11:20:43;2;2; 0.0;7; 0.921; 0.000; 1.726; 0.379;0.466;0.064;0.470;0.136;0.142;0.598;0.246; 1.4 + 72;22.04.26;11:21:13;3;2; 0.0;36; 0.783; 0.000; 1.379; 0.359;0.432;0.168;0.399;0.421;0.351;0.584;0.268; 6.5 + 102;22.04.26;11:21:43;4;2; 0.0;106; 0.644; 0.000; 1.082; 0.335;0.405;0.267;0.329;0.811;0.525;0.586;0.305; 18.0 + 132;22.04.26;11:22:13;5;2; 0.0;203; 0.595; 0.000; 0.899; 0.315;0.338;0.358;0.304;1.180;0.628;0.521;0.276; 28.8 + 162;22.04.26;11:22:43;6;2; 0.0;368; 0.584; 0.000; 0.780; 0.299;0.251;0.451;0.298;1.513;0.694;0.408;0.209; 38.8 + 192;22.04.26;11:23:13;7;2; 0.0;624; 0.585; 0.000; 0.712; 0.289;0.178;0.523;0.298;1.753;0.730;0.300;0.148; 46.7 + 222;22.04.26;11:23:43;8;2; 0.0;986; 0.588; 0.000; 0.673; 0.282;0.126;0.574;0.300;1.912;0.751;0.217;0.104; 52.3 + 252;22.04.26;11:24:13;9;2; 0.0;1391; 0.588; 0.000; 0.651; 0.278;0.097;0.603;0.300;2.011;0.763;0.169;0.080; 56.5 + 282;22.04.26;11:24:43;10;2; 0.0;2020; 0.592; 0.000; 0.636; 0.275;0.069;0.629;0.302;2.082;0.770;0.122;0.057; 58.7 + 312;22.04.26;11:25:13;11;2; 0.0;7; 0.449; 0.000; 1.011; 0.328;0.556;0.215;0.229;0.939;0.565;0.823;0.601; 1.6 + 342;22.04.26;11:25:43;12;2; 0.0;69; 0.507; 0.000; 1.065; 0.333;0.524;0.217;0.259;0.840;0.534;0.763;0.502; 15.2 + 355;22.04.26;11:25:55;File: L_260422_112001.PWS diff --git a/src/man/combo_plot_control.Rd b/src/man/combo_plot_control.Rd index 4833f14..fba2468 100644 --- a/src/man/combo_plot_control.Rd +++ b/src/man/combo_plot_control.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/combo_plot_control.R +% Please edit documentation in R/plot.R \name{combo_plot_control} \alias{combo_plot_control} \title{Combined ETR Plot and Summary Table} diff --git a/src/man/eilers_peeters_default_start_value_a.Rd b/src/man/eilers_peeters_default_start_value_a.Rd index 749d6b3..b90840f 100644 --- a/src/man/eilers_peeters_default_start_value_a.Rd +++ b/src/man/eilers_peeters_default_start_value_a.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/eilers_peeters.R +% Please edit documentation in R/model_eilers_peeters.R \docType{data} \name{eilers_peeters_default_start_value_a} \alias{eilers_peeters_default_start_value_a} diff --git a/src/man/eilers_peeters_default_start_value_b.Rd b/src/man/eilers_peeters_default_start_value_b.Rd index d4fd0ac..8ddf54f 100644 --- a/src/man/eilers_peeters_default_start_value_b.Rd +++ b/src/man/eilers_peeters_default_start_value_b.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/eilers_peeters.R +% Please edit documentation in R/model_eilers_peeters.R \docType{data} \name{eilers_peeters_default_start_value_b} \alias{eilers_peeters_default_start_value_b} diff --git a/src/man/eilers_peeters_default_start_value_c.Rd b/src/man/eilers_peeters_default_start_value_c.Rd index 87e74db..3bbd431 100644 --- a/src/man/eilers_peeters_default_start_value_c.Rd +++ b/src/man/eilers_peeters_default_start_value_c.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/eilers_peeters.R +% Please edit documentation in R/model_eilers_peeters.R \docType{data} \name{eilers_peeters_default_start_value_c} \alias{eilers_peeters_default_start_value_c} diff --git a/src/man/eilers_peeters_generate_regression_ETR_I.Rd b/src/man/eilers_peeters_generate_regression_ETR_I.Rd index a48a6d3..3981037 100644 --- a/src/man/eilers_peeters_generate_regression_ETR_I.Rd +++ b/src/man/eilers_peeters_generate_regression_ETR_I.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/eilers_peeters.R +% Please edit documentation in R/model_eilers_peeters.R \name{eilers_peeters_generate_regression_ETR_I} \alias{eilers_peeters_generate_regression_ETR_I} \title{Eilers-Peeters Regression for ETR I} diff --git a/src/man/eilers_peeters_generate_regression_ETR_II.Rd b/src/man/eilers_peeters_generate_regression_ETR_II.Rd index 4c08182..7ebaca4 100644 --- a/src/man/eilers_peeters_generate_regression_ETR_II.Rd +++ b/src/man/eilers_peeters_generate_regression_ETR_II.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/eilers_peeters.R +% Please edit documentation in R/model_eilers_peeters.R \name{eilers_peeters_generate_regression_ETR_II} \alias{eilers_peeters_generate_regression_ETR_II} \title{Eilers-Peeters Regression for ETR II} diff --git a/src/man/eilers_peeters_modified.Rd b/src/man/eilers_peeters_modified.Rd index 9a6fd2f..f2a25fc 100644 --- a/src/man/eilers_peeters_modified.Rd +++ b/src/man/eilers_peeters_modified.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/eilers_peeters.R +% Please edit documentation in R/model_eilers_peeters.R \name{eilers_peeters_modified} \alias{eilers_peeters_modified} \title{Eilers & Peeters Model Modification} diff --git a/src/man/platt_default_start_value_alpha.Rd b/src/man/platt_default_start_value_alpha.Rd index 15cb9e9..c6cb1c9 100644 --- a/src/man/platt_default_start_value_alpha.Rd +++ b/src/man/platt_default_start_value_alpha.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/platt.R +% Please edit documentation in R/model_platt.R \docType{data} \name{platt_default_start_value_alpha} \alias{platt_default_start_value_alpha} diff --git a/src/man/platt_default_start_value_beta.Rd b/src/man/platt_default_start_value_beta.Rd index 0acd762..20c3104 100644 --- a/src/man/platt_default_start_value_beta.Rd +++ b/src/man/platt_default_start_value_beta.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/platt.R +% Please edit documentation in R/model_platt.R \docType{data} \name{platt_default_start_value_beta} \alias{platt_default_start_value_beta} diff --git a/src/man/platt_default_start_value_ps.Rd b/src/man/platt_default_start_value_ps.Rd index f6f4dc2..402c3a2 100644 --- a/src/man/platt_default_start_value_ps.Rd +++ b/src/man/platt_default_start_value_ps.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/platt.R +% Please edit documentation in R/model_platt.R \docType{data} \name{platt_default_start_value_ps} \alias{platt_default_start_value_ps} diff --git a/src/man/platt_generate_regression_ETR_I.Rd b/src/man/platt_generate_regression_ETR_I.Rd index 1f5092e..8087ac7 100644 --- a/src/man/platt_generate_regression_ETR_I.Rd +++ b/src/man/platt_generate_regression_ETR_I.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/platt.R +% Please edit documentation in R/model_platt.R \name{platt_generate_regression_ETR_I} \alias{platt_generate_regression_ETR_I} \title{Platt Regression for ETR I} diff --git a/src/man/platt_generate_regression_ETR_II.Rd b/src/man/platt_generate_regression_ETR_II.Rd index 3166a75..32951e4 100644 --- a/src/man/platt_generate_regression_ETR_II.Rd +++ b/src/man/platt_generate_regression_ETR_II.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/platt.R +% Please edit documentation in R/model_platt.R \name{platt_generate_regression_ETR_II} \alias{platt_generate_regression_ETR_II} \title{Platt Regression for ETR II} diff --git a/src/man/platt_modified.Rd b/src/man/platt_modified.Rd index e383ddd..353f616 100644 --- a/src/man/platt_modified.Rd +++ b/src/man/platt_modified.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/platt.R +% Please edit documentation in R/model_platt.R \name{platt_modified} \alias{platt_modified} \title{Platt Model Modification} diff --git a/src/man/plot_control.Rd b/src/man/plot_control.Rd index 4423a9c..6441fbe 100644 --- a/src/man/plot_control.Rd +++ b/src/man/plot_control.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/util.R +% Please edit documentation in R/plot.R \name{plot_control} \alias{plot_control} \title{Plot Control} diff --git a/src/man/read_dual_pam_data.Rd b/src/man/read_dual_pam_data.Rd index c25aa42..70a36ef 100644 --- a/src/man/read_dual_pam_data.Rd +++ b/src/man/read_dual_pam_data.Rd @@ -1,55 +1,55 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_pam_data.R -\name{read_dual_pam_data} -\alias{read_dual_pam_data} -\title{Read and Process DualPAM Data} -\usage{ -read_dual_pam_data( - csv_path, - remove_recovery = TRUE, - etr_factor = 0.84, - fraction_photosystem_I = 0.5, - fraction_photosystem_II = 0.5 -) -} -\arguments{ -\item{csv_path}{File path to the CSV file.} - -\item{remove_recovery}{Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}.} - -\item{etr_factor}{Numeric. Factor for ETR calculation. Default is \code{0.84}.} - -\item{fraction_photosystem_I}{Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}.} - -\item{fraction_photosystem_II}{Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}.} -} -\value{ -A \code{data.table} containing: -\itemize{ - \item \code{par}: Photosynthetically active radiation. - \item \code{yield_1}: Yield for photosystem I. - \item \code{yield_2}: Yield for photosystem II. - \item \code{etr_1}: Calculated ETR for photosystem I. - \item \code{etr_2}: Calculated ETR for photosystem II. -} -} -\description{ -Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values, and returns a universal dataset. -} -\details{ -Calculates ETR using: -\deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I or II)} \cdot \text{Yield (I or II)}} - -A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} -} -\examples{ -path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") -data <- read_dual_pam_data(path) -} -\references{ -{ - Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} - Heinz Walz GmbH, Effeltrich, Germany. - Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} -} -} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/device_dual_pam.R +\name{read_dual_pam_data} +\alias{read_dual_pam_data} +\title{Read and Process DualPAM Data} +\usage{ +read_dual_pam_data( + csv_path, + remove_recovery = TRUE, + etr_factor = 0.84, + fraction_photosystem_I = 0.5, + fraction_photosystem_II = 0.5 +) +} +\arguments{ +\item{csv_path}{File path to the CSV file.} + +\item{remove_recovery}{Logical. Removes recovery measurements if \code{TRUE}. Default is \code{TRUE}.} + +\item{etr_factor}{Numeric. Factor for ETR calculation. Default is \code{0.84}.} + +\item{fraction_photosystem_I}{Numeric. Relative distribution of absorbed PAR to photosystem I. Default is \code{0.5}.} + +\item{fraction_photosystem_II}{Numeric. Relative distribution of absorbed PAR to photosystem II. Default is \code{0.5}.} +} +\value{ +A \code{data.table} containing: +\itemize{ + \item \code{par}: Photosynthetically active radiation. + \item \code{yield_1}: Yield for photosystem I. + \item \code{yield_2}: Yield for photosystem II. + \item \code{etr_1}: Calculated ETR for photosystem I. + \item \code{etr_2}: Calculated ETR for photosystem II. +} +} +\description{ +Reads raw CSV files generated by DualPAM software, calculates electron transport rate (ETR) values, and returns a universal dataset. +} +\details{ +Calculates ETR using: +\deqn{\text{ETR} = \text{PAR} \cdot \text{ETR-Factor} \cdot \text{Fraction of Photosystem (I or II)} \cdot \text{Yield (I or II)}} + +A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file#read_dual_pam_data} +} +\examples{ +path <- file.path(system.file("extdata/dual_pam_data", package = "pam"), "20240925.csv") +data <- read_dual_pam_data(path) +} +\references{ +{ + Heinz Walz GmbH. (2024). \emph{DUAL-PAM-100 DUAL-PAM/F MANUAL, 5th Edition, April 2024, Chapter 7 (pp. 162-172).} + Heinz Walz GmbH, Effeltrich, Germany. + Available at: \url{https://www.walz.com/files/downloads/dualpamed05.pdf} +} +} diff --git a/src/man/read_dual_pam_single_channel_fluo_data.Rd b/src/man/read_dual_pam_single_channel_fluo_data.Rd index 2567b81..d9f6fe0 100644 --- a/src/man/read_dual_pam_single_channel_fluo_data.Rd +++ b/src/man/read_dual_pam_single_channel_fluo_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_pam_data.R +% Please edit documentation in R/device_dual_pam_single_channel_fluo.R \name{read_dual_pam_single_channel_fluo_data} \alias{read_dual_pam_single_channel_fluo_data} \title{Read and Process DualPAM Data Single Chanel Mode Fluo} @@ -45,7 +45,7 @@ A detailed documentation can be found under \url{https://github.com/biotoolbox/p \examples{ path <- file.path( system.file("extdata/dual_pam_single_channel_fluo_data", package = "pam"), - "20260130_efeutute_dual_pam_only_fluo.csv" + "20260130_dual_pam_only_fluo.csv" ) data <- read_dual_pam_single_channel_fluo_data(path) } diff --git a/src/man/read_dual_pam_single_channel_p700_data.Rd b/src/man/read_dual_pam_single_channel_p700_data.Rd index 7d766bb..be58956 100644 --- a/src/man/read_dual_pam_single_channel_p700_data.Rd +++ b/src/man/read_dual_pam_single_channel_p700_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_pam_data.R +% Please edit documentation in R/device_dual_pam_single_channel_p700.R \name{read_dual_pam_single_channel_p700_data} \alias{read_dual_pam_single_channel_p700_data} \title{Read and Process DualPAM Data Single Chanel Mode P700} @@ -45,7 +45,7 @@ A detailed documentation can be found under \url{https://github.com/biotoolbox/p \examples{ path <- file.path( system.file("extdata/dual_pam_single_channel_p700_data", package = "pam"), - "20260130_01_efeutute_dual_pam_only_p700.csv" + "20260130_01_dual_pam_only_p700.csv" ) data <- read_dual_pam_single_channel_p700_data(path) } diff --git a/src/man/read_junior_pam_data.Rd b/src/man/read_junior_pam_data.Rd index 180872a..c4d1e3d 100644 --- a/src/man/read_junior_pam_data.Rd +++ b/src/man/read_junior_pam_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_pam_data.R +% Please edit documentation in R/device_junior_pam.R \name{read_junior_pam_data} \alias{read_junior_pam_data} \title{Read and Process Junior PAM Data} @@ -45,7 +45,7 @@ A detailed documentation can be found under \url{https://github.com/biotoolbox/p \examples{ path <- file.path( system.file("extdata/junior_pam_data", package = "pam"), - "junior_pam_20250613.csv" + "2026_04_22_junior_pam.csv" ) data <- read_junior_pam_data(path) } diff --git a/src/man/read_pam_2500_data.Rd b/src/man/read_pam_2500_data.Rd index 7199f92..ce8e5b6 100644 --- a/src/man/read_pam_2500_data.Rd +++ b/src/man/read_pam_2500_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_pam_data.R +% Please edit documentation in R/device_pam_2500.R \name{read_pam_2500_data} \alias{read_pam_2500_data} \title{Read and Process PAM 2500 Data} @@ -43,7 +43,7 @@ Calculates ETR II using: A detailed documentation can be found under \url{https://github.com/biotoolbox/pam?tab=readme-ov-file} } \examples{ -path <- file.path(system.file("extdata/pam_2500_data", package = "pam"), "20260311_1(2).CSV") +path <- file.path(system.file("extdata/pam_2500_data", package = "pam"), "20260422_pam_2500.CSV") data <- read_pam_2500_data(path) } \references{ diff --git a/src/man/read_universal_data.Rd b/src/man/read_universal_data.Rd index ba63970..f877222 100644 --- a/src/man/read_universal_data.Rd +++ b/src/man/read_universal_data.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_pam_data.R +% Please edit documentation in R/device_universal_data.R \name{read_universal_data} \alias{read_universal_data} \title{Read and Process Universal PAM Data} diff --git a/src/man/vollenweider_default_start_value_a.Rd b/src/man/vollenweider_default_start_value_a.Rd index c3a2479..0f9e605 100644 --- a/src/man/vollenweider_default_start_value_a.Rd +++ b/src/man/vollenweider_default_start_value_a.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \docType{data} \name{vollenweider_default_start_value_a} \alias{vollenweider_default_start_value_a} diff --git a/src/man/vollenweider_default_start_value_alpha.Rd b/src/man/vollenweider_default_start_value_alpha.Rd index 698faa7..f896c6d 100644 --- a/src/man/vollenweider_default_start_value_alpha.Rd +++ b/src/man/vollenweider_default_start_value_alpha.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \docType{data} \name{vollenweider_default_start_value_alpha} \alias{vollenweider_default_start_value_alpha} diff --git a/src/man/vollenweider_default_start_value_n.Rd b/src/man/vollenweider_default_start_value_n.Rd index 9cb6ba8..ad79912 100644 --- a/src/man/vollenweider_default_start_value_n.Rd +++ b/src/man/vollenweider_default_start_value_n.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \docType{data} \name{vollenweider_default_start_value_n} \alias{vollenweider_default_start_value_n} diff --git a/src/man/vollenweider_default_start_value_pmax.Rd b/src/man/vollenweider_default_start_value_pmax.Rd index acf98e1..b10dfb6 100644 --- a/src/man/vollenweider_default_start_value_pmax.Rd +++ b/src/man/vollenweider_default_start_value_pmax.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \docType{data} \name{vollenweider_default_start_value_pmax} \alias{vollenweider_default_start_value_pmax} diff --git a/src/man/vollenweider_generate_regression_ETR_I.Rd b/src/man/vollenweider_generate_regression_ETR_I.Rd index aa5b47c..224e1d5 100644 --- a/src/man/vollenweider_generate_regression_ETR_I.Rd +++ b/src/man/vollenweider_generate_regression_ETR_I.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \name{vollenweider_generate_regression_ETR_I} \alias{vollenweider_generate_regression_ETR_I} \title{Vollenweider Regression for ETR I} diff --git a/src/man/vollenweider_generate_regression_ETR_II.Rd b/src/man/vollenweider_generate_regression_ETR_II.Rd index 0cd386c..c1c0bde 100644 --- a/src/man/vollenweider_generate_regression_ETR_II.Rd +++ b/src/man/vollenweider_generate_regression_ETR_II.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \name{vollenweider_generate_regression_ETR_II} \alias{vollenweider_generate_regression_ETR_II} \title{Vollenweider Regression for ETR II} diff --git a/src/man/vollenweider_modified.Rd b/src/man/vollenweider_modified.Rd index 5747da4..8fde27b 100644 --- a/src/man/vollenweider_modified.Rd +++ b/src/man/vollenweider_modified.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/vollenweider.R +% Please edit documentation in R/model_vollenweider.R \name{vollenweider_modified} \alias{vollenweider_modified} \title{Vollenweider Model Modification} diff --git a/src/man/walsby_default_start_value_alpha.Rd b/src/man/walsby_default_start_value_alpha.Rd index 0756ff4..43bcffc 100644 --- a/src/man/walsby_default_start_value_alpha.Rd +++ b/src/man/walsby_default_start_value_alpha.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/walsby.R +% Please edit documentation in R/model_walsby.R \docType{data} \name{walsby_default_start_value_alpha} \alias{walsby_default_start_value_alpha} diff --git a/src/man/walsby_default_start_value_beta.Rd b/src/man/walsby_default_start_value_beta.Rd index 9885fe7..95e0360 100644 --- a/src/man/walsby_default_start_value_beta.Rd +++ b/src/man/walsby_default_start_value_beta.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/walsby.R +% Please edit documentation in R/model_walsby.R \docType{data} \name{walsby_default_start_value_beta} \alias{walsby_default_start_value_beta} diff --git a/src/man/walsby_default_start_value_etr_max.Rd b/src/man/walsby_default_start_value_etr_max.Rd index def9308..3754373 100644 --- a/src/man/walsby_default_start_value_etr_max.Rd +++ b/src/man/walsby_default_start_value_etr_max.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/walsby.R +% Please edit documentation in R/model_walsby.R \docType{data} \name{walsby_default_start_value_etr_max} \alias{walsby_default_start_value_etr_max} diff --git a/src/man/walsby_generate_regression_ETR_I.Rd b/src/man/walsby_generate_regression_ETR_I.Rd index 6d7222d..560e7af 100644 --- a/src/man/walsby_generate_regression_ETR_I.Rd +++ b/src/man/walsby_generate_regression_ETR_I.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/walsby.R +% Please edit documentation in R/model_walsby.R \name{walsby_generate_regression_ETR_I} \alias{walsby_generate_regression_ETR_I} \title{Walsby Regression for ETR I} diff --git a/src/man/walsby_generate_regression_ETR_II.Rd b/src/man/walsby_generate_regression_ETR_II.Rd index 0767416..4549376 100644 --- a/src/man/walsby_generate_regression_ETR_II.Rd +++ b/src/man/walsby_generate_regression_ETR_II.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/walsby.R +% Please edit documentation in R/model_walsby.R \name{walsby_generate_regression_ETR_II} \alias{walsby_generate_regression_ETR_II} \title{Walsby Regression for ETR II} diff --git a/src/man/walsby_modified.Rd b/src/man/walsby_modified.Rd index 8b40c68..cad11c3 100644 --- a/src/man/walsby_modified.Rd +++ b/src/man/walsby_modified.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/walsby.R +% Please edit documentation in R/model_walsby.R \name{walsby_modified} \alias{walsby_modified} \title{Walsby Model Modification} diff --git a/src/man/write_model_result_csv.Rd b/src/man/write_model_result_csv.Rd index 75c3281..bc6a2d2 100644 --- a/src/man/write_model_result_csv.Rd +++ b/src/man/write_model_result_csv.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/util.R +% Please edit documentation in R/write_model_result_csv.R \name{write_model_result_csv} \alias{write_model_result_csv} \title{Write Model Result CSV} diff --git a/src/tests/testthat/data/20260311_1(2)_pam_2500.CSV b/src/tests/testthat/data/20260311_1(2)_pam_2500.CSV deleted file mode 100644 index 6868c88..0000000 --- a/src/tests/testthat/data/20260311_1(2)_pam_2500.CSV +++ /dev/null @@ -1,18 +0,0 @@ - -"t";"Date";"Time";"No.";"ML";"Temp.";"PAR";"F";"Fo'";"Fm'";"~Fo'";"Y(II)";"Y(NPQ)";"Y(NO)";"NPQ";"qN";"qP";"qL";"ETR";"Y4S";""; - 2;11.03.26;14:16:47;Type: LC - 4;11.03.26;14:16:48;default_60.par - 2;11.03.26;14:16:47;;1; 0.0;0;0.166;Fo: 0.166;Fm: 0.744 - 2;11.03.26;14:16:47;1;1; 0.0;0; 0.166; 0.000; 0.744; 0.166;0.777;0.000;0.223;0.000;0.000;1.000;1.000; 0.0;0.777 - 12;11.03.26;14:16:57;2;1; 0.0;5; 0.208; 0.194; 0.708; 0.164;0.706;0.014;0.280;0.051;0.111;0.973;0.907; 1.5;0.706 - 42;11.03.26;14:17:27;3;1; 0.0;9; 0.238; 0.184; 0.474; 0.147;0.498;0.182;0.320;0.570;0.498;0.814;0.629; 1.9;0.498 - 72;11.03.26;14:17:57;4;1; 0.0;34; 0.246; 0.180; 0.423; 0.142;0.418;0.251;0.331;0.759;0.580;0.728;0.533; 6.0;0.418 - 102;11.03.26;14:18:27;5;1; 0.0;67; 0.259; 0.174; 0.412; 0.141;0.371;0.281;0.348;0.806;0.588;0.643;0.432; 10.5;0.371 - 132;11.03.26;14:18:57;6;1; 0.0;104; 0.270; 0.168; 0.397; 0.139;0.320;0.317;0.363;0.874;0.604;0.555;0.345; 14.0;0.320 - 162;11.03.26;14:19:27;7;1; 0.0;144; 0.277; 0.177; 0.383; 0.137;0.277;0.351;0.372;0.943;0.644;0.515;0.329; 16.7;0.277 - 192;11.03.26;14:19:57;8;1; 0.0;201; 0.285; 0.172; 0.371; 0.136;0.232;0.385;0.383;1.005;0.656;0.432;0.261; 19.6;0.232 - 222;11.03.26;14:20:27;9;1; 0.0;274; 0.294; 0.169; 0.361; 0.134;0.186;0.419;0.395;1.061;0.668;0.349;0.201; 21.4;0.186 - 252;11.03.26;14:20:57;10;1; 0.0;366; 0.299; 0.171; 0.351; 0.133;0.148;0.450;0.402;1.120;0.689;0.289;0.165; 22.8;0.148 - 282;11.03.26;14:21:27;11;1; 0.0;477; 0.303; 0.170; 0.344; 0.132;0.119;0.474;0.407;1.163;0.699;0.236;0.132; 23.9;0.119 - 312;11.03.26;14:21:57;12;1; 0.0;622; 0.304; 0.169; 0.337; 0.131;0.098;0.493;0.409;1.208;0.709;0.196;0.109; 25.6;0.098 - 329;11.03.26;14:22:14;File: L_260311_141645.PWS diff --git a/src/tests/testthat/data/20231122_01.csv b/src/tests/testthat/data/dual_pam_data/20231122_01.csv similarity index 100% rename from src/tests/testthat/data/20231122_01.csv rename to src/tests/testthat/data/dual_pam_data/20231122_01.csv diff --git a/src/tests/testthat/data/20240925.csv b/src/tests/testthat/data/dual_pam_data/20240925.csv similarity index 100% rename from src/tests/testthat/data/20240925.csv rename to src/tests/testthat/data/dual_pam_data/20240925.csv diff --git a/src/tests/testthat/data/bulk/20231123_02.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231123_02.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231123_02.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231123_02.csv diff --git a/src/tests/testthat/data/bulk/20231123_03.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231123_03.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231123_03.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231123_03.csv diff --git a/src/tests/testthat/data/bulk/20231123_04.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231123_04.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231123_04.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231123_04.csv diff --git a/src/tests/testthat/data/bulk/20231123_05.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231123_05.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231123_05.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231123_05.csv diff --git a/src/tests/testthat/data/bulk/20231123_06.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231123_06.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231123_06.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231123_06.csv diff --git a/src/tests/testthat/data/bulk/20231123_07.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231123_07.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231123_07.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231123_07.csv diff --git a/src/tests/testthat/data/bulk/20231214.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214.csv diff --git a/src/tests/testthat/data/bulk/20231214_08.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_08.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_08.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_08.csv diff --git a/src/tests/testthat/data/bulk/20231214_09.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_09.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_09.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_09.csv diff --git a/src/tests/testthat/data/bulk/20231214_10.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_10.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_10.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_10.csv diff --git a/src/tests/testthat/data/bulk/20231214_11.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_11.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_11.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_11.csv diff --git a/src/tests/testthat/data/bulk/20231214_12.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_12.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_12.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_12.csv diff --git a/src/tests/testthat/data/bulk/20231214_13.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_13.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_13.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_13.csv diff --git a/src/tests/testthat/data/bulk/20231214_14.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_14.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_14.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_14.csv diff --git a/src/tests/testthat/data/bulk/20231214_15.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_15.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_15.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_15.csv diff --git a/src/tests/testthat/data/bulk/20231214_16.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_16.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_16.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_16.csv diff --git a/src/tests/testthat/data/bulk/20231214_17.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_17.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_17.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_17.csv diff --git a/src/tests/testthat/data/bulk/20231214_18.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_18.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_18.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_18.csv diff --git a/src/tests/testthat/data/bulk/20231214_19.csv b/src/tests/testthat/data/dual_pam_data/bulk/20231214_19.csv similarity index 100% rename from src/tests/testthat/data/bulk/20231214_19.csv rename to src/tests/testthat/data/dual_pam_data/bulk/20231214_19.csv diff --git a/src/tests/testthat/data/20260130_efeutute_dual_pam_only_fluo.csv b/src/tests/testthat/data/dual_pam_single_channel_fluo_data/20260130_dual_pam_only_fluo.csv similarity index 100% rename from src/tests/testthat/data/20260130_efeutute_dual_pam_only_fluo.csv rename to src/tests/testthat/data/dual_pam_single_channel_fluo_data/20260130_dual_pam_only_fluo.csv diff --git a/src/tests/testthat/data/20260130_01_efeutute_dual_pam_only_p700.csv b/src/tests/testthat/data/dual_pam_single_channel_p700_data/20260130_01_dual_pam_only_p700.csv similarity index 100% rename from src/tests/testthat/data/20260130_01_efeutute_dual_pam_only_p700.csv rename to src/tests/testthat/data/dual_pam_single_channel_p700_data/20260130_01_dual_pam_only_p700.csv diff --git a/src/tests/testthat/data/junior_pam_20250613.csv b/src/tests/testthat/data/junior_pam_20250613.csv deleted file mode 100644 index 94e369e..0000000 --- a/src/tests/testthat/data/junior_pam_20250613.csv +++ /dev/null @@ -1,20 +0,0 @@ -25-06-13;10:50:28.000;WinControl (rev1242) report file -Datetime;Time (abs/ms);Time (rel/ms);Type;No.;1:F;1:Fm';1:PAR;1:Y (II);1:ETR -;0;D;;Device Nr: #1, JUNIOR-PAM-III (CFMG0710B); -2025-06-13 10:38:54.217;1749803934217;0;SLCS;;Light Curve start; -2025-06-13 10:38:54.217;1749803934217;0;REG1;;#1: alpha: 0.303, ETRm: 59.733, Ik: 197.268 ( beta: 0.001, ETRmPot: 61.486 ) (Platt et al. 1980); -2025-06-13 10:38:54.217;1749803934217;0;REG2;;#1: alpha: 0.238, ETRm: 58.397, Ik: 245.332 (Jassby and Platt 1976); -2025-06-13 10:38:55.603;1.7498e+012;1386;FO;1;124;584;0;0.788;0 -2025-06-13 10:39:35.598;1.7498e+012;41381;F;2;207;549;50;0.623;13.1 -2025-06-13 10:40:15.588;1.7498e+012;81371;F;3;207;512;90;0.596;22.5 -2025-06-13 10:40:55.576;1.7498e+012;121359;F;4;214;472;130;0.547;29.9 -2025-06-13 10:41:35.555;1.7498e+012;161338;F;5;204;396;180;0.485;36.7 -2025-06-13 10:42:15.549;1.7498e+012;201332;F;6;198;336;250;0.411;43.2 -2025-06-13 10:42:55.538;1.7498e+012;241321;F;7;196;286;380;0.315;50.3 -2025-06-13 10:43:35.534;1.7498e+012;281317;F;8;193;252;570;0.234;56 -2025-06-13 10:44:15.514;1.7498e+012;321297;F;9;189;226;840;0.164;57.9 -2025-06-13 10:44:55.507;1.7498e+012;361290;F;10;185;209;1250;0.115;60.4 -2025-06-13 10:45:35.495;1.7498e+012;401278;F;11;178;196;1640;0.092;63.4 -2025-06-13 10:46:15.491;1.7498e+012;441274;F;12;174;185;2300;0.059;57 -2025-06-13 10:46:55.496;1.7498e+012;481279;F;13;168;176;3000;0.045;56.7 -2025-06-13 10:46:58.974;1749804418974;484757;SLCE;;Light Curve end; diff --git a/src/tests/testthat/data/junior_pam_data/2026_04_22_junior_pam.csv b/src/tests/testthat/data/junior_pam_data/2026_04_22_junior_pam.csv new file mode 100644 index 0000000..3f4f810 --- /dev/null +++ b/src/tests/testthat/data/junior_pam_data/2026_04_22_junior_pam.csv @@ -0,0 +1,20 @@ +26-04-22;10:44:04.000;WinControl (rev1255) report file +Time (rel/ms);Type;No.;2:F;2:Fm';2:PAR;2:Y (II);2:ETR +0;D;;Device Nr: #2, JUNIOR-PAM-III (CFMG0711B); +0;SLCS;;Light Curve start; +0;REG1;;#2: alpha: - , ETRm: - , Ik: - ( beta: - 0.001, ETRmPot: 76.798 ) (Platt et al. 1980); +0;REG2;;#2: alpha: 0.188, ETRm: 77.953, Ik: 414.611 (Jassby and Platt 1976); +1393;FO;1;130;506;0;0.743;0 +51389;F;2;278;489;50;0.431;9.1 +101375;F;3;317;472;90;0.328;12.4 +151366;F;4;211;342;130;0.383;20.9 +201357;F;5;178;304;180;0.414;31.3 +251347;F;6;164;284;250;0.423;44.4 +301335;F;7;159;248;380;0.359;57.3 +351325;F;8;148;210;570;0.295;70.6 +401305;F;9;144;183;840;0.213;75.1 +451323;F;10;140;164;1250;0.146;76.7 +501306;F;11;135;150;1640;0.1;68.9 +551299;F;12;131;143;2300;0.084;81.1 +601286;F;13;127;136;3000;0.066;83.2 +605163;SLCE;;Light Curve end; diff --git a/src/tests/testthat/data/pam_2500_data/20260422_pam_2500.CSV b/src/tests/testthat/data/pam_2500_data/20260422_pam_2500.CSV new file mode 100644 index 0000000..663240e --- /dev/null +++ b/src/tests/testthat/data/pam_2500_data/20260422_pam_2500.CSV @@ -0,0 +1,18 @@ + +"t";"Date";"Time";"No.";"ML";"Temp.";"PAR";"F";"Fo'";"Fm'";"~Fo'";"Y(II)";"Y(NPQ)";"Y(NO)";"NPQ";"qN";"qP";"qL";"ETR";""; + 12;22.04.26;11:20:13;Type: LC + 14;22.04.26;11:20:14;default_60.par + 12;22.04.26;11:20:13;;2; 0.0;0;0.389;Fo: 0.389;Fm: 1.960 + 12;22.04.26;11:20:13;1;2; 0.0;0; 0.389; 0.000; 1.960; 0.389;0.802;0.000;0.198;0.000;0.000;1.000;1.000; 0.0 + 42;22.04.26;11:20:43;2;2; 0.0;7; 0.921; 0.000; 1.726; 0.379;0.466;0.064;0.470;0.136;0.142;0.598;0.246; 1.4 + 72;22.04.26;11:21:13;3;2; 0.0;36; 0.783; 0.000; 1.379; 0.359;0.432;0.168;0.399;0.421;0.351;0.584;0.268; 6.5 + 102;22.04.26;11:21:43;4;2; 0.0;106; 0.644; 0.000; 1.082; 0.335;0.405;0.267;0.329;0.811;0.525;0.586;0.305; 18.0 + 132;22.04.26;11:22:13;5;2; 0.0;203; 0.595; 0.000; 0.899; 0.315;0.338;0.358;0.304;1.180;0.628;0.521;0.276; 28.8 + 162;22.04.26;11:22:43;6;2; 0.0;368; 0.584; 0.000; 0.780; 0.299;0.251;0.451;0.298;1.513;0.694;0.408;0.209; 38.8 + 192;22.04.26;11:23:13;7;2; 0.0;624; 0.585; 0.000; 0.712; 0.289;0.178;0.523;0.298;1.753;0.730;0.300;0.148; 46.7 + 222;22.04.26;11:23:43;8;2; 0.0;986; 0.588; 0.000; 0.673; 0.282;0.126;0.574;0.300;1.912;0.751;0.217;0.104; 52.3 + 252;22.04.26;11:24:13;9;2; 0.0;1391; 0.588; 0.000; 0.651; 0.278;0.097;0.603;0.300;2.011;0.763;0.169;0.080; 56.5 + 282;22.04.26;11:24:43;10;2; 0.0;2020; 0.592; 0.000; 0.636; 0.275;0.069;0.629;0.302;2.082;0.770;0.122;0.057; 58.7 + 312;22.04.26;11:25:13;11;2; 0.0;7; 0.449; 0.000; 1.011; 0.328;0.556;0.215;0.229;0.939;0.565;0.823;0.601; 1.6 + 342;22.04.26;11:25:43;12;2; 0.0;69; 0.507; 0.000; 1.065; 0.333;0.524;0.217;0.259;0.840;0.534;0.763;0.502; 15.2 + 355;22.04.26;11:25:55;File: L_260422_112001.PWS diff --git a/src/tests/testthat/data/universal_data.csv b/src/tests/testthat/data/universal_data/universal_data.csv similarity index 100% rename from src/tests/testthat/data/universal_data.csv rename to src/tests/testthat/data/universal_data/universal_data.csv diff --git a/src/tests/testthat/helper-os-detection.R b/src/tests/testthat/helper-os-detection.R index d143fbc..95b89a7 100644 --- a/src/tests/testthat/helper-os-detection.R +++ b/src/tests/testthat/helper-os-detection.R @@ -1,51 +1,36 @@ -# Returns a string identifying the OS or distro -get_os_distro <- function() { +get_os_id <- function() { sys_name <- Sys.info()[["sysname"]] if (sys_name == "Linux") { - # If the file doesn't exist, we can't determine distro if (!file.exists("/etc/os-release")) { - return("unknown") + return(NA) } - - # Try reading the file safely - os_release <- tryCatch( - readLines("/etc/os-release"), - error = function(e) NULL - ) - - if (is.null(os_release)) { - return("unknown") + os_release <- readLines("/etc/os-release") + id_line <- grep("^ID=", os_release, value = TRUE) + if (length(id_line) == 0) { + return(NA) } + return(id_line) + } - # Extract ID_LIKE and ID - distro_id_like <- grep("^ID_LIKE=", os_release, value = TRUE) - distro_id_like <- if (length(distro_id_like) > 0) { - sub("^ID_LIKE=", "", distro_id_like) - } else { - "" - } + return(tolower(sys_name)) +} - distro_id <- grep("^ID=", os_release, value = TRUE) - distro_id <- if (length(distro_id) > 0) { - sub("^ID=", "", distro_id) - } else { - "" - } +is_reference_platform <- function() { + os <- get_os_id() + if (is.na(os) || !grepl("\\b(debian|ubuntu)\\b", os, ignore.case = TRUE)) { + return(FALSE) + } - distro_names <- paste(distro_id_like, distro_id, collapse = " ") - if (nchar(trimws(distro_names)) == 0) { - return("unknown") - } else { - return(distro_names) - } + blas <- tolower(extSoftVersion()[["BLAS"]]) + if (!grepl("openblas|mkl|atlas|flexiblas|accelerate", blas)) { + return(FALSE) } - # For non-Linux, just return the system name (e.g. "Windows", "Darwin") - return(tolower(sys_name)) -} + arch <- tolower(Sys.info()[["machine"]]) + if (!(arch %in% c("x86_64", "amd64", "i386", "i686"))) { + return(FALSE) + } -is_debian_or_ubuntu <- function() { - os <- get_os_distro() - grepl("\\b(debian|ubuntu)\\b", os, ignore.case = TRUE) + return(TRUE) } diff --git a/src/tests/testthat/test-combo_plot_control_etr_I.R b/src/tests/testthat/test-combo_plot_control_etr_I.R index cf29b08..87c882a 100644 --- a/src/tests/testthat/test-combo_plot_control_etr_I.R +++ b/src/tests/testthat/test-combo_plot_control_etr_I.R @@ -1,5 +1,5 @@ test_that("test-combo_plot_control 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) diff --git a/src/tests/testthat/test-combo_plot_control_etr_II.R b/src/tests/testthat/test-combo_plot_control_etr_II.R index 798f8cd..47457e1 100644 --- a/src/tests/testthat/test-combo_plot_control_etr_II.R +++ b/src/tests/testthat/test-combo_plot_control_etr_II.R @@ -1,5 +1,5 @@ test_that("test-combo_plot_control 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_II(data)) diff --git a/src/tests/testthat/test-compare_regression_models_etr_I.R b/src/tests/testthat/test-compare_regression_models_etr_I.R index 5e54236..5789053 100644 --- a/src/tests/testthat/test-compare_regression_models_etr_I.R +++ b/src/tests/testthat/test-compare_regression_models_etr_I.R @@ -1,6 +1,6 @@ test_that("compare_regression_models etr I - linux", { - skip_if_not(is_debian_or_ubuntu()) - test_data_dir <- testthat::test_path("data", "bulk") + skip_if_not(is_reference_platform()) + test_data_dir <- testthat::test_path("data", "dual_pam_data", "bulk") result <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) expect_equal(result[["eilers_peeters"]], 13) @@ -10,7 +10,7 @@ test_that("compare_regression_models etr I - linux", { }) test_that("compare_regression_models etr I", { - test_data_dir <- testthat::test_path("data", "bulk") + test_data_dir <- testthat::test_path("data", "dual_pam_data", "bulk") result <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) expect_named(result, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) }) diff --git a/src/tests/testthat/test-compare_regression_models_etr_II.R b/src/tests/testthat/test-compare_regression_models_etr_II.R index 919d238..5c12d66 100644 --- a/src/tests/testthat/test-compare_regression_models_etr_II.R +++ b/src/tests/testthat/test-compare_regression_models_etr_II.R @@ -1,7 +1,7 @@ test_that("compare_regression_models etr II - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_dir <- testthat::test_path("data", "bulk") + test_data_dir <- testthat::test_path("data", "dual_pam_data", "bulk") result <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) expect_equal(result[["eilers_peeters"]], 37) @@ -11,7 +11,7 @@ test_that("compare_regression_models etr II - linux", { }) test_that("compare_regression_models etr II", { - test_data_dir <- testthat::test_path("data", "bulk") + test_data_dir <- testthat::test_path("data", "dual_pam_data", "bulk") result <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) expect_named(result, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) }) diff --git a/src/tests/testthat/test-compare_regression_models_total.R b/src/tests/testthat/test-compare_regression_models_total.R index 3c6f43a..69d59c1 100644 --- a/src/tests/testthat/test-compare_regression_models_total.R +++ b/src/tests/testthat/test-compare_regression_models_total.R @@ -1,6 +1,6 @@ test_that("compare_regression_models etr I + II - linux", { - skip_if_not(is_debian_or_ubuntu()) - test_data_dir <- testthat::test_path("data", "bulk") + skip_if_not(is_reference_platform()) + test_data_dir <- testthat::test_path("data", "dual_pam_data", "bulk") model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) model_points_etr_II <- compare_regression_models_ETR_II(test_data_dir, read_dual_pam_data) @@ -16,7 +16,7 @@ test_that("compare_regression_models etr I + II - linux", { }) test_that("compare_regression_models etr I + II", { - test_data_dir <- testthat::test_path("data", "bulk") + test_data_dir <- testthat::test_path("data", "dual_pam_data", "bulk") model_points_etr_I <- compare_regression_models_ETR_I(test_data_dir, read_dual_pam_data) expect_named(model_points_etr_I, c("eilers_peeters", "platt", "vollenweider", "walsby"), ignore.order = TRUE) diff --git a/src/tests/testthat/test-eilers_peeters_etr_I.R b/src/tests/testthat/test-eilers_peeters_etr_I.R index b8d0fe2..f9f1851 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_I.R +++ b/src/tests/testthat/test-eilers_peeters_etr_I.R @@ -1,6 +1,6 @@ test_that("test-eilers_peeters_etr_I generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) - test_data_file <- testthat::test_path("data", "20240925.csv") + skip_if_not(is_reference_platform()) + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_I(data) @@ -16,14 +16,14 @@ test_that("test-eilers_peeters_etr_I generate regression 20240925.csv - linux", }) test_that("test-eilers_peeters_etr_I generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_I(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-eilers_peeters_etr_I control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_I(data) @@ -42,9 +42,9 @@ test_that("test-eilers_peeters_etr_I control plot 20240925.csv", { }) test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_I(data) model_result <- eilers_peeters_modified(model_result) @@ -67,7 +67,7 @@ test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv - }) test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_I(data) @@ -78,7 +78,7 @@ test_that("test-eilers_peeters_etr_I generate regression modified 20240925.csv", }) test_that("test-eilers_peeters_etr_I modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_I(data) model_result <- eilers_peeters_modified(model_result) diff --git a/src/tests/testthat/test-eilers_peeters_etr_II.R b/src/tests/testthat/test-eilers_peeters_etr_II.R index 0dc92b6..70f79d0 100644 --- a/src/tests/testthat/test-eilers_peeters_etr_II.R +++ b/src/tests/testthat/test-eilers_peeters_etr_II.R @@ -1,6 +1,6 @@ test_that("test-eilers_peeters_etr_II generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) - test_data_file <- testthat::test_path("data", "20240925.csv") + skip_if_not(is_reference_platform()) + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_II(data) @@ -16,16 +16,16 @@ test_that("test-eilers_peeters_etr_II generate regression 20240925.csv - linux", }) test_that("test-eilers_peeters_etr_II generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_II(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-eilers_peeters_etr_II modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_II(data) model_result <- eilers_peeters_modified(model_result) @@ -48,7 +48,7 @@ test_that("test-eilers_peeters_etr_II modified 20240925.csv - linux", { }) test_that("test-eilers_peeters_etr_II modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_II(data) expect_no_error(validate_model_result(model_result)) @@ -58,7 +58,7 @@ test_that("test-eilers_peeters_etr_II modified 20240925.csv", { }) test_that("test-eilers_peeters_etr_II modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- eilers_peeters_generate_regression_ETR_II(data) model_result <- model_result <- eilers_peeters_modified(model_result) diff --git a/src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R b/src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R deleted file mode 100644 index f5143e8..0000000 --- a/src/tests/testthat/test-eilers_peeters_junior_pam_etr_II.R +++ /dev/null @@ -1,79 +0,0 @@ -test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) - - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - - expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) - # expect_equal(model_result[["a"]], 0.000001594) - expect_equal(model_result[["b"]], 0.01213671) - expect_equal(model_result[["c"]], 2.77837046) - expect_equal(model_result[["pm"]], 61.1793644) - expect_equal(model_result[["s"]], 0.35992320) - expect_equal(model_result[["ik"]], 169.978939) - expect_equal(model_result[["im"]], 1320.307821) - expect_equal(model_result[["w"]], 5.7674788) -}) - -test_that("test-eilers_peeters_etr_II junior_pam_20250613.csv.csv", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - expect_no_error(validate_model_result(model_result)) -}) - -test_that("test-eilers_peeters_etr_II modified junior_pam_20250613.csv.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- eilers_peeters_modified(model_result) - - expect_equal(model_result[["residual_sum_of_squares"]], 18.5975058) - # expect_equal(model_result[["a"]], 0.000001594) - expect_equal(model_result[["b"]], 0.01213671) - expect_equal(model_result[["c"]], 2.77837046) - expect_equal(model_result[["d"]], NA_real_) - expect_equal(model_result[["alpha"]], 0.35992320) - expect_equal(model_result[["beta"]], NA_real_) - expect_equal(model_result[["etrmax_with_photoinhibition"]], 61.1793644) - expect_equal(model_result[["etrmax_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["ik_with_photoinhibition"]], 169.978939) - expect_equal(model_result[["ik_without_photoinhibition"]], NA_real_) - expect_equal(model_result[["im_with_photoinhibition"]], 1320.307821) - expect_equal(model_result[["w"]], 5.7674788) - expect_equal(model_result[["ib"]], NA_real_) - expect_equal(model_result[["etrmax_without_with_ratio"]], NA_real_) -}) - -test_that("test-eilers_peeters_etr_II modified junior_pam_20250613.csv.csv", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - - model_result <- eilers_peeters_generate_regression_ETR_II(data) - expect_no_error(validate_model_result(model_result)) - - model_result <- eilers_peeters_modified(model_result) - expect_no_error(validate_modified_model_result(model_result)) -}) - -test_that("test-eilers_peeters_etr_II modified control plot junior_pam_20250613.csv", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") - data <- read_junior_pam_data(test_data_file) - model_result <- eilers_peeters_generate_regression_ETR_II(data) - model_result <- model_result <- eilers_peeters_modified(model_result) - - plot <- plot_control( - data, - model_result, - "eilers_peeters ETR II modified junior_pam_20250613.csv", - color_eilers_peeters - ) - expect_s3_class(plot, "ggplot") - expect_gt(length(plot$layers), 0) - - out <- file.path("results", "test-eilers_peeters_etr_II modified control plot junior_pam_20250613.jpg") - ggplot2::ggsave(out, create.dir = TRUE, plot = plot, units = "px", width = 1000, height = 1000, dpi = 100, limitsize = FALSE) - expect_true(file.exists(out)) -}) diff --git a/src/tests/testthat/test-get_etr_data_for_par_values.R b/src/tests/testthat/test-get_etr_data_for_par_values.R index 7e8022a..2705898 100644 --- a/src/tests/testthat/test-get_etr_data_for_par_values.R +++ b/src/tests/testthat/test-get_etr_data_for_par_values.R @@ -1,5 +1,5 @@ test_that("test-get_etr_data_for_par_values.R", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) diff --git a/src/tests/testthat/test-platt_etr_I.R b/src/tests/testthat/test-platt_etr_I.R index dded5b9..4cd675d 100644 --- a/src/tests/testthat/test-platt_etr_I.R +++ b/src/tests/testthat/test-platt_etr_I.R @@ -1,7 +1,7 @@ test_that("test-platt_etr_I generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_I(data) @@ -17,16 +17,16 @@ test_that("test-platt_etr_I generate regression 20240925.csv - linux", { }) test_that("test-platt_etr_I generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_I(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-platt_etr_I generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_I(data) model_result <- platt_modified(model_result) @@ -49,7 +49,7 @@ test_that("test-platt_etr_I generate regression modified 20240925.csv - linux", }) test_that("test-platt_etr_I generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_I(data) @@ -60,7 +60,7 @@ test_that("test-platt_etr_I generate regression modified 20240925.csv", { }) test_that("test-platt_etr_I modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_I(data) model_result <- platt_modified(model_result) diff --git a/src/tests/testthat/test-platt_etr_II.R b/src/tests/testthat/test-platt_etr_II.R index f5d7c93..ff45605 100644 --- a/src/tests/testthat/test-platt_etr_II.R +++ b/src/tests/testthat/test-platt_etr_II.R @@ -1,7 +1,7 @@ test_that("test-platt_etr_II generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_II(data) @@ -17,14 +17,14 @@ test_that("test-platt_etr_II generate regression 20240925.csv - linux", { }) test_that("test-platt_etr_II generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_II(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-platt_etr_II control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_II(data) @@ -43,9 +43,9 @@ test_that("test-platt_etr_II control plot 20240925.csv", { }) test_that("test-platt_etr_II generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_II(data) model_result <- platt_modified(model_result) @@ -68,7 +68,7 @@ test_that("test-platt_etr_II generate regression modified 20240925.csv - linux", }) test_that("test-platt_etr_II generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_II(data) expect_no_error(validate_model_result(model_result)) @@ -78,7 +78,7 @@ test_that("test-platt_etr_II generate regression modified 20240925.csv", { }) test_that("test-platt_etr_II modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- platt_generate_regression_ETR_II(data) diff --git a/src/tests/testthat/test-read_dual_pam_data.R b/src/tests/testthat/test-read_dual_pam_data.R index bcb9dc1..61c12c8 100644 --- a/src/tests/testthat/test-read_dual_pam_data.R +++ b/src/tests/testthat/test-read_dual_pam_data.R @@ -1,5 +1,5 @@ test_that("read_dual_pam_data 20240925.csv - default", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) par <- data$par @@ -99,7 +99,7 @@ test_that("read_dual_pam_data 20240925.csv - default", { }) test_that("read_dual_pam_data 20240925.csv - etr_factor 0.5", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file, etr_factor = 0.5) par <- data$par @@ -199,12 +199,12 @@ test_that("read_dual_pam_data 20240925.csv - etr_factor 0.5", { }) test_that("read_dual_pam_data 20240925.csv - fraction_photosystem > 1", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") expect_error(read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_dual_pam_data 20240925.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par @@ -303,12 +303,12 @@ test_that("read_dual_pam_data 20240925.csv - fraction_photosystem_I = 0.2, fract expect_equal(etr_2[17], 62.0256) }) -test_that("20260130_01_efeutute_dual_pam_only_p700.csv - expect fm missing", { - test_data_file <- testthat::test_path("data", "20260130_01_efeutute_dual_pam_only_p700.csv") +test_that("20260130_01_dual_pam_only_p700.csv - expect fm missing", { + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv") expect_error(read_dual_pam_data(test_data_file)) }) -test_that("20260130_efeutute_dual_pam_only_fluo.csv - expect pm missing", { - test_data_file <- testthat::test_path("data", "20260130_efeutute_dual_pam_only_fluo.csv") +test_that("20260130_dual_pam_only_fluo.csv - expect pm missing", { + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv") expect_error(read_dual_pam_data(test_data_file)) }) diff --git a/src/tests/testthat/test-read_dual_pam_single_channel_fluo_data.R b/src/tests/testthat/test-read_dual_pam_single_channel_fluo_data.R index fda729a..2c865b1 100644 --- a/src/tests/testthat/test-read_dual_pam_single_channel_fluo_data.R +++ b/src/tests/testthat/test-read_dual_pam_single_channel_fluo_data.R @@ -1,5 +1,5 @@ test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - default", { - test_data_file <- testthat::test_path("data", "20260130_efeutute_dual_pam_only_fluo.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv") data <- read_dual_pam_single_channel_fluo_data(test_data_file) par <- data$par @@ -69,7 +69,7 @@ test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_onl }) test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - etr_factor 0.5", { - test_data_file <- testthat::test_path("data", "20260130_efeutute_dual_pam_only_fluo.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv") data <- read_dual_pam_single_channel_fluo_data(test_data_file, etr_factor = 0.5) par <- data$par @@ -139,12 +139,12 @@ test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_onl }) test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - fraction_photosystem > 1", { - test_data_file <- testthat::test_path("data", "20260130_efeutute_dual_pam_only_fluo.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv") expect_error(read_dual_pam_single_channel_fluo_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_dual_pam_single_channel_fluo_data 20260130_efeutute_dual_pam_only_fluo - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "20260130_efeutute_dual_pam_only_fluo.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_fluo_data", "20260130_dual_pam_only_fluo.csv") data <- read_dual_pam_single_channel_fluo_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par diff --git a/src/tests/testthat/test-read_dual_pam_single_channel_p700_data.R b/src/tests/testthat/test-read_dual_pam_single_channel_p700_data.R index d486edf..5b38fa3 100644 --- a/src/tests/testthat/test-read_dual_pam_single_channel_p700_data.R +++ b/src/tests/testthat/test-read_dual_pam_single_channel_p700_data.R @@ -1,5 +1,5 @@ test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - default", { - test_data_file <- testthat::test_path("data", "20260130_01_efeutute_dual_pam_only_p700.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv") data <- read_dual_pam_single_channel_p700_data(test_data_file) par <- data$par @@ -89,7 +89,7 @@ test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_ }) test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - etr_factor 0.5", { - test_data_file <- testthat::test_path("data", "20260130_01_efeutute_dual_pam_only_p700.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv") data <- read_dual_pam_single_channel_p700_data(test_data_file, etr_factor = 0.5) par <- data$par @@ -179,12 +179,12 @@ test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_ }) test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - fraction_photosystem > 1", { - test_data_file <- testthat::test_path("data", "20260130_01_efeutute_dual_pam_only_p700.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv") expect_error(read_dual_pam_single_channel_p700_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_dual_pam_single_channel_p700_data 20260130_01_efeutute_dual_pam_only_p700 - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "20260130_01_efeutute_dual_pam_only_p700.csv") + test_data_file <- testthat::test_path("data", "dual_pam_single_channel_p700_data", "20260130_01_dual_pam_only_p700.csv") data <- read_dual_pam_single_channel_p700_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par diff --git a/src/tests/testthat/test-read_junior_pam_data.R b/src/tests/testthat/test-read_junior_pam_data.R index 8290928..0286f22 100644 --- a/src/tests/testthat/test-read_junior_pam_data.R +++ b/src/tests/testthat/test-read_junior_pam_data.R @@ -1,5 +1,5 @@ -test_that("read_junior_pam_data junior_pam_20250613.csv - default", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") +test_that("read_junior_pam_data 2026_04_22_junior_pam.csv - default", { + test_data_file <- testthat::test_path("data", "junior_pam_data", "2026_04_22_junior_pam.csv") data <- read_junior_pam_data(test_data_file) par <- data$par @@ -33,19 +33,19 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - default", { expect_equal(yield_1[13], NA_real_) yield_2 <- data$yield_2 - expect_equal(yield_2[1], 0.788) - expect_equal(yield_2[2], 0.623) - expect_equal(yield_2[3], 0.596) - expect_equal(yield_2[4], 0.547) - expect_equal(yield_2[5], 0.485) - expect_equal(yield_2[6], 0.411) - expect_equal(yield_2[7], 0.315) - expect_equal(yield_2[8], 0.234) - expect_equal(yield_2[9], 0.164) - expect_equal(yield_2[10], 0.115) - expect_equal(yield_2[11], 0.092) - expect_equal(yield_2[12], 0.059) - expect_equal(yield_2[13], 0.045) + expect_equal(yield_2[1], 0.743) + expect_equal(yield_2[2], 0.4310) + expect_equal(yield_2[3], 0.3280) + expect_equal(yield_2[4], 0.3830) + expect_equal(yield_2[5], 0.414) + expect_equal(yield_2[6], 0.423) + expect_equal(yield_2[7], 0.359) + expect_equal(yield_2[8], 0.295) + expect_equal(yield_2[9], 0.213) + expect_equal(yield_2[10], 0.146) + expect_equal(yield_2[11], 0.1000) + expect_equal(yield_2[12], 0.084) + expect_equal(yield_2[13], 0.066) etr_1 <- data$etr_1 expect_equal(etr_1[1], NA_real_) @@ -64,22 +64,22 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - default", { etr_2 <- data$etr_2 expect_equal(etr_2[1], 0) - expect_equal(etr_2[2], 13.083) - expect_equal(etr_2[3], 22.5288) - expect_equal(etr_2[4], 29.8662) - expect_equal(etr_2[5], 36.666) - expect_equal(etr_2[6], 43.155) - expect_equal(etr_2[7], 50.274) - expect_equal(etr_2[8], 56.0196) - expect_equal(etr_2[9], 57.8592) - expect_equal(etr_2[10], 60.375) - expect_equal(etr_2[11], 63.3696) - expect_equal(etr_2[12], 56.994) - expect_equal(etr_2[13], 56.7) + expect_equal(etr_2[2], 9.0510) + expect_equal(etr_2[3], 12.3984) + expect_equal(etr_2[4], 20.9118) + expect_equal(etr_2[5], 31.2984) + expect_equal(etr_2[6], 44.4150) + expect_equal(etr_2[7], 57.2964) + expect_equal(etr_2[8], 70.6230) + expect_equal(etr_2[9], 75.1464) + expect_equal(etr_2[10], 76.6500) + expect_equal(etr_2[11], 68.8800) + expect_equal(etr_2[12], 81.1440) + expect_equal(etr_2[13], 83.1600) }) -test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") +test_that("read_junior_pam_data 2026_04_22_junior_pam.csv - etr_factor 0.5", { + test_data_file <- testthat::test_path("data", "junior_pam_data", "2026_04_22_junior_pam.csv") data <- read_junior_pam_data(test_data_file, etr_factor = 0.5) par <- data$par @@ -113,19 +113,19 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { expect_equal(yield_1[13], NA_real_) yield_2 <- data$yield_2 - expect_equal(yield_2[1], 0.788) - expect_equal(yield_2[2], 0.623) - expect_equal(yield_2[3], 0.596) - expect_equal(yield_2[4], 0.547) - expect_equal(yield_2[5], 0.485) - expect_equal(yield_2[6], 0.411) - expect_equal(yield_2[7], 0.315) - expect_equal(yield_2[8], 0.234) - expect_equal(yield_2[9], 0.164) - expect_equal(yield_2[10], 0.115) - expect_equal(yield_2[11], 0.092) - expect_equal(yield_2[12], 0.059) - expect_equal(yield_2[13], 0.045) + expect_equal(yield_2[1], 0.743) + expect_equal(yield_2[2], 0.4310) + expect_equal(yield_2[3], 0.3280) + expect_equal(yield_2[4], 0.3830) + expect_equal(yield_2[5], 0.414) + expect_equal(yield_2[6], 0.423) + expect_equal(yield_2[7], 0.359) + expect_equal(yield_2[8], 0.295) + expect_equal(yield_2[9], 0.213) + expect_equal(yield_2[10], 0.146) + expect_equal(yield_2[11], 0.1000) + expect_equal(yield_2[12], 0.084) + expect_equal(yield_2[13], 0.066) etr_1 <- data$etr_1 expect_equal(etr_1[1], NA_real_) @@ -144,27 +144,27 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - etr_factor 0.5", { etr_2 <- data$etr_2 expect_equal(etr_2[1], 0) - expect_equal(etr_2[2], 7.7875) - expect_equal(etr_2[3], 13.41) - expect_equal(etr_2[4], 17.7775) - expect_equal(etr_2[5], 21.825) - expect_equal(etr_2[6], 25.6875) - expect_equal(etr_2[7], 29.925) - expect_equal(etr_2[8], 33.345) - expect_equal(etr_2[9], 34.44) - expect_equal(etr_2[10], 35.9375) - expect_equal(etr_2[11], 37.72) - expect_equal(etr_2[12], 33.925) - expect_equal(etr_2[13], 33.75) + expect_equal(etr_2[2], 5.3875) + expect_equal(etr_2[3], 7.3800) + expect_equal(etr_2[4], 12.4475) + expect_equal(etr_2[5], 18.6300) + expect_equal(etr_2[6], 26.4375) + expect_equal(etr_2[7], 34.1050) + expect_equal(etr_2[8], 42.0375) + expect_equal(etr_2[9], 44.7300) + expect_equal(etr_2[10], 45.6250) + expect_equal(etr_2[11], 41.0000) + expect_equal(etr_2[12], 48.3000) + expect_equal(etr_2[13], 49.5000) }) -test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem > 1", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") +test_that("read_junior_pam_data 2026_04_22_junior_pam.csv - fraction_photosystem > 1", { + test_data_file <- testthat::test_path("data", "junior_pam_data", "2026_04_22_junior_pam.csv") expect_error(read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) -test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "junior_pam_20250613.csv") +test_that("read_junior_pam_data 2026_04_22_junior_pam.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { + test_data_file <- testthat::test_path("data", "junior_pam_data", "2026_04_22_junior_pam.csv") data <- read_junior_pam_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par @@ -198,19 +198,19 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem_I expect_equal(yield_1[13], NA_real_) yield_2 <- data$yield_2 - expect_equal(yield_2[1], 0.788) - expect_equal(yield_2[2], 0.623) - expect_equal(yield_2[3], 0.596) - expect_equal(yield_2[4], 0.547) - expect_equal(yield_2[5], 0.485) - expect_equal(yield_2[6], 0.411) - expect_equal(yield_2[7], 0.315) - expect_equal(yield_2[8], 0.234) - expect_equal(yield_2[9], 0.164) - expect_equal(yield_2[10], 0.115) - expect_equal(yield_2[11], 0.092) - expect_equal(yield_2[12], 0.059) - expect_equal(yield_2[13], 0.045) + expect_equal(yield_2[1], 0.743) + expect_equal(yield_2[2], 0.4310) + expect_equal(yield_2[3], 0.3280) + expect_equal(yield_2[4], 0.3830) + expect_equal(yield_2[5], 0.414) + expect_equal(yield_2[6], 0.423) + expect_equal(yield_2[7], 0.359) + expect_equal(yield_2[8], 0.295) + expect_equal(yield_2[9], 0.213) + expect_equal(yield_2[10], 0.146) + expect_equal(yield_2[11], 0.1000) + expect_equal(yield_2[12], 0.084) + expect_equal(yield_2[13], 0.066) etr_1 <- data$etr_1 expect_equal(etr_1[1], NA_real_) @@ -229,16 +229,16 @@ test_that("read_junior_pam_data junior_pam_20250613.csv - fraction_photosystem_I etr_2 <- data$etr_2 expect_equal(etr_2[1], 0) - expect_equal(etr_2[2], 20.9328) - expect_equal(etr_2[3], 36.04608) - expect_equal(etr_2[4], 47.78592) - expect_equal(etr_2[5], 58.6656) - expect_equal(etr_2[6], 69.048) - expect_equal(etr_2[7], 80.4384) - expect_equal(etr_2[8], 89.63136) - expect_equal(etr_2[9], 92.57472) - expect_equal(etr_2[10], 96.6) - expect_equal(etr_2[11], 101.39136) - expect_equal(etr_2[12], 91.1904) - expect_equal(etr_2[13], 90.72) + expect_equal(etr_2[2], 14.48160) + expect_equal(etr_2[3], 19.83744) + expect_equal(etr_2[4], 33.45888) + expect_equal(etr_2[5], 50.07744) + expect_equal(etr_2[6], 71.06400) + expect_equal(etr_2[7], 91.67424) + expect_equal(etr_2[8], 112.99680) + expect_equal(etr_2[9], 120.23424) + expect_equal(etr_2[10], 122.64000) + expect_equal(etr_2[11], 110.20800) + expect_equal(etr_2[12], 129.83040) + expect_equal(etr_2[13], 133.05600) }) diff --git a/src/tests/testthat/test-read_pam_2500_data.R b/src/tests/testthat/test-read_pam_2500_data.R index 97c31c8..d916676 100644 --- a/src/tests/testthat/test-read_pam_2500_data.R +++ b/src/tests/testthat/test-read_pam_2500_data.R @@ -1,20 +1,18 @@ -test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - default", { - test_data_file <- testthat::test_path("data", "20260311_1(2)_pam_2500.CSV") +test_that("read_pam_2500_data 20260422_pam_2500.CSV - default", { + test_data_file <- testthat::test_path("data", "pam_2500_data", "20260422_pam_2500.CSV") data <- read_pam_2500_data(test_data_file) par <- data$par expect_equal(par[1], 0) - expect_equal(par[2], 5) - expect_equal(par[3], 9) - expect_equal(par[4], 34) - expect_equal(par[5], 67) - expect_equal(par[6], 104) - expect_equal(par[7], 144) - expect_equal(par[8], 201) - expect_equal(par[9], 274) - expect_equal(par[10], 366) - expect_equal(par[11], 477) - expect_equal(par[12], 622) + expect_equal(par[2], 7) + expect_equal(par[3], 36) + expect_equal(par[4], 106) + expect_equal(par[5], 203) + expect_equal(par[6], 368) + expect_equal(par[7], 624) + expect_equal(par[8], 986) + expect_equal(par[9], 1391) + expect_equal(par[10], 2020) yield_1 <- data$yield_1 expect_equal(yield_1[1], NA_real_) @@ -27,22 +25,18 @@ test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - default", { expect_equal(yield_1[8], NA_real_) expect_equal(yield_1[9], NA_real_) expect_equal(yield_1[10], NA_real_) - expect_equal(yield_1[11], NA_real_) - expect_equal(yield_1[12], NA_real_) yield_2 <- data$yield_2 - expect_equal(yield_2[1], 0.777) - expect_equal(yield_2[2], 0.706) - expect_equal(yield_2[3], 0.498) - expect_equal(yield_2[4], 0.418) - expect_equal(yield_2[5], 0.371) - expect_equal(yield_2[6], 0.320) - expect_equal(yield_2[7], 0.277) - expect_equal(yield_2[8], 0.232) - expect_equal(yield_2[9], 0.186) - expect_equal(yield_2[10], 0.148) - expect_equal(yield_2[11], 0.119) - expect_equal(yield_2[12], 0.098) + expect_equal(yield_2[1], 0.802) + expect_equal(yield_2[2], 0.466) + expect_equal(yield_2[3], 0.432) + expect_equal(yield_2[4], 0.405) + expect_equal(yield_2[5], 0.338) + expect_equal(yield_2[6], 0.251) + expect_equal(yield_2[7], 0.178) + expect_equal(yield_2[8], 0.126) + expect_equal(yield_2[9], 0.097) + expect_equal(yield_2[10], 0.069) etr_1 <- data$etr_1 expect_equal(etr_1[1], NA_real_) @@ -55,41 +49,35 @@ test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - default", { expect_equal(etr_1[8], NA_real_) expect_equal(etr_1[9], NA_real_) expect_equal(etr_1[10], NA_real_) - expect_equal(etr_1[11], NA_real_) - expect_equal(etr_1[12], NA_real_) etr_2 <- data$etr_2 expect_equal(etr_2[1], 0) - expect_equal(etr_2[2], 1.48260) - expect_equal(etr_2[3], 1.88244) - expect_equal(etr_2[4], 5.969040) - expect_equal(etr_2[5], 10.439940) - expect_equal(etr_2[6], 13.97760) - expect_equal(etr_2[7], 16.752960) - expect_equal(etr_2[8], 19.58544) - expect_equal(etr_2[9], 21.404880) - expect_equal(etr_2[10], 22.75056) - expect_equal(etr_2[11], 23.84046) - expect_equal(etr_2[12], 25.601520) + expect_equal(etr_2[2], 1.37004) + expect_equal(etr_2[3], 6.53184) + expect_equal(etr_2[4], 18.03060) + expect_equal(etr_2[5], 28.81788) + expect_equal(etr_2[6], 38.79456) + expect_equal(etr_2[7], 46.65024) + expect_equal(etr_2[8], 52.17912) + expect_equal(etr_2[9], 56.66934) + expect_equal(etr_2[10], 58.53960) }) -test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - etr-factor 0.5", { - test_data_file <- testthat::test_path("data", "20260311_1(2)_pam_2500.CSV") +test_that("read_pam_2500_data 20260422_pam_2500.CSV - etr-factor 0.5", { + test_data_file <- testthat::test_path("data", "pam_2500_data", "20260422_pam_2500.CSV") data <- read_pam_2500_data(test_data_file, etr_factor = 0.5) par <- data$par - expect_equal(par[1], 0) - expect_equal(par[2], 5) - expect_equal(par[3], 9) - expect_equal(par[4], 34) - expect_equal(par[5], 67) - expect_equal(par[6], 104) - expect_equal(par[7], 144) - expect_equal(par[8], 201) - expect_equal(par[9], 274) - expect_equal(par[10], 366) - expect_equal(par[11], 477) - expect_equal(par[12], 622) + expect_equal(par[1], 0) + expect_equal(par[2], 7) + expect_equal(par[3], 36) + expect_equal(par[4], 106) + expect_equal(par[5], 203) + expect_equal(par[6], 368) + expect_equal(par[7], 624) + expect_equal(par[8], 986) + expect_equal(par[9], 1391) + expect_equal(par[10], 2020) yield_1 <- data$yield_1 expect_equal(yield_1[1], NA_real_) @@ -102,22 +90,18 @@ test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - etr-factor 0.5", { expect_equal(yield_1[8], NA_real_) expect_equal(yield_1[9], NA_real_) expect_equal(yield_1[10], NA_real_) - expect_equal(yield_1[11], NA_real_) - expect_equal(yield_1[12], NA_real_) yield_2 <- data$yield_2 - expect_equal(yield_2[1], 0.777) - expect_equal(yield_2[2], 0.706) - expect_equal(yield_2[3], 0.498) - expect_equal(yield_2[4], 0.418) - expect_equal(yield_2[5], 0.371) - expect_equal(yield_2[6], 0.320) - expect_equal(yield_2[7], 0.277) - expect_equal(yield_2[8], 0.232) - expect_equal(yield_2[9], 0.186) - expect_equal(yield_2[10], 0.148) - expect_equal(yield_2[11], 0.119) - expect_equal(yield_2[12], 0.098) + expect_equal(yield_2[1], 0.802) + expect_equal(yield_2[2], 0.466) + expect_equal(yield_2[3], 0.432) + expect_equal(yield_2[4], 0.405) + expect_equal(yield_2[5], 0.338) + expect_equal(yield_2[6], 0.251) + expect_equal(yield_2[7], 0.178) + expect_equal(yield_2[8], 0.126) + expect_equal(yield_2[9], 0.097) + expect_equal(yield_2[10], 0.069) etr_1 <- data$etr_1 expect_equal(etr_1[1], NA_real_) @@ -130,46 +114,40 @@ test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - etr-factor 0.5", { expect_equal(etr_1[8], NA_real_) expect_equal(etr_1[9], NA_real_) expect_equal(etr_1[10], NA_real_) - expect_equal(etr_1[11], NA_real_) - expect_equal(etr_1[12], NA_real_) etr_2 <- data$etr_2 expect_equal(etr_2[1], 0) - expect_equal(etr_2[2], 0.8825) - expect_equal(etr_2[3], 1.12050) - expect_equal(etr_2[4], 3.553) - expect_equal(etr_2[5], 6.21425) - expect_equal(etr_2[6], 8.320) - expect_equal(etr_2[7], 9.972) - expect_equal(etr_2[8], 11.658) - expect_equal(etr_2[9], 12.741) - expect_equal(etr_2[10], 13.542) - expect_equal(etr_2[11], 14.190750) - expect_equal(etr_2[12], 15.239) + expect_equal(etr_2[2], 0.81550) + expect_equal(etr_2[3], 3.88800) + expect_equal(etr_2[4], 10.73250) + expect_equal(etr_2[5], 17.15350) + expect_equal(etr_2[6], 23.09200) + expect_equal(etr_2[7], 27.76800) + expect_equal(etr_2[8], 31.05900) + expect_equal(etr_2[9], 33.73175) + expect_equal(etr_2[10], 34.84500) }) -test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "20260311_1(2)_pam_2500.CSV") +test_that("read_pam_2500_data 20260422_pam_2500.CSV - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { + test_data_file <- testthat::test_path("data", "pam_2500_data", "20260422_pam_2500.CSV") expect_error(read_pam_2500_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) -test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "20260311_1(2)_pam_2500.CSV") +test_that("read_pam_2500_data 20260422_pam_2500.CSV - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { + test_data_file <- testthat::test_path("data", "pam_2500_data", "20260422_pam_2500.CSV") data <- read_pam_2500_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par expect_equal(par[1], 0) - expect_equal(par[2], 5) - expect_equal(par[3], 9) - expect_equal(par[4], 34) - expect_equal(par[5], 67) - expect_equal(par[6], 104) - expect_equal(par[7], 144) - expect_equal(par[8], 201) - expect_equal(par[9], 274) - expect_equal(par[10], 366) - expect_equal(par[11], 477) - expect_equal(par[12], 622) + expect_equal(par[2], 7) + expect_equal(par[3], 36) + expect_equal(par[4], 106) + expect_equal(par[5], 203) + expect_equal(par[6], 368) + expect_equal(par[7], 624) + expect_equal(par[8], 986) + expect_equal(par[9], 1391) + expect_equal(par[10], 2020) yield_1 <- data$yield_1 expect_equal(yield_1[1], NA_real_) @@ -182,22 +160,18 @@ test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - fraction_photosystem_ expect_equal(yield_1[8], NA_real_) expect_equal(yield_1[9], NA_real_) expect_equal(yield_1[10], NA_real_) - expect_equal(yield_1[11], NA_real_) - expect_equal(yield_1[12], NA_real_) yield_2 <- data$yield_2 - expect_equal(yield_2[1], 0.777) - expect_equal(yield_2[2], 0.706) - expect_equal(yield_2[3], 0.498) - expect_equal(yield_2[4], 0.418) - expect_equal(yield_2[5], 0.371) - expect_equal(yield_2[6], 0.320) - expect_equal(yield_2[7], 0.277) - expect_equal(yield_2[8], 0.232) - expect_equal(yield_2[9], 0.186) - expect_equal(yield_2[10], 0.148) - expect_equal(yield_2[11], 0.119) - expect_equal(yield_2[12], 0.098) + expect_equal(yield_2[1], 0.802) + expect_equal(yield_2[2], 0.466) + expect_equal(yield_2[3], 0.432) + expect_equal(yield_2[4], 0.405) + expect_equal(yield_2[5], 0.338) + expect_equal(yield_2[6], 0.251) + expect_equal(yield_2[7], 0.178) + expect_equal(yield_2[8], 0.126) + expect_equal(yield_2[9], 0.097) + expect_equal(yield_2[10], 0.069) etr_1 <- data$etr_1 expect_equal(etr_1[1], NA_real_) @@ -210,20 +184,16 @@ test_that("read_pam_2500_data 20260311_1(2)_pam_2500.CSV - fraction_photosystem_ expect_equal(etr_1[8], NA_real_) expect_equal(etr_1[9], NA_real_) expect_equal(etr_1[10], NA_real_) - expect_equal(etr_1[11], NA_real_) - expect_equal(etr_1[12], NA_real_) etr_2 <- data$etr_2 expect_equal(etr_2[1], 0) - expect_equal(etr_2[2], 2.37216) - expect_equal(etr_2[3], 3.011904) - expect_equal(etr_2[4], 9.5504640) - expect_equal(etr_2[5], 16.7039040) - expect_equal(etr_2[6], 22.36416) - expect_equal(etr_2[7], 26.804736) - expect_equal(etr_2[8], 31.3367040) - expect_equal(etr_2[9], 34.2478080) - expect_equal(etr_2[10], 36.4008960) - expect_equal(etr_2[11], 38.1447360) - expect_equal(etr_2[12], 40.9624320) + expect_equal(etr_2[2], 2.192064) + expect_equal(etr_2[3], 10.450944) + expect_equal(etr_2[4], 28.848960) + expect_equal(etr_2[5], 46.108608) + expect_equal(etr_2[6], 62.071296) + expect_equal(etr_2[7], 74.640384) + expect_equal(etr_2[8], 83.486592) + expect_equal(etr_2[9], 90.670944) + expect_equal(etr_2[10], 93.663360) }) diff --git a/src/tests/testthat/test-read_universal_data.R b/src/tests/testthat/test-read_universal_data.R index e07470e..ba3d7fb 100644 --- a/src/tests/testthat/test-read_universal_data.R +++ b/src/tests/testthat/test-read_universal_data.R @@ -1,5 +1,5 @@ test_that("read_universal_data universal_data.csv - default", { - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") data <- read_universal_data(test_data_file) par <- data$par @@ -99,7 +99,7 @@ test_that("read_universal_data universal_data.csv - default", { }) test_that("read_universal_data universal_data.csv - etr_factor 0.5", { - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") data <- read_universal_data(test_data_file, etr_factor = 0.5) par <- data$par @@ -199,12 +199,12 @@ test_that("read_universal_data universal_data.csv - etr_factor 0.5", { }) test_that("read_universal_data universal_data.csv - fraction_photosystem > 1", { - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") expect_error(read_universal_data(test_data_file, fraction_photosystem_I = 0.9, fraction_photosystem_II = 0.2)) }) test_that("read_universal_data universal_data.csv - fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8", { - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") data <- read_universal_data(test_data_file, fraction_photosystem_I = 0.2, fraction_photosystem_II = 0.8) par <- data$par diff --git a/src/tests/testthat/test-relative_root_mean_squared_error.R b/src/tests/testthat/test-relative_root_mean_squared_error.R index 026f461..430a398 100644 --- a/src/tests/testthat/test-relative_root_mean_squared_error.R +++ b/src/tests/testthat/test-relative_root_mean_squared_error.R @@ -1,7 +1,7 @@ test_that("test-relative_root_mean_squared_error - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) @@ -13,7 +13,7 @@ test_that("test-relative_root_mean_squared_error - linux", { }) test_that("test-relative_root_mean_squared_error", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) diff --git a/src/tests/testthat/test-root_mean_squared_error.R b/src/tests/testthat/test-root_mean_squared_error.R index 8606069..a6066dc 100644 --- a/src/tests/testthat/test-root_mean_squared_error.R +++ b/src/tests/testthat/test-root_mean_squared_error.R @@ -1,7 +1,7 @@ test_that("test-root_mean_squared_error - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) @@ -12,7 +12,7 @@ test_that("test-root_mean_squared_error - linux", { }) test_that("test-root_mean_squared_error", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) etr_regression_data <- get_etr_regression_data_from_model_result(model_result) diff --git a/src/tests/testthat/test-universal_data_etr_I.R b/src/tests/testthat/test-universal_data_etr_I.R index e1ac1e3..d2592c3 100644 --- a/src/tests/testthat/test-universal_data_etr_I.R +++ b/src/tests/testthat/test-universal_data_etr_I.R @@ -1,7 +1,7 @@ test_that("test-universal_data_etr_I - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") data <- read_universal_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) @@ -75,7 +75,7 @@ test_that("test-universal_data_etr_I - linux", { }) test_that("test-universal_data_etr_I", { - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") data <- read_universal_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) @@ -92,7 +92,7 @@ test_that("test-universal_data_etr_I", { }) test_that("test-universal_data_etr_I plot", { - test_data_file <- testthat::test_path("data", "universal_data.csv") + test_data_file <- testthat::test_path("data", "universal_data", "universal_data.csv") data <- read_universal_data(test_data_file) eilers_peeters <- eilers_peeters_modified(eilers_peeters_generate_regression_ETR_I(data)) diff --git a/src/tests/testthat/test-vollenweider_etr_I.R b/src/tests/testthat/test-vollenweider_etr_I.R index 0c7bda5..ac1fb8d 100644 --- a/src/tests/testthat/test-vollenweider_etr_I.R +++ b/src/tests/testthat/test-vollenweider_etr_I.R @@ -1,7 +1,7 @@ test_that("test-vollenweider_etr_I generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_I(data) @@ -17,14 +17,14 @@ test_that("test-vollenweider_etr_I generate regression 20240925.csv - linux", { }) test_that("test-vollenweider_etr_I generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_I(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-vollenweider_etr_I control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_I(data) @@ -43,9 +43,9 @@ test_that("test-vollenweider_etr_I control plot 20240925.csv", { }) test_that("test-vollenweider_etr_I generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_I(data) model_result <- vollenweider_modified(model_result) @@ -68,7 +68,7 @@ test_that("test-vollenweider_etr_I generate regression modified 20240925.csv - l }) test_that("test-vollenweider_etr_I generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_I(data) expect_no_error(validate_model_result(model_result)) @@ -78,7 +78,7 @@ test_that("test-vollenweider_etr_I generate regression modified 20240925.csv", { }) test_that("test-vollenweider_etr_I modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_I(data) model_result <- vollenweider_modified(model_result) diff --git a/src/tests/testthat/test-vollenweider_etr_II.R b/src/tests/testthat/test-vollenweider_etr_II.R index ad71827..3aac649 100644 --- a/src/tests/testthat/test-vollenweider_etr_II.R +++ b/src/tests/testthat/test-vollenweider_etr_II.R @@ -1,7 +1,7 @@ test_that("test-vollenweider_etr_II generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_II(data) @@ -17,14 +17,14 @@ test_that("test-vollenweider_etr_II generate regression 20240925.csv - linux", { }) test_that("test-vollenweider_etr_II generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_II(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-vollenweider_etr_II control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_II(data) @@ -43,9 +43,9 @@ test_that("test-vollenweider_etr_II control plot 20240925.csv", { }) test_that("test-vollenweider_etr_II generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_II(data) model_result <- vollenweider_modified(model_result) @@ -68,7 +68,7 @@ test_that("test-vollenweider_etr_II generate regression modified 20240925.csv - }) test_that("test-vollenweider_etr_II generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_II(data) @@ -79,7 +79,7 @@ test_that("test-vollenweider_etr_II generate regression modified 20240925.csv", }) test_that("test-vollenweider_etr_II modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- vollenweider_generate_regression_ETR_II(data) model_result <- vollenweider_modified(model_result) diff --git a/src/tests/testthat/test-walsby_etr_I.R b/src/tests/testthat/test-walsby_etr_I.R index 6da7dad..f5b383c 100644 --- a/src/tests/testthat/test-walsby_etr_I.R +++ b/src/tests/testthat/test-walsby_etr_I.R @@ -1,7 +1,7 @@ test_that("test-walsby_etr_I generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_I(data) @@ -12,14 +12,14 @@ test_that("test-walsby_etr_I generate regression 20240925.csv - linux", { }) test_that("test-walsby_etr_I generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_I(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-walsby_etr_I control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_I(data) @@ -38,9 +38,9 @@ test_that("test-walsby_etr_I control plot 20240925.csv", { }) test_that("test-walsby_etr_I generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_I(data) model_result <- walsby_modified(model_result) @@ -63,7 +63,7 @@ test_that("test-walsby_etr_I generate regression modified 20240925.csv - linux", }) test_that("test-walsby_etr_I generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_I(data) @@ -74,7 +74,7 @@ test_that("test-walsby_etr_I generate regression modified 20240925.csv", { }) test_that("test-walsby_etr_I modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_I(data) model_result <- walsby_modified(model_result) diff --git a/src/tests/testthat/test-walsby_etr_II.R b/src/tests/testthat/test-walsby_etr_II.R index 55d94c5..e3b28fb 100644 --- a/src/tests/testthat/test-walsby_etr_II.R +++ b/src/tests/testthat/test-walsby_etr_II.R @@ -1,7 +1,7 @@ test_that("test-walsby_etr_II generate regression 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) @@ -12,14 +12,14 @@ test_that("test-walsby_etr_II generate regression 20240925.csv - linux", { }) test_that("test-walsby_etr_II generate regression 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) expect_no_error(validate_model_result(model_result)) }) test_that("test-walsby_etr_II control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) @@ -38,9 +38,9 @@ test_that("test-walsby_etr_II control plot 20240925.csv", { }) test_that("test-walsby_etr_II generate regression modified 20240925.csv - linux", { - skip_if_not(is_debian_or_ubuntu()) + skip_if_not(is_reference_platform()) - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) model_result <- walsby_modified(model_result) @@ -63,7 +63,7 @@ test_that("test-walsby_etr_II generate regression modified 20240925.csv - linux" }) test_that("test-walsby_etr_II generate regression modified 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) @@ -74,7 +74,7 @@ test_that("test-walsby_etr_II generate regression modified 20240925.csv", { }) test_that("test-walsby_etr_II modified control plot 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) model_result <- walsby_modified(model_result) diff --git a/src/tests/testthat/test-write_model_result_csv.R b/src/tests/testthat/test-write_model_result_csv.R index a968478..2e51656 100644 --- a/src/tests/testthat/test-write_model_result_csv.R +++ b/src/tests/testthat/test-write_model_result_csv.R @@ -1,5 +1,5 @@ test_that("test-write_model_result_csv - walsby_modified - 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data) model_result <- walsby_modified(model_result) @@ -52,7 +52,7 @@ test_that("test-write_model_result_csv - walsby_modified - 20240925.csv", { }) test_that("test-write_model_result_csv - walsby - 20240925.csv", { - test_data_file <- testthat::test_path("data", "20240925.csv") + test_data_file <- testthat::test_path("data", "dual_pam_data", "20240925.csv") data <- read_dual_pam_data(test_data_file) model_result <- walsby_generate_regression_ETR_II(data)