plot_eddy: Plot Time Series of Eddy Covariance Data

View source: R/Plot_eddy.R

plot_eddyR Documentation

Plot Time Series of Eddy Covariance Data

Description

Visualize flux measurements together with micrometeorological or other related variables in monthly and weekly intervals. Missing values, scales of axes and plotting regions are treated in an automated way.

Usage

plot_eddy(
  x,
  flux,
  qc_flag = "none",
  test = "none",
  flux_gf = "none",
  NEE_sep = FALSE,
  skip = c("none", "monthly", "weekly"),
  ylim = NULL,
  panel_top = c("T_light", "VPD_Rn", "H_err_var", "blue_red", "violet_orange"),
  panel_top_vars = NULL,
  panel_bottom = c("VPD_Rn", "T_light", "H_err_var", "blue_red", "violet_orange"),
  panel_bottom_vars = NULL,
  light = c("PAR", "GR"),
  GPP_scor = TRUE,
  document = TRUE
)

Arguments

x

A data frame with column names representing required variables. See 'Details' below.

flux

A character string. Specifies the column name in x with flux values.

qc_flag

A character string. Specifies the column name in x with flux related quality control flag used for visualisation of data quality and setting of y-axis range. If "none" is provided, all data will be used. See 'Quality Control'.

test

A character string. Specifies the column name in x with quality control flag for visualisation of its effect on the data. If "none" is provided, no visualisation will be done. See 'Quality Control'.

flux_gf

A character string. Specifies the column name in x with gap-filled flux values.

NEE_sep

A logical value. Determines whether NEE separation should be visualized. If TRUE, columns "Reco" and "GPP" are expected in x.

skip

A character string. Determines whether plotting should be done in monthly (skip = "weekly"), weekly intervals (skip = "monthly") or both (skip = "none").

ylim

A numeric vector of length two or NULL. If NULL (default), the treatment of y-axis limits in the figures with flux values is fully automated. Otherwise, ylim sets the maximum range of automatically computed y-axis limits. See 'Quality Control'.

panel_top

A character string. Selects one of the available modules for plotting additional variables. This module is displayed above the panel with fluxes in weekly plots. Can be abbreviated. See 'Modules'.

panel_top_vars

A character vector of length two or NULL. Specifies two variables expected in x if panel_top = "blue_red" or "violet_orange", otherwise NULL.

panel_bottom

A character string. Selects one of the available modules for plotting additional variables. This module is displayed below the panel with fluxes in weekly plots. Can be abbreviated. See 'Modules'.

panel_bottom_vars

A character vector of length two or NULL. Specifies two variables expected in x if panel_bottom = "blue_red" or "violet_orange", otherwise NULL.

light

A character string. Required only for the "T_light" module. Selects preferred variable for incoming light intensity. "PAR" or "GR" is allowed. Can be abbreviated.

GPP_scor

A logical value. Should sign correction of GPP be performed? See Gap-filling and NEE separation section in Details. Ignored if NEE_sep = FALSE.

document

A logical value. If TRUE, values of qc_flag and test arguments are documented in both monthly and weekly plots.

Details

The data frame x is expected to have certain properties. It is required that it contains column named "timestamp" of class "POSIXt" with regular sequence of date-time values, typically with (half-)hourly time interval. Any missing values in "timestamp" are not allowed. Thus, if no records exist for given date-time value, it still has to be included. It also has to contain required (depends on the argument values and applied modules) column names. If required auxiliary variable is not available (e.g. "Tair", "PAR"), it still has to be included in x as a named column with NA values. The x column defined by argument flux is the only one that has to contain at least one non-missing value. If present, column "P" is expected to contain precipitation.

If skip = "weekly", minimum requirements for x column names are "timestamp" and flux. If skip = "none" or "monthly", respective names specified in 'Modules' (see below) are also required.

Variable names for plot labels are extracted from required column names of x. Units are extracted from x if they are present as units attributes of required columns. If missing, "-" string is used instead.

Plotting is separated into two stages. Firstly, flux time-series data are drawn in monthly intervals. Monthly plotting regions consist of four figures on top of each other representing separately four consecutive months. Secondly, if skip = "none" or "monthly", flux time-series data are drawn together with auxiliary data in weekly intervals. Weekly plotting regions are described in 'Modules' section (see below).

Modules

Applies only if skip = "none" or "monthly". Plotting of auxiliary variables in weekly intervals is simplified by using predefined modules. Their main purpose is to achieve well-arranged display of auxiliary variables. Weekly plotting regions consist of two figures representing separately two consecutive weeks. Each figure contains three panels on top of each other. The middle panel always contains the values from flux and, if present, "P" columns of x. Variables used in the upper and lower panel can be changed by panel_top and panel_bottom. These arguments specify the respective modules that will be loaded (can be the same) and thus also a certain set of required column names of x (variables).

Available modules are:

  • T_light: requires "Tair", "Tsoil" and selected light columns.

  • VPD_Rn: requires "VPD" and "Rn" columns.

  • H_err_var: requires "rand_err_H" and "ts_var" columns.

  • blue_red: requires columns specified by panel_top/bottom_vars.

  • violet_orange: requires columns specified by panel_top/bottom_vars.

Modules T_light, VPD_Rn and H_err_var have predefined color combinations and variables. Modules blue_red and violet_orange provide more flexibility as they only have predefined color combinations. Actual plotted variables are selected by additional argument (see above).

Quality Control

qc_flag and test relate to QC flags available for the specified flux. Only QC scheme using QC flag range 0 - 2 is supported.

Flags specified by qc_flag separate corresponding flux values to two groups. Used data for flags 0 and 1 (black points) and Excluded data for flags 2 and NA (grey points). The y-axis limits in the figures with flux values are based on Used data only. If qc_flag = "none", all data are Used data. The time interval used for setting the range is one month both for monthly (respective month) and weekly (month centered on the respective week) plots. Additionally, maximum ylim range can be set for the figures with flux values (e.g. in case of large outliers).

In order to emphasize flux values with lower quality, test can be specified. Values with QC flag = 1 have green center of the point. Values with QC flag = 2 or NA have red center of the point.

NB: flux data with NA values are always Excluded data and cannot be emphasized (NA values are not drawn).

Gap-filling and NEE separation

Gap-filled flux values can be displayed using flux_gf as a line overlaying the flux values. If NEE_sep = TRUE, columns "Reco" and "GPP" are expected in x. GPP_scor allows to change the sign convention of GPP to minimize lines overlay during plotting. CO2 uptake in REddyProc package is represented by positive GPP, thus, to optimize plotting, GPP_scor = TRUE is taken as default.

Abbreviations

  • H: Sensible heat flux [W m-2]

  • NEE: Net Ecosystem Exchange [umol m-2 s-1]

  • GPP: Gross Primary Production [umol m-2 s-1]

  • Reco: Ecosystem Respiration [umol m-2 s-1]

  • QC: Quality Control

  • P: Precipitation [mm]

  • PAR: Photosynthetic Active Radiation [umol m-2 s-1]

  • GR: Global Radiation [W m-2]

  • T: Temperature [degC]

  • Tair: Air Temperature [degC]

  • Tsoil: Soil Temperature [degC]

  • VPD: Vapor Pressure Deficit [hPa]

  • Rn: Net Radiation [W m-2]

  • rand_err_H: random error of H [W m-2]; in plots abbreviated as H_re

  • ts_var: sonic temperature variance [K2]

See Also

read_eddy and strptime_eddy.

Examples

# prepare mock data
set.seed(87)
my_var <- sin(seq(pi / 2, 2.5 * pi, length = 48)) * 10
my_var[my_var > 5] <- 5
t <- seq(ISOdate(2020, 7, 1, 0, 15), ISOdate(2020, 7, 14, 23, 45), "30 mins")
P <- vector("numeric", 48 * 14)
P[c(180:188, 250:253, 360:366, 500:505)] <- sample(1:15, 26, replace = TRUE)
PAR <- (-my_var + 5) * 100
Tair <- Tsoil <- rep(-cos(seq(0, 2 * pi, length = 48)), 14)
Tair <- Tair * 2 + 15 + seq(0, 5, length = 48 * 14)
Tsoil <- Tsoil * 1.2 + 10 + seq(0, 3, length = 48 * 14)
VPD <- -my_var + 10
VPD <- VPD[c(43:48, 0:42)]
Rn <- PAR / 2 - 50

# combine into data frame
a <- data.frame(
  timestamp = t,
  my_var = my_var + rnorm(48 * 14),
  my_qc = sample(c(0:2, NA), 672, replace = TRUE, prob = c(5, 3, 2, 1)),
  P = P,
  PAR = PAR,
  Tair = Tair,
  Tsoil = Tsoil,
  VPD = VPD,
  Rn = Rn
)

# specify units
openeddy::units(a) <- c("-", "units", "-", "mm", "umol m-2 s-1", "degC",
                        "degC", "hPa", "W m-2")

# plot in weekly resolution (flux can be any variable)
plot_eddy(x = a, flux = "my_var", qc_flag = "my_qc", test = "my_qc",
skip = "monthly")

# test can be used to distinguish up to 3 groups (0-2 flagging scheme)
# - example with 2 groups:
a$day <- a$PAR > 0 # 2 groups (TRUE / FALSE; i.e. 1 / 0)
plot_eddy(a, "my_var", "my_qc", "day", skip = "monthly") # daytime is green
# - example with 3 groups:
a$Tair_levels <- cut(a$Tair, c(13, 16, 19, 22))
a$Tair_levels <- as.numeric(a$Tair_levels) - 1 # only flags 0-2 supported
plot_eddy(a, "my_var", "my_qc", "Tair_levels", skip = "monthly")

# make a custom setup of top and bottom panels
plot_eddy(x = a, flux = "my_var", qc_flag = "my_qc", test = "my_qc",
          skip = "monthly",
          panel_top = "blue_red", panel_top_vars = c("Tair", "Rn"),
          panel_bottom = "violet_orange", panel_bottom_vars = c("PAR", "VPD"))

# any time resolution is supported
b <- ex(a, c(TRUE, FALSE, FALSE, FALSE)) # two-hourly time resolution
plot_eddy(b, "my_var", "my_qc", "my_qc", skip = "monthly")

# Precipitation is treated specifically and can be missing
d <- a
d["P"] <- NULL
plot_eddy(d, "my_var", "my_qc", "my_qc", skip = "monthly")


lsigut/openeddy documentation built on Aug. 5, 2023, 12:25 a.m.