Skip to content

Commit

Permalink
working version of read_licor()
Browse files Browse the repository at this point in the history
  • Loading branch information
cdmuir committed Apr 12, 2023
1 parent 6611d44 commit af6a406
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 52 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: photosynthesis
Version: 2.1.2.9000
Version: 2.1.2.9001
Date: 2023-04-11
Title: Tools for Plant Ecophysiology & Modeling
Authors@R: c(
Expand Down Expand Up @@ -28,6 +28,7 @@ Imports: checkmate (>= 2.0.0),
nlme (>= 3.1-147),
progress (>= 1.2.0),
purrr (>= 0.3.3),
readr (>= 2.0.0),
rlang (>= 0.4.6),
stats (>= 4.0.0),
stringr (>= 1.4.0),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export(photosynthesis)
export(ppm2pa)
export(print_graphs)
export(read_li6800)
export(read_licor)
export(required_variables)
export(simulate_error)
export(t_response_arrhenius)
Expand Down
2 changes: 1 addition & 1 deletion R/fit_many.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @description
#' `r lifecycle::badge("deprecated")`
#'
#' We are no longer updating this function. Please use generic methods like \code{\link[purrr]{map()}} instead. See `vignette("light-response")` for an example.
#' We are no longer updating this function. Please use generic methods like \code{\link[purrr]{map}} instead. See `vignette("light-response")` for an example.
#'
#' @param data Dataframe
#' @param funct Function to fit
Expand Down
40 changes: 11 additions & 29 deletions R/read_licor.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ read_li6800 = function(x) {
#'
#' @param file Path to a raw LI6800 file
#' @param bluestem_version Character string of Bluestem software version number. By default, the function will try to pull the version number from file.
#' @params ... Argument passed to \code{\link[readr]{read_lines}}
#' @param ... Argument passed to \code{\link[readr]{read_lines}}
#'
#' @return Returns a \code{\link[tibble]{tibble}} from raw LI-COR LI6800 files.
#'
Expand Down Expand Up @@ -97,40 +97,22 @@ read_licor = function(
# Extract data and convert to a tibble
data_block = setdiff(all_lines, extract_licor_remarks(all_lines))
data_start_line = stringr::str_detect(data_block, "\\[Data\\]")
var_names = readr::read_delim(
file,
col_names = TRUE,
skip = which(data_start_line) + 1L,
n_max = 0,
delim = "\t",
show_col_types = FALSE,
name_repair = "minimal"
) |>
colnames()

data_block[(which(data_start_line) + 4L):length(data_block)] |>
tibble::as_tibble() |>
tidyr::separate(col = "value", into = var_names, sep = "\t")

# read.table(data_block, sep = "\t")
# readr::read_lines(data_block)
data_block = readr::read_delim(
file,
col_names = FALSE,
skip = which(data_start_line) + 3L,
delim = "\t",
show_col_types = FALSE,
name_repair = "minimal"
)

NA
var_names = stringr::str_split_1(data_block[which(data_start_line) + 2L],
pattern = "\t")

utils::read.table(
text = data_block[(which(data_start_line) + 4L):length(data_block)]
) |>
magrittr::set_colnames(var_names) |>
magrittr::set_attr("remarks", remarks) |>
magrittr::set_attr("header", header)

}

#' Get Bluestem version from LI6800 file
#'
#' @inheritParams read_licor
#' @params ... Argument passed to \code{\link[readr]{read_lines}}
#' @param ... Argument passed to \code{\link[readr]{read_lines}}
#' @noRd
get_bluestem_version = function(file, ...) {
x1 = readr::read_lines(file, ...)
Expand Down
4 changes: 3 additions & 1 deletion man/fit_many.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions man/read_li6800.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions man/read_licor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions man/read_licors.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/simulate_error.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit af6a406

Please sign in to comment.