R/pre_processor_flowcam.R

Defines functions pre_processor_flowcam

Documented in pre_processor_flowcam

#' Preprocessor flowcam data
#'
#' Convert all \code{.tif} files in \code{flowcam} folder to zip compressed TIFF.
#'
#' @param input directory from which to read the data
#' @param output directory to which to write the data
#'
#' @return invisibly \code{TRUE} when completed successful
#'
#' @export

pre_processor_flowcam <- function(
  input,
  output
) {

  if ( length( list.files( file.path(input, "flowcam") ) ) == 0 ) {
    message("Empty or missing flowcam directory - nothing to do.")
    message("done")
    message("########################################################")
    return(invisible(TRUE))
  }

  dir.create(
    file.path(output, "flowcam"),
    recursive = TRUE,
    showWarnings = FALSE
  )
  loggit::set_logfile(file.path(output, "flowcam", "flowcam.log"))

  message("########################################################")
  message("Processing flowcam...")
  ##

  file.copy(
    file.path( input, "..", "00.general.parameter", "." ),
    file.path( output, "flowcam" ),
    recursive = TRUE,
    overwrite = TRUE
  )
  file.copy(
    from = file.path(input, "flowcam", "."),
    to = file.path(output, "flowcam"),
    recursive = TRUE
  )

  message("done")
  message("########################################################")

  invisible(TRUE)
}
LEEF-UZH/LEEF.measurement.flowcam documentation built on Feb. 11, 2025, 3:21 a.m.