-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextract_coded.Rd
97 lines (89 loc) · 4.01 KB
/
extract_coded.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Quality_checking.R
\name{extract_coded}
\alias{extract_coded}
\title{Extract Quality Control Information from Coded Values}
\usage{
extract_coded(
x,
name_out_SA = "SA",
name_out_GA = "GA",
name_out_SAGA = "SAGA",
name_out_ALL = "ALL",
prefix = "[8]",
split = "[/]",
sf = FALSE
)
}
\arguments{
\item{x}{An atomic type.}
\item{name_out_SA, name_out_GA, name_out_SAGA, name_out_ALL}{A character string.
Name of the output column with QC related to SA, GA, SAGA or ALL.}
\item{prefix}{Character string containing a \code{\link{regular expression}}
identifying the prefix of coded values.}
\item{split}{Character string containing a \code{\link{regular expression}}
identifying the separator of variable names in \code{units} attribute.}
\item{sf}{A logical value. Coded variable represents hard flag (\code{sf =
FALSE}; default) or soft flag (\code{sf = TRUE}). See Details.}
}
\value{
A data frame with relevant column names defined by
\code{name_out_SA}, \code{name_out_GA}, \code{name_out_SAGA} and
\code{name_out_ALL}. Each column has attributes \code{"varnames"} and
\code{"units"} and length equal to that of \code{x}.
}
\description{
This function is called by \code{\link{extract_QC}} and is not intended to be
used directly. Coded QC information for one or multiple variables stored in a
character vector of certain properties is extracted and interpreted.
}
\details{
Each element of \code{x} is expected to have the same structure according to
the format specified by \code{units} attribute of \code{x}. \code{units}
format string (e.g. \code{"8u/v/w/ts/h2o/co2"}) starts with a prefix
(\code{"8"}) that is followed by variable names (\code{"u", "v", "w", "ts",
"h2o", "co2"}) that are distinguished by a separator (\code{"/"}). Elements
of \code{x} thus consist of either seven components (prefix and six flags for
each variable) or one \code{NA} value. Flags of coded variables can have
three values: \itemize{ \item flag 0: measured variable passed the test.
\item flag 1: measured variable failed the test. \item flag 9: flag could not
be obtained for the given variable (\code{NA}).}
The original flags are then interpreted within the QC scheme using QC flag
range 0 - 2. Coded variable can represent either \itemize{\item hard flag
(suffix \code{"_hf"} in EddyPro column name): flag 1 interpreted as flag 2.
\item soft flag (suffix \code{"_sf"} in EddyPro column name): flag 1
interpreted as flag 1.}
\code{x} is interpreted in respect to instruments required to measure given
fluxes. SA is required for measurements of all fluxes and solely provides
data for computation of Tau and H fluxes. GA is used only for measurements of
LE and NEE. A combination of SA and GA (SAGA) is used for measurements of LE
and NEE. Filters where flags would be identical for both SA and GA have
prefix ALL (QC flags in a single column applicable to all fluxes). To confirm
the correct performance of SA, all variables \code{"u", "v", "w", "ts"} must
have flag 0. In case of GA, all variables \code{"co2", "h2o"} must have flag
0. In case of SAGA, all variables \code{"u", "v", "w", "ts", "h2o", "co2"}
must have flag 0.
}
\section{Abbreviations}{
\itemize{ \item QC: Quality Control \item SA: Sonic
Anemometer \item GA: Gas Analyzer \item Tau: Momentum flux [kg m-1 s-2]
\item H: Sensible heat flux [W m-2] \item LE: Latent heat flux [W m-2]
\item NEE: Net ecosystem exchange [umol m-2 s-1] \item u: Longitudinal wind
speed component [m s-1] \item v: Cross-wind wind speed component [m s-1]
\item w: Vertical wind speed component [m s-1] \item ts: Sonic temperature
[degC] \item h2o: H2O concentration [mmol mol-1] \item co2: CO2
concentration [umol mol-1]}.
}
\examples{
set.seed(5)
xx <- replicate(10,
paste0(c("8", sample(c(0:1, 9), 6, c(0.7, 0.2, 0.1),
replace = TRUE)),
collapse = ""))
is.na(xx) <- c(2, 5)
units(xx) <- "8u/v/w/ts/h2o/co2"
cbind(xx, extract_coded(xx))
}
\seealso{
\code{\link{extract_QC}}.
}