├── LICENSE ├── .Rbuildignore ├── .gitignore ├── inst └── extdata │ ├── Fast.xlsx │ └── Empty_2.xlsx ├── NAMESPACE ├── readphoto.Rproj ├── man ├── regex_read.Rd ├── read_regex68.Rd ├── read_6400.Rd ├── read_6800.Rd ├── read_bat_6800.Rd ├── recomp_6800.Rd ├── read_bat_6400.Rd ├── recomp_6400.Rd └── xlconnect_read.Rd ├── DESCRIPTION ├── README.md ├── R ├── read_regex68.R ├── read_6400.R ├── read_6800.R ├── regex_read.R ├── read_bat_6800.R ├── read_bat_6400.R ├── recomp_6400.R ├── recomp_6800.R └── xls_read.R └── LICENSE.md /LICENSE: -------------------------------------------------------------------------------- 1 | YEAR: 2020 2 | COPYRIGHT HOLDER: Zhu Jiedong 3 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^LICENSE\.md$ 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | -------------------------------------------------------------------------------- /inst/extdata/Fast.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhujiedong/readphoto/master/inst/extdata/Fast.xlsx -------------------------------------------------------------------------------- /inst/extdata/Empty_2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhujiedong/readphoto/master/inst/extdata/Empty_2.xlsx -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(read_6400) 4 | export(read_6800) 5 | export(read_bat_6400) 6 | export(read_bat_6800) 7 | export(read_regex68) 8 | export(recomp_6400) 9 | export(recomp_6800) 10 | export(regex_read) 11 | export(xlconnect_read) 12 | importFrom(stringr,str_split) 13 | importFrom(utils,read.delim) 14 | importFrom(utils,tail) 15 | -------------------------------------------------------------------------------- /readphoto.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: XeLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | -------------------------------------------------------------------------------- /man/regex_read.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/regex_read.R 3 | \name{regex_read} 4 | \alias{regex_read} 5 | \title{Reads files from the LI-6800} 6 | \usage{ 7 | regex_read(filename) 8 | } 9 | \arguments{ 10 | \item{filename}{path and name of your data.} 11 | } 12 | \value{ 13 | read_6800 imports a LI-6800 raw data file as a data frame 14 | } 15 | \description{ 16 | \code{read_6800} Reads LI-6800 raw data files, which are delimited by tabs. 17 | } 18 | -------------------------------------------------------------------------------- /man/read_regex68.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_regex68.R 3 | \name{read_regex68} 4 | \alias{read_regex68} 5 | \title{read all raw data in one file measured by LI-6800} 6 | \usage{ 7 | read_regex68(file_dir) 8 | } 9 | \arguments{ 10 | \item{file_dir}{is the file directory only contains all the measured 11 | raw data.} 12 | } 13 | \description{ 14 | help to read all raw data files with a command. 15 | } 16 | \examples{ 17 | \dontrun{ 18 | library(readphoto) 19 | read_regex('./6800') 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /man/read_6400.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_6400.R 3 | \name{read_6400} 4 | \alias{read_6400} 5 | \title{Reads files from the LI-6400} 6 | \usage{ 7 | read_6400(filename, data_start = 27) 8 | } 9 | \arguments{ 10 | \item{filename}{path and name of your data.} 11 | 12 | \item{data_start}{the start of your data(without headline)} 13 | } 14 | \value{ 15 | read_6400 imports a LI-6400 raw data file as a data frame 16 | } 17 | \description{ 18 | \code{read_6400} Reads LI-6400 raw data files, which are delimited by tabs. 19 | } 20 | -------------------------------------------------------------------------------- /man/read_6800.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_6800.R 3 | \name{read_6800} 4 | \alias{read_6800} 5 | \title{Reads files from the LI-6800} 6 | \usage{ 7 | read_6800(filename, data_start = 56) 8 | } 9 | \arguments{ 10 | \item{filename}{path and name of your data.} 11 | 12 | \item{data_start}{the start of your data(without headline)} 13 | } 14 | \value{ 15 | read_6800 imports a LI-6800 raw data file as a data frame 16 | } 17 | \description{ 18 | \code{read_6800} Reads LI-6800 raw data files, which are delimited by tabs. 19 | } 20 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Type: Package 2 | Package: readphoto 3 | Version: 0.0.1 4 | Title: read LI-6800 and LI-6400 raw data file in batch 5 | Description: read LI-6800 raw data file in batch. 6 | Authors@R: c( 7 | person("Jiedong", "Zhu", , "zhujiedong@yeah.net", c("aut", "cre")) 8 | ) 9 | Encoding: UTF-8 10 | Depends: R (>= 3.6.0) 11 | Imports: 12 | stringr, 13 | readxl, 14 | stringi, 15 | XLConnect, 16 | readr 17 | LazyData: yes 18 | License: MIT + file LICENSE 19 | Packaged: 2018-07-17 20 | Author: Jiedong Zhu [aut, cre] 21 | Maintainer: Jiedong Zhu 22 | RoxygenNote: 7.1.1 23 | -------------------------------------------------------------------------------- /man/read_bat_6800.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_bat_6800.R 3 | \name{read_bat_6800} 4 | \alias{read_bat_6800} 5 | \title{read all raw data in one file measured by LI-6800} 6 | \usage{ 7 | read_bat_6800(file_dir, data_start = 56) 8 | } 9 | \arguments{ 10 | \item{file_dir}{is the file directory only contains all the measured 11 | raw data.} 12 | 13 | \item{data_start}{the start of your data(without headline)} 14 | } 15 | \description{ 16 | help to read all raw data files with a command. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | library(readphoto) 21 | read_bat_6800('./6800') 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /man/recomp_6800.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/recomp_6800.R 3 | \name{recomp_6800} 4 | \alias{recomp_6800} 5 | \title{recompute the raw data in one file measured by LI-6800} 6 | \usage{ 7 | recomp_6800(file_dir, S = 6, K = 0.5) 8 | } 9 | \arguments{ 10 | \item{file_dir}{is the file directory only contains all the measured 11 | raw data.} 12 | 13 | \item{S}{area of the leaf measured} 14 | 15 | \item{K}{stomatal ratio} 16 | } 17 | \description{ 18 | help to read all raw data files with a command. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(readphoto) 23 | recomp_6800('./6800') 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /man/read_bat_6400.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/read_bat_6400.R 3 | \name{read_bat_6400} 4 | \alias{read_bat_6400} 5 | \title{read all raw data in one file measured by LI-6400} 6 | \usage{ 7 | read_bat_6400(file_dir, header_line = 17, data_start = 27) 8 | } 9 | \arguments{ 10 | \item{file_dir}{is the file directory only contains all the measured 11 | raw data.} 12 | 13 | \item{header_line}{ther start of your data with header.} 14 | 15 | \item{data_start}{the start of your data(without headline)} 16 | } 17 | \description{ 18 | help to read all raw data files with a command. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | library(readphoto) 23 | read_bat_6400s('./6400') 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # readphoto 2 | read LI-6400 and LI-6800 data in batch 3 | 4 | # read_bat_6400 5 | 6 | ``` 7 | read_bat_6400 <- function(file_dir, header_line = 17, data_start = 27) 8 | ``` 9 | 10 | file_dir are the path of your raw data file, it should be a folder only contain raw data files. 11 | 12 | header_line are the start of your measured data header. 13 | 14 | data_start are the start line of your measured data. 15 | 16 | the output data frame contains a column named files, its the name of your file where the data from. 17 | 18 | # read_bat_6800 19 | 20 | ``` 21 | read_bat_6800(file_dir, skiplines = 53) 22 | ``` 23 | 24 | file_dir are the path of your raw data file, it should be a folder only contain raw data files. 25 | skiplines are the lines before your start of your measured data. 26 | 27 | -------------------------------------------------------------------------------- /man/recomp_6400.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/recomp_6400.R 3 | \name{recomp_6400} 4 | \alias{recomp_6400} 5 | \title{recompute the raw data in one file measured by LI-6400} 6 | \usage{ 7 | recomp_6400(file_dir, header_line = 17, data_start = 27, S = 6, K = 0.5) 8 | } 9 | \arguments{ 10 | \item{file_dir}{is the file directory only contains all the measured 11 | raw data.} 12 | 13 | \item{header_line}{ther start of your data with header.} 14 | 15 | \item{data_start}{the start of your data(without headline)} 16 | 17 | \item{S}{area of the leaf measured} 18 | 19 | \item{K}{stomatal ratio} 20 | } 21 | \description{ 22 | help to read all raw data files with a command. 23 | } 24 | \examples{ 25 | \dontrun{ 26 | library(readphoto) 27 | recomp_6400('./6400') 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /R/read_regex68.R: -------------------------------------------------------------------------------- 1 | #' read all raw data in one file measured by LI-6800 2 | #' @description help to read all raw data files with a command. 3 | #' 4 | #' @param file_dir is the file directory only contains all the measured 5 | #' raw data. 6 | #' 7 | #' @examples 8 | #' \dontrun{ 9 | #' library(readphoto) 10 | #' read_regex('./6800') 11 | #' } 12 | #' 13 | #' @export 14 | #' 15 | 16 | read_regex68 <- function(file_dir){ 17 | # use the first file's header as the colnames ----------------------------- 18 | 19 | file_names <- list.files(path = file_dir, full.names = TRUE) 20 | match.fun("regex_read") 21 | 22 | # apply lyapply to cycle all the files ------------------------------------ 23 | 24 | data_list <- lapply(file_names, regex_read) 25 | df <- do.call("rbind", data_list) 26 | 27 | return(df) 28 | } 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /man/xlconnect_read.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/xls_read.R 3 | \name{xlconnect_read} 4 | \alias{xlconnect_read} 5 | \title{Reads files from the LI-6800} 6 | \usage{ 7 | xlconnect_read(path, start_row = 17, S = NULL) 8 | } 9 | \arguments{ 10 | \item{path}{path of your data.} 11 | 12 | \item{start_row}{start of measured data} 13 | 14 | \item{S}{recompute by providing diffferen leaf areas, if the area does not need to change 15 | , enter one single value of the actual area, else, enter a vector of the same length 16 | with the measured data. The default NULL means you do not want to change the leaf area.} 17 | } 18 | \value{ 19 | read_6800 imports a LI-6800 raw data file as a data frame 20 | } 21 | \description{ 22 | \code{xlconnect_read} Reads LI-6800 raw data files, which are delimited by tabs. 23 | } 24 | -------------------------------------------------------------------------------- /R/read_6400.R: -------------------------------------------------------------------------------- 1 | #' Reads files from the LI-6400 2 | #' 3 | #' \code{read_6400} Reads LI-6400 raw data files, which are delimited by tabs. 4 | #' 5 | #' @param filename path and name of your data. 6 | #' @param data_start the start of your data(without headline) 7 | #' @return read_6400 imports a LI-6400 raw data file as a data frame 8 | #' @importFrom utils read.delim 9 | #' @importFrom stringr str_split 10 | #' @importFrom utils tail 11 | #' @export 12 | 13 | read_6400 <- function(filename, data_start = 27){ 14 | 15 | data <- read.delim(filename, sep = "\t", skip = data_start - 1, 16 | header = FALSE, fill = TRUE, stringsAsFactors = FALSE) 17 | # split with the / of directory path of filename 18 | rm_name <- str_split(filename, "\\/") 19 | # only use the last part of the split list, ie data file name 20 | data$files <- rep(tail(rm_name[[1]], 1), nrow(data)) 21 | return(data) 22 | } 23 | -------------------------------------------------------------------------------- /R/read_6800.R: -------------------------------------------------------------------------------- 1 | #' Reads files from the LI-6800 2 | #' 3 | #' \code{read_6800} Reads LI-6800 raw data files, which are delimited by tabs. 4 | #' 5 | #' @param filename path and name of your data. 6 | #' @param data_start the start of your data(without headline) 7 | #' @return read_6800 imports a LI-6800 raw data file as a data frame 8 | #' @importFrom utils read.delim 9 | #' @importFrom stringr str_split 10 | #' @importFrom utils tail 11 | #' @export 12 | 13 | read_6800 <- function(filename, data_start = 56){ 14 | 15 | # only read measured data ------------------------------------------------- 16 | 17 | data <- read.delim(filename, sep = "\t", skip = data_start-1, 18 | header = FALSE, fill = TRUE, stringsAsFactors = FALSE) 19 | # split with the / of directory path of filename 20 | rm_name <- str_split(filename, "\\/") 21 | # only use the last part of the split list, ie data file name 22 | data$files <- rep(tail(rm_name[[1]], 1), nrow(data)) 23 | 24 | # Assign column names to data ----------------------------- 25 | return(data) 26 | } 27 | -------------------------------------------------------------------------------- /R/regex_read.R: -------------------------------------------------------------------------------- 1 | #' Reads files from the LI-6800 2 | #' 3 | #' \code{read_6800} Reads LI-6800 raw data files, which are delimited by tabs. 4 | #' 5 | #' @param filename path and name of your data. 6 | #' @return read_6800 imports a LI-6800 raw data file as a data frame 7 | #' @export 8 | 9 | regex_read <- function(filename){ 10 | 11 | raw68 <- readLines(filename) 12 | pattern <- "^\\[Header\\](\\s|\\S)+(\\[Data\\])" 13 | rawone <- stringi::stri_flatten(raw68, collapse = '\n') 14 | 15 | # data start with [Data], header between [Header] and [Data] 16 | header <- stringi::stri_extract_all(rawone, regex = pattern) 17 | data_meas <- stringi::stri_split(rawone, regex = pattern, 18 | omit_empty = TRUE) 19 | 20 | data_temp <- stringi::stri_split(data_meas,regex = "\n", simplify = TRUE) 21 | data_temp <- t(data_temp) 22 | 23 | data_name <- readr::read_tsv(data_temp, skip = 2) 24 | data_noname <- readr::read_tsv(data_temp, skip = 4, col_names = names(data_name)) 25 | data_noname$file_name <- filename 26 | 27 | return(data_noname) 28 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2020 Zhu Jiedong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /R/read_bat_6800.R: -------------------------------------------------------------------------------- 1 | #' read all raw data in one file measured by LI-6800 2 | #' @description help to read all raw data files with a command. 3 | #' 4 | #' @param file_dir is the file directory only contains all the measured 5 | #' raw data. 6 | #' @param data_start the start of your data(without headline) 7 | #' 8 | #' @examples 9 | #' \dontrun{ 10 | #' library(readphoto) 11 | #' read_bat_6800('./6800') 12 | #' } 13 | #' 14 | #' @export 15 | #' 16 | 17 | read_bat_6800 <- function(file_dir, data_start = 56){ 18 | # use the first file's header as the colnames ----------------------------- 19 | 20 | file_names <- list.files(path = file_dir, full.names = TRUE) 21 | data_name <- read.delim(file_names[[1]], sep = "\t", skip = data_start-3) 22 | 23 | # apply lyapply to cycle all the files ------------------------------------ 24 | 25 | read_6800 <- match.fun("read_6800") 26 | data_list <- lapply(file_names, read_6800, data_start = data_start) 27 | df <- do.call("rbind", data_list) 28 | colnames(df) <- c(colnames(data_name), "files") 29 | df_name <- data.frame(files = df$files) 30 | df <- cbind(df_name, df[, -(ncol(df))]) 31 | 32 | return(df) 33 | } 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /R/read_bat_6400.R: -------------------------------------------------------------------------------- 1 | #' read all raw data in one file measured by LI-6400 2 | #' @description help to read all raw data files with a command. 3 | #' 4 | #' @param file_dir is the file directory only contains all the measured 5 | #' raw data. 6 | #' @param data_start the start of your data(without headline) 7 | #' @param header_line ther start of your data with header. 8 | #' 9 | #' @examples 10 | #' \dontrun{ 11 | #' library(readphoto) 12 | #' read_bat_6400s('./6400') 13 | #' } 14 | #' 15 | #' @export 16 | #' 17 | 18 | read_bat_6400 <- function(file_dir, header_line = 17, data_start = 27){ 19 | 20 | # use the first file's header as the colnames ----------------------------- 21 | 22 | file_names <- list.files(file_dir, full.names = TRUE) 23 | data_name <- read.delim(file_names[[1]], sep = "\t", skip = header_line - 1) 24 | 25 | # apply lyapply to cycle all the files ------------------------------------ 26 | 27 | read_6400 <- match.fun("read_6400") 28 | data_list <- lapply(file_names, read_6400, data_start = data_start) 29 | df <- do.call("rbind", data_list) 30 | colnames(df) <- c(colnames(data_name), "files") 31 | df <- df[which(df$FTime>0), ] 32 | df_name <- data.frame(files = df$files) 33 | df <- cbind(df_name, df[, -(ncol(df))]) 34 | return(df) 35 | } 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /R/recomp_6400.R: -------------------------------------------------------------------------------- 1 | #' recompute the raw data in one file measured by LI-6400 2 | #' @description help to read all raw data files with a command. 3 | #' 4 | #' @param file_dir is the file directory only contains all the measured 5 | #' raw data. 6 | #' @param data_start the start of your data(without headline) 7 | #' @param header_line ther start of your data with header. 8 | #' @param S area of the leaf measured 9 | #' @param K stomatal ratio 10 | #' @examples 11 | #' \dontrun{ 12 | #' library(readphoto) 13 | #' recomp_6400('./6400') 14 | #' } 15 | #' 16 | #' @export 17 | #' 18 | #' 19 | recomp_6400 <- function(file_dir, header_line = 17, data_start = 27, S = 6, K = 0.5){ 20 | 21 | read_bat_6400 <- match.fun(read_bat_6400) 22 | 23 | df <- read_bat_6400(file_dir, header_line = header_line, data_start = data_start) 24 | 25 | # A and E in mmol --------------------------------------------------------- 26 | 27 | df$Trmmol =df$Flow *(df$H2OS-df$H2OR)/(1000-df$H2OS)/(100*S)*1000 28 | 29 | df$Photo = df$Flow*(df$CO2R-df$CO2S*(1000-df$H2OR)/(1000-df$H2OS))/(100*S) 30 | 31 | # gtw --------------------------------------------------------------------- 32 | 33 | df$SVTleaf = 0.61365*exp(17.502*df$CTleaf/(240.97+df$CTleaf)) 34 | df$h2o_i = df$SVTleaf*1000/df$Press 35 | df$CndTotal = df$Trmmol*((1000-(df$h2o_i+df$H2OS)/2))/(df$h2o_i-df$H2OS)/1000 36 | 37 | 38 | 39 | # gbw single side --------------------------------------------------------- 40 | df$BLC_1=S*df$BLCslope+df$BLCoffst 41 | 42 | 43 | # gsw --------------------------------------------------------------------- 44 | df$Kf = (K^2+1)/(K+1)^2 45 | df$Cond = 1/(1/df$CndTotal-df$Kf/df$BLC_1) 46 | 47 | 48 | # Ci ---------------------------------------------------------------------- 49 | df$gtc = 1/(1.6/df$Cond + 1.378*df$Kf/df$BLC_1) 50 | df$Ci=((df$gtc-df$Trmmol/2000)*df$CO2S-df$Photo)/(df$gtc+df$Trmmol/2000) 51 | 52 | return(df) 53 | } 54 | -------------------------------------------------------------------------------- /R/recomp_6800.R: -------------------------------------------------------------------------------- 1 | #' recompute the raw data in one file measured by LI-6800 2 | #' @description help to read all raw data files with a command. 3 | #' 4 | #' @param file_dir is the file directory only contains all the measured 5 | #' raw data. 6 | #' @param S area of the leaf measured 7 | #' @param K stomatal ratio 8 | #' 9 | #' @examples 10 | #' \dontrun{ 11 | #' library(readphoto) 12 | #' recomp_6800('./6800') 13 | #' } 14 | #' 15 | #' @export 16 | #' 17 | recomp_6800 <- function(file_dir, S = 6, K = 0.5){ 18 | 19 | read_regex68 <- match.fun("read_regex68") 20 | 21 | df <- read_regex68(file_dir) 22 | # transpiration ----------------------------------------------------------- 23 | 24 | df$E = df$CorrFact * df$Flow * (df$H2O_s - df$H2O_r) / (100 * S *(1000 - df$CorrFact * df$H2O_s)) 25 | 26 | # assimilation ------------------------------------------------------------ 27 | 28 | df$A = df$Flow*df$CorrFact*(df$CO2_r-df$CO2_s*(1000-df$CorrFact*df$H2O_r)/(1000-df$CorrFact*df$H2O_s))/(100*S) 29 | 30 | # gbw --------------------------------------------------------------------- 31 | 32 | df$gbw=df$blfa_3+df$blfa_2*S+df$blfa_1*S*S 33 | 34 | # gtw --------------------------------------------------------------------- 35 | 36 | df$gtw=df$E*(1000-(1000*0.61365*exp(17.502*df$TleafCnd/(240.97+df$TleafCnd))/(df$Pa+df$VPcham)+df$H2O_s)/2)/(1000*0.61365*exp(17.502*df$TleafCnd/(240.97+df$TleafCnd))/(df$Pa+df$VPcham)-df$H2O_s) 37 | 38 | # gsw --------------------------------------------------------------------- 39 | 40 | df$gsw = 2/((1/df$gtw-1/df$gbw)+sqrt((1/df$gtw-1/df$gbw)*(1/df$gtw-1/df$gbw) + 4*K/((K+1)*(K+1))*(2*1/df$gtw*1/df$gbw-1/df$gbw*1/df$gbw))) 41 | 42 | # gtc --------------------------------------------------------------------- 43 | 44 | df$gtc=1/((K+1)/(df$gsw/1.6)+1/(df$gbw/1.37)) + K/((K+1)/(df$gsw/1.6) + K/(df$gsw/1.37)) 45 | 46 | # ci ---------------------------------------------------------------------- 47 | df$Ci=((df$gtc-df$E/2)*df$Ca-df$A)/(df$gtc+df$E/2) 48 | 49 | return(df) 50 | } -------------------------------------------------------------------------------- /R/xls_read.R: -------------------------------------------------------------------------------- 1 | #' Reads files from the LI-6800 2 | #' 3 | #' \code{xlconnect_read} Reads LI-6800 raw data files, which are delimited by tabs. 4 | #' 5 | #' @param path path of your data. 6 | #' @param start_row start of measured data 7 | #' @param S recompute by providing diffferen leaf areas, if the area does not need to change 8 | #' , enter one single value of the actual area, else, enter a vector of the same length 9 | #' with the measured data. The default NULL means you do not want to change the leaf area. 10 | #' 11 | #' @return read_6800 imports a LI-6800 raw data file as a data frame 12 | #' @export 13 | 14 | xlconnect_read <- function(path, start_row = 17, S = NULL) { 15 | #Loading an Excel workbook. Both .xls and .xlsx file formats can be used. 16 | wb <- XLConnect::loadWorkbook(path) 17 | # read group name and header, without header, and paste0 them as names 18 | # to avoid repeated names such as time 19 | # group_name <- 20 | # XLConnect::readWorksheet( 21 | # wb, 22 | # sheet = 1, 23 | # startRow = start_row - 3, 24 | # endRow = start_row - 3, 25 | # header = FALSE 26 | # ) 27 | header_name <- 28 | XLConnect::readWorksheet( 29 | wb, 30 | sheet = 1, 31 | startRow = start_row - 2, 32 | endRow = start_row - 2, 33 | header = FALSE 34 | ) 35 | if (is.null(S)) { 36 | #reading worksheets of an Excel workbook 37 | df <- XLConnect::readWorksheet(wb, 38 | sheet = 1, 39 | startRow = start_row, 40 | header = FALSE) 41 | names(df) <- header_name 42 | } else{ 43 | # new_name <- paste0(group_name, "_", header_name) 44 | 45 | XLConnect::writeWorksheet( 46 | wb, 47 | data = S, 48 | sheet = 1, 49 | startRow = start_row, 50 | startCol = which(header_name == "S"), 51 | header = FALSE 52 | ) 53 | XLConnect::setForceFormulaRecalculation(wb, sheet = 1, TRUE) 54 | 55 | df <- XLConnect::readWorksheet(wb, 56 | sheet = 1, 57 | startRow = start_row, 58 | header = FALSE) 59 | names(df) <- header_name 60 | } 61 | df 62 | } 63 | --------------------------------------------------------------------------------