Title: | Imports data from sunscan device |
---|---|
Description: | Provides functions to import, convert and visualize LAI measurements from Sunscan device. An interactive shiny app is included. |
Authors: | Gunther Krauss <[email protected]> |
Maintainer: | Gunther Krauss <[email protected]> |
License: | GPL-3 |
Version: | 0.3.4 |
Built: | 2024-12-30 07:23:22 UTC |
Source: | https://github.com/gk-crop/sunscanimport |
Information about PlotID is given via additional tab delimited files.
addPlotID(data, path)
addPlotID(data, path)
data |
data.frame with LAI data |
path |
of the original data |
data.frame with PlotID column
Information about PlotID is given via additional tab delimited files.
addPlotIDFromData(data, ids, mids)
addPlotIDFromData(data, ids, mids)
data |
data.frame with LAI data |
ids |
dataframe with plotids |
mids |
dataframe with measurementids |
data.frame with PlotID column
Converts all SunScan data files in a directory (and it's subdirectories)
convertSunScanDirectory( directory, prefix = "", extension = ".txt", reportscript = "" )
convertSunScanDirectory( directory, prefix = "", extension = ".txt", reportscript = "" )
directory |
to search for data files |
prefix |
of files to take into accoung |
extension |
of files to take into account |
reportscript |
R script that is used to generate a report for each converted file |
Converts a SunScan data file
convertSunscanFile(file, inputfolder, outputfolder)
convertSunscanFile(file, inputfolder, outputfolder)
file |
name of file |
inputfolder |
input folder |
outputfolder |
output folder |
vector with filenames of converted data
Counts measurements
countMeasurements(data)
countMeasurements(data)
data |
imported sunscan data |
dataframe with number of measurements
Creates a boxplot for LAI data
createBoxplot(data, deleted = FALSE)
createBoxplot(data, deleted = FALSE)
data |
data.frame with LAI data |
deleted |
include measurements marked as deleted |
ggplot graph with boxplot
Creates (sub)folders for converted data and reports
createFolders(file, inputfolder, outputfolder)
createFolders(file, inputfolder, outputfolder)
file |
filename |
inputfolder |
input folder |
outputfolder |
output folder |
Plots the PlotNr arranged in a grid
createGridPlot(griddata)
createGridPlot(griddata)
griddata |
grid data |
Plots LAI on a grid
createGridPlotLAI(data, griddata, deleted = FALSE)
createGridPlotLAI(data, griddata, deleted = FALSE)
data |
imported sunscan data |
griddata |
grid data |
deleted |
include measurements marked as deleted |
Summarise information about measurement series
createSeriesInfo(data)
createSeriesInfo(data)
data |
imported sunscan data |
dataframe
Summarises data for each PlotID
createSummary(data, deleted = FALSE)
createSummary(data, deleted = FALSE)
data |
data.frame with LAI data |
deleted |
include measurements marked as deleted |
data.frame with summary information
Plots measurements over time
createTimePlot(data, stripes = 11)
createTimePlot(data, stripes = 11)
data |
imported sunscan data |
stripes |
number of color stripes |
Plots measurements over time
createTimePlotLAI(data, stripes = 11)
createTimePlotLAI(data, stripes = 11)
data |
imported sunscan data |
stripes |
number of color stripes |
Creates initial grid data
generateInitialGridData(data, rows = 1, rowwise = FALSE)
generateInitialGridData(data, rows = 1, rowwise = FALSE)
data |
converted sunscan data |
rows |
number of rows of the field |
rowwise |
TRUE if the numbering is rowwise |
data frame with grids (col/row)
If one does not provide a report script, then the default report script is used.
generateReport( file, inputfolder, outputfolder, reportscript = system.file("reports", "default_report.R", package = "sunscanimport") )
generateReport( file, inputfolder, outputfolder, reportscript = system.file("reports", "default_report.R", package = "sunscanimport") )
file |
filename |
inputfolder |
input folder |
outputfolder |
output folder |
reportscript |
script to generate the report |
A report script is an R script that may contain RMarkdown. Inside the script
one can use the variable param
with its elements param$file
, param$inputfolder
and param$outputfolder
.
The report will be placed in the outputfolder in the subdirectory report
.
Notice that the package rmarkdown
and knitr
have to be installed to generate a report.
Creates Sample MeasurementID data
generateSampleMeasurementIdData(data, interval = 0)
generateSampleMeasurementIdData(data, interval = 0)
data |
converted sunscan data |
interval |
time interval after which a new PlotNR is assumed |
data frame with ids
Generates sample data to relate PlotNr to grids, PlotIDs or MeasurementIDs
generateSamplePlotIdData(data) generateInitialPlotIdData(data) generateInitialMeasurementIdData(data)
generateSamplePlotIdData(data) generateInitialPlotIdData(data) generateInitialMeasurementIdData(data)
data |
LAI-Data from SunscanFile |
dataframe with IDs
Extracts LAI data from the file lines
getData(lines, date)
getData(lines, date)
lines |
vector of lines read from the data file |
date |
start date of measurements from meta data |
data.frame with LAI measurements
Fetches recursively all possible data files from a directory
getFileList( directory, prefix = "", extension = ".TXT", excludedir = "converted" )
getFileList( directory, prefix = "", extension = ".TXT", excludedir = "converted" )
directory |
to search for data files |
prefix |
of files to take into account |
extension |
of files to take into account |
excludedir |
subdirectory name to exclude |
vector of potential data files
Gets meta data from the file header
getHeader(lines, path)
getHeader(lines, path)
lines |
vector of lines read from the data file |
path |
path of the file |
named vector with meta data
Extracts PAR data from the file lines
getParData(lines, date)
getParData(lines, date)
lines |
vector of lines read from the data file |
date |
start date of measurements from meta data |
data.frame with PAR measurements
Gets meta data from the file header
getSmallHeader(lines)
getSmallHeader(lines)
lines |
vector of lines read from the data file |
named vector with meta data
File name for the metadata file
File name for the LAI data file
File name for the PAR data file
File name for the summary file
File name for the boxplot image
File name for the report
headerFileName(file, outputfolder) dataFileName(file, outputfolder) pardataFileName(file, outputfolder) summaryFileName(file, outputfolder) boxplotFileName(file, outputfolder) reportFileName(file, outputfolder)
headerFileName(file, outputfolder) dataFileName(file, outputfolder) pardataFileName(file, outputfolder) summaryFileName(file, outputfolder) boxplotFileName(file, outputfolder) reportFileName(file, outputfolder)
file |
filename of data file |
outputfolder |
output folder |
filename
Data lines begin with a date
isDataLine(line)
isDataLine(line)
line |
a line of text |
TRUE if data line
Checks if the data file has been moved to subfolder 'original'
isMovedFile(file, inputfolder, target = "original")
isMovedFile(file, inputfolder, target = "original")
file |
filename |
inputfolder |
input folder |
target |
target folder |
TRUE if file has been moved to original folder
Checks if file starts with 'Created by SunData' and if the files has at least 14 lines
isSunscanFile(path)
isSunscanFile(path)
path |
path to the file |
TRUE if valid SunScan file
A title line starts a new metatdata section in the sunscan data file.
isTitleLine(line)
isTitleLine(line)
line |
a line of text |
TRUE if title line
Returns path for the data file moved to 'original' subfolder
movedFileName(file, inputfolder, target = "original")
movedFileName(file, inputfolder, target = "original")
file |
filename |
inputfolder |
input folder |
target |
target folder |
path to data file
Moves data file to subfolder 'original'
moveFilesToSubfolders(file, inputfolder, target = "original")
moveFilesToSubfolders(file, inputfolder, target = "original")
file |
filename |
inputfolder |
input folder |
target |
target folder |
Moves data file to subfolder 'original'
moveOriginalFile(file, inputfolder, target = "original")
moveOriginalFile(file, inputfolder, target = "original")
file |
filename |
inputfolder |
input folder |
target |
target folder |
Reads converted data
readConvertedHeader(file, outputfolder) readConvertedData(file, outputfolder) readConvertedParData(file, outputfolder) readConvertedSummary(file, outputfolder) readConvertedFiles(file, outputfolder)
readConvertedHeader(file, outputfolder) readConvertedData(file, outputfolder) readConvertedParData(file, outputfolder) readConvertedSummary(file, outputfolder) readConvertedFiles(file, outputfolder)
file |
filename |
outputfolder |
output folder |
dataframe with converted data
Read dataframe with PlotID column
readIdData(file)
readIdData(file)
file |
filename |
data frame with the ids
Reorders columns in converted data
reorderDataColumns(data)
reorderDataColumns(data)
data |
imported sunscan data |
dataframe with reordered columns
Runs Shiny app
runSunscanApp(...)
runSunscanApp(...)
... |
parameters passed to shiny::runApp |
Saves metadata to file
Saves LAI data
Saves PAR data
Saves summary
Saves boxplot
saveHeader(data, file, outputfolder) saveData(data, file, outputfolder) saveParData(data, file, outputfolder) saveSummary(data, file, outputfolder) saveBoxplot(data, file, outputfolder)
saveHeader(data, file, outputfolder) saveData(data, file, outputfolder) saveParData(data, file, outputfolder) saveSummary(data, file, outputfolder) saveBoxplot(data, file, outputfolder)
data |
data frame |
file |
filename of original file |
outputfolder |
output folder |
Splits the data when file contains multiple headers
splitLines(lines)
splitLines(lines)
lines |
vector of lines from the data file |
list of line vectors
Strips the file extension
stripFileExtension(file)
stripFileExtension(file)
file |
filename |
file name without path and extension
The package provides functions to:
convert a file or a directory
summarize or transform converted data
create reports for converted data
run a shiny app for interactive conversion
Gunther Krauss
## Not run: runSunscanApp() ## End(Not run) ## Not run: file <- "paulinenaue.TXT" inputfolder <- "data/210908/original/" outputfolder <- "data/210908/" convfile <- convertSunscanFile(file,inputfolder, outputfolder) generateReport(convfile, inputfolder, outputfolder) ## End(Not run) ## Not run: convertSunScanDirectory("data/") ## End(Not run) ## Not run: data <- readr::read_delim("data/210908/converted/data_paulinenaue.txt", delim="\t") data_summary <- createSummary(data) data_wide <- transformToWideFormat(data) ## End(Not run)
## Not run: runSunscanApp() ## End(Not run) ## Not run: file <- "paulinenaue.TXT" inputfolder <- "data/210908/original/" outputfolder <- "data/210908/" convfile <- convertSunscanFile(file,inputfolder, outputfolder) generateReport(convfile, inputfolder, outputfolder) ## End(Not run) ## Not run: convertSunScanDirectory("data/") ## End(Not run) ## Not run: data <- readr::read_delim("data/210908/converted/data_paulinenaue.txt", delim="\t") data_summary <- createSummary(data) data_wide <- transformToWideFormat(data) ## End(Not run)
Each PlotID has only one row where each individual LAI measurements is in an own column. Number of columns is determined by the maxiumum number of measurements per PlotID. Measurements are populated from left to right and filled up by NAs.
transformToWideFormat(data, deleted = FALSE)
transformToWideFormat(data, deleted = FALSE)
data |
data.frame with LAI data |
deleted |
include measurements marked as deleted |
data.frame in wide format