mc_read_files {myClim}R Documentation

Reading files or directories

Description

This function read one or more CSV/TXT files or directories of identical, pre-defined logger type (format) see mc_DataFormat and mc_data_formats. This function does not support loading locality or sensor metadata while reading. Metadata can be loaded through mc_read_data() or can be provided later with function mc_prep_meta_locality()

Usage

mc_read_files(
  paths,
  dataformat_name,
  logger_type = NA_character_,
  recursive = TRUE,
  date_format = NA_character_,
  tz_offset = NA_integer_,
  step = NA_integer_,
  clean = TRUE,
  silent = FALSE,
  user_data_formats = NULL
)

Arguments

paths

vector of paths to files or directories

dataformat_name

data format of logger; one of names(mc_data_formats)

logger_type

type of logger (default NA), can be one of pre-defined see mc_read_data() or any custom string

recursive

recursive search in sub-directories (default TRUE)

date_format

format of date in your hobo files e.g. "%d.%m.%y %H:%M:%S" (default NA). Required for HOBO files. For TMS files ignored, there is known, stable date format. see mc_data_formats

tz_offset

timezone offset in minutes; It is required only for non-UTC data (custom settings in HOBO). Not used in TMS (default NA)

step

time step of microclimatic time-series in seconds. When provided, then is used in mc_prep_clean instead of automatic step detection. If not provided (NA), is automatically detected in mc_prep_clean. (default NA)

clean

if TRUE, then mc_prep_clean is called automatically while reading (default TRUE)

silent

if TRUE, then any information is not printed in console (default FALSE)

user_data_formats

custom data formats; use in case you have your own logger files not pre-defined in myClim - list(key=mc_DataFormat) mc_DataFormat (default NULL)

If custom data format is defined the key can be used in data_format parameter in mc_read_files() and mc_read_data(). Custom data format must be defined first, and then an be used for reading.

Details

If file is not in expected format, then file is skipped and warning printed in console. CSV/TXT files (loggers raw data) are in resulting myClim object placed to separate localities with empty metadata. Localities are named after serial_number of logger. Pre-defined logger types are ("Dendro","HOBO","Thermo","TMS","TMS_L45") By default data are cleaned with function mc_prep_clean(). See function description. It detects holes in time-series, duplicated records or records in wrong order.

Value

myClim object in Raw-format see myClim-package

See Also

mc_DataFormat, mc_prep_clean()

Examples

files <- c(system.file("extdata", "data_91184101_0.csv", package = "myClim"),
           system.file("extdata", "data_94184102_0.csv", package = "myClim"))
tomst_data <- mc_read_files(files, "TOMST")
# user_data_formats
files <- system.file("extdata", "TMS94184102.csv", package = "myClim")
user_data_formats <- list(my_logger=new("mc_DataFormat"))
user_data_formats$my_logger@date_column <- 2
user_data_formats$my_logger@date_format <- "%Y-%m-%d %H:%M:%S"
user_data_formats$my_logger@tz_offset <- 0
user_data_formats$my_logger@columns[[mc_const_SENSOR_T_C]] <- c(3, 4, 5)
user_data_formats$my_logger@columns[[mc_const_SENSOR_real]] <- 6
my_data <- mc_read_files(files, "my_logger", silent=TRUE, user_data_formats=user_data_formats)

[Package myClim version 1.1.0 Index]