Package {DendroFlux}


Type: Package
Date: 2026-07-26
Title: Processing and Analyzing Dendrometer and Sap Flux Data
Version: 1.0.3
Author: Shuo Wen [aut, cre], Xiaoyan Shang [ctb], Wenjian Zhou [ctb], Zhongjie Shi [ths], Xiao Zhang [ths]
Maintainer: Shuo Wen <shuowen@caf.ac.cn>
Description: Data management and cleaning for dendrometer and sap flux data, including gap detection, NA identification, missing value interpolation, and date conversion. The package also calculates multiple growth metrics of tree radial change data, including the cumulative growth over the entire observation period, daily cumulative growth, and growth changes between adjacent time intervals. Various approaches can be applied to calculate the night delta-Tmax required for sap flow (Peters et al., 2018, <doi:10.1111/nph.15241>) and subsequently estimate sap flow density (Granier, 1987, <doi:10.1093/treephys/3.4.309>). In addition, it supports the creation of simple time‑series point plots to visually display the dynamic changes in tree growth status or sap flow density during that period.
License: GPL-3
Language: en-US
Encoding: UTF-8
LazyData: true
Depends: R (≥ 3.5.0)
Imports: readxl, ggplot2, zoo, forecast, rlang
NeedsCompilation: no
Config/roxygen2/version: 8.0.0
Packaged: 2026-07-26 03:38:11 UTC; shuow
Repository: CRAN
Date/Publication: 2026-08-05 06:50:02 UTC

Detection of missing values in dendrometer/sap flux data.

Description

This function detects gap(s) in a time series, inserts missing rows at the given temporal resolution corresponding to the data, assigns NA values to the missing values, and compiles the gap and NA information from multiple series into a single data frame.

Usage

check.na(df, resolution)

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with data for the same temporal resolution and time period.

resolution

integer, indicating the resolution of data in minutes.

Value

A dataframe containing time series gap(s) and NA values from other series.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(dendro_na)
dendro_na_if <- check.na(df=dendro_na, resolution=10)
head(dendro_na_if)


climate data

Description

Climate dataset from Wushen Banner, Inner Mongolia Autonomous Region, China.

Usage

climate

Format

A data frame with 2160 rows and 2 variables. The variables are respectively

Time

Containing date and time in the format yyyy-mm-dd HH:MM:SS

vpd

Vapor pressure deficit

Source

data vpd from the China Meteorological Data Network http://data.cma.cn/ variable Time is the corresponding time of vpd


Calculate the cumulative growth or growth variation of dendrometer data.

Description

This function calculates the cumulative growth increment of all period(i.e., method = "cumul_p"), daily cumulative growth increment(i.e., method = "cumul_d") or growth variation between adjacent time periods(i.e., method = "increase").

Usage

dendcalcu(df, method = "cumul_p")

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with dendrometer data for the same temporal resolution and time period.

method

string, "cumul_p" for annual cumulative growth increment, "cumul_d" for daily cumulative growth increment or 'increase' for growth changes between adjacent time periods. Default is "cumul_p".

Value

A dataframe containing time series and cumulative growth (or growth variation).

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(dendro)

#The default method is annual cumulative growth increment
dendro_cp <- dendcalcu(df=dendro)
head(dendro_cp)

#Daily cumulative growth increment
dendro_cd <- dendcalcu(df=dendro, method = "cumul_d")
head(dendro_cd)

#Growth variation between adjacent time periods
dendro_gv <- dendcalcu(df=dendro, method = "increase")
head(dendro_gv)


dendrometer data

Description

Dendrometer dataset from Wushen Banner, Inner Mongolia Autonomous Region, China.

Usage

dendro

Format

A data frame with 2160 rows and 9 variables. The variables are respectively

Time

Containing date and time in the format yyyy-mm-dd HH:MM:SS

tri1

Dendrometer data of tree 1

tri2

Dendrometer data of tree 2

tri3

Dendrometer data of tree 3

tri4

Dendrometer data of tree 4

tri5

Dendrometer data of tree 5

tri6

Dendrometer data of tree 6

tri7

Dendrometer data of tree 7

tri8

Dendrometer data of tree 8

Source

The data was collected by dendrometer instrument (TR80, Beijing Sinton Technology Company, Beijing, China).


dendrometer data with missing values

Description

Dendrometer dataset with missing values from Wushen Banner, Inner Mongolia Autonomous Region, China.

Usage

dendro_na

Format

A data frame with 2157 rows and 9 variables. The variables are respectively

Time

Containing date and time in the format yyyy-mm-dd HH:MM:SS with gaps in time series

tri1

Dendrometer data of tree 1 with NA

tri2

Dendrometer data of tree 2 with NA

tri3

Dendrometer data of tree 3 with NA

tri4

Dendrometer data of tree 4 with NA

tri5

Dendrometer data of tree 5 with NA

tri6

Dendrometer data of tree 6 with NA

tri7

Dendrometer data of tree 7 with NA

tri8

Dendrometer data of tree 8 with NA

Source

The data, after manual deletion of some entries, was collected by dendrometer instrument (TR80, Beijing Sinton Technology Company, Beijing, China).


Determine the zero-flow conditions

Description

This function determines zero-flow by environmental conditions. method = "MN" means the dT of the zero-flow condition is the dT of midnight. method = "SP" means the dT of the zero-flow condition is the maximum dT within a 24-hour period that begins at daybreak. method = "PD" means the dT of the zero-flow condition is the maximum dT between midnight and morning.

Usage

dtmaxcalcu(df, method = "MN", predawn = "06:00:00")

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with sap flux data for the same temporal resolution and time period.

method

string, "MN" for the dTmax is the dT of midnight. "SP" for dTmax as the maximum dT of the day that starts at predawn within a 24-hour period. "PD" for dTmax as the maximum dT between midnight and the morning. Default is "MN".

predawn

filter the time boundary for the dTmax.

Details

The midnight method (MN) defines the dTmax is the dT of midnight.

The successive predawn method (SP) defines dTmax as the maximum dT of the day that starts at predawn within a 24-hour period.This method has the advantage of being able to calculate dTmax quickly while minimizing the effect of nocturnal transpiration on dTmax estimation. See more in details in Peters et al.(2018).

The daily predawn method (PD) defines dTmax as the maximum dT between midnight and the morning. See more in details in Peters et al.(2018).

Value

A dataframe containing time series , dT series and corresponding dTmax series.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

References

Peters et al.(2018). Quantification of uncertainties in conifer sap flow measured with the thermal dissipation method. New Phytologist, 219(4),1283-1299.

Examples

##Load data
data(sapflux)

#The midnight method (MN)
sapflux_baseline <- dtmaxcalcu(df=sapflux)
head(sapflux_baseline)

#The successive predawn method (SP)
sapflux_baseline <- dtmaxcalcu(df=sapflux, method = "SP")
head(sapflux_baseline)

#The daily predawn method (PD)
sapflux_baseline <- dtmaxcalcu(df=sapflux, method = "PD")
head(sapflux_baseline)


Determine the zero-flow conditions by environmental conditions

Description

This function determines zero-flow by environmental conditions. method = "CV" means the dT of the zero-flow condition is stable dT, with a low coefficient of variation. method = "S" means the dT 0f the zero-flow condition is stable dT, with nighttime stability.

Usage

dtmaxcalcu.en(
  df,
  dc = NULL,
  method = "CV",
  predawn = "06:00:00",
  hour = 2,
  day = 7,
  threshold_cli = 0.05,
  threshold_sta = 0.005,
  fill = FALSE
)

Arguments

df

dataframe with sap flux data.

dc

dataframe with Climate data.

method

string, "CV" for the stable dT, with a low coefficient of variation (CV), "S" for A stable dT, with a low nighttime stability (S). Default is "CV".

predawn

filter the time boundary for the dTmax.

hour

time range for stable environmental conditions, default is 2h.

day

filter the duration of the sliding time window for nighttime stability (S), default is 7 d.

threshold_cli

the threshold of low environmental variables, default is 0.05.

threshold_sta

the threshold of stable dT, default is 0.005.

fill

logical, if TRUE it fills the NA values using spline interpolation. Default is FALSE.

Details

The environmental dependent method (ED) filter the dTmax by the daily predawn method (PD), using the environmental conditions(T was < 1 celsius degree or D was < 0.1–0.05 kPa for a period, default is 2 h) when plants let their sap flux nearly zero. A stable dT, with a low coefficient of variation (CV)(default CV < 0.005) within the same time range for stable nighttime environmental conditions(Peters et al., 2018) or with a low nighttime stability (S)(default S < 0.005) within the same time range for stable nighttime environmental conditions(Oish et al., 2008,2016).

Nighttime stability is determined using the following function:

S = N / V

where S is stability, N is the standard deviation of nighttime delta-T values within the user-defined time range (this is the same time range for stable nighttime VPD conditions, default is 2-hours), and V is diurnal variability of delta-T for a 7-day moving window centered on a given night where

V = mean (P(i) - L(i))

where P(i) is the peak value of delta-T for day i, defined by the upper quartile of nightime values L(i) is the low value of delta-T for day i, defined by the lower quartile of daytime values.

Value

A dataframe containing time series , dT series and corresponding dTmax series.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

References

Oish et al.(2008). Estimating components of forest evapotranspiration: A footprint approach for scaling sap flux measurements. Agricultural and Forest Meteorology, 148, 1719-1732.

Oish et al.(2016). Baseliner: An open-source, interactive tool for processing sap flux data from thermal dissipation probes. SoftwareX, 2016,5, 139-143.

Peters et al.(2018). Quantification of uncertainties in conifer sap flow measured with the thermal dissipation method. New Phytologist, 219(4),1283-1299.

Examples

##Load data
data(sapflux)
data(climate)
#A stable dT, with a low coefficient of variation (CV)
sapflux_baseline <- dtmaxcalcu.en(df=sapflux,dc =climate)
head(sapflux_baseline)

#A stable dT, with a low nighttime stability (S)
sapflux_baseline <- dtmaxcalcu.en(df=sapflux,dc =climate, method = "S")
head(sapflux_baseline)


Determine the zero-flow conditions by moving window

Description

This function determines zero-flow by environmental conditions. method = "MAX" means the dT of the zero-flow condition is the maximum night dT, with a moving window. method = "MEAN" means the dT of the zero-flow condition is the moving window mean recalculated after omitting values lower than the mean.

Usage

dtmaxcalcu.moving(df, method = "MAX", win.size = 11, fill = FALSE)

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with sap flux data for the same temporal resolution and time period.

method

string, "MAX" for dTmax as the maximum daily dTmax with a moving window (default is an eleven-day length). "MEAN" for dTmax as the moving window (default is an eleven-day length) mean recalculated after omitting values lower than the mean. Default is "MAX".

win.size

Size of moving window, default is 11.

fill

logical, if TRUE it fills the NA values using spline interpolation. Default is FALSE.

Details

The moving window method (MAX) defines dTmax as the maximum daily dTmax with a moving window (default is an eleven-day length). See more in details in Peters et al.(2018).

The double regression method (MEAN) defines dTmax as the moving window (default is an eleven-day length) mean recalculated after omitting values lower than the mean. See more in details in Peters et al.(2018).

Value

A dataframe containing time series , dT series and corresponding dTmax series.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

References

Peters et al.(2018). Quantification of uncertainties in conifer sap flow measured with the thermal dissipation method. New Phytologist, 219(4),1283-1299.

Examples

##Load data
data(sapflux)
sapflux_baseline <- dtmaxcalcu(df=sapflux,method= "PD")

#The moving window method (MAX)
sapflux_bl_moving <- dtmaxcalcu.moving(df=sapflux_baseline, method = "MAX")
head(sapflux_bl_moving)

#The double regression method (MEAN)
sapflux_bl_moving <- dtmaxcalcu.moving(df=sapflux_baseline, method = "MEAN")
head(sapflux_bl_moving)


Daily water consumption from sap flux

Description

This function roughly calculate the daily water consumption per square centimeter of water-conducting sapwood area, in cubic meters.

Usage

dwaterconsu(df, resolution)

Arguments

df

dataframe containing date and sap flux density.

resolution

integer, indicating the resolution of data in minutes.

Details

The daily water consumption of a tree is the product of the area under the daily sap flow curve and the water-conducting sapwood area. The more meticulous the resolution, the higher the accuracy.

Value

A dataframe containing time series and the daily water consumption per square centimeter of water-conducting sapwood area (Unit: cubic meter per day).

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(sapflux)
sapflux_baseline <- dtmaxcalcu(df=sapflux)
sapflux_fd <- sfcalcu(df=sapflux_baseline)
waterconsume_d <- dwaterconsu(sapflux_fd, resolution = 10)
head(waterconsume_d)


Interpolation of missing values in dendrometer/sap flux data.

Description

This function interpolates NA values based on existing data. The NA values can be replaced by spline interpolation using na.spline of the package zoo or seasonal interpolation considering the seasonality of the daily pattern using na.interp of the package forecast.

Usage

fill.na(df, method = "spline")

Arguments

df

dataframe from mer.na

method

string, 'spline' for the spline interpolation or 'seasonal' for the seasonal interpolation.

Value

A dataframe containing the data including gaps filled with interpolated values.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(dendro_na)
dendro_na_if <-check.na(df=dendro_na, resolution=10)
dendro_na_merge <- mer.na(dendro_na,dendro_na_if)

#The default method is spline interpolation
dendro_fill_spline <- fill.na(dendro_na_merge)
head(dendro_fill_spline)

#The seasonal interpolation
dendro_fill_season <- fill.na(dendro_na_merge, method = "seasonal")
head(dendro_fill_season)


Merge the missing data with the original data

Description

This function merges time series gap(s) and NA values from other series - as indentified by check.na - into the original data.

Usage

mer.na(df, df.na)

Arguments

df

dataframe with the original data

df.na

dataframe with time series gap(s) and NA values from check.na

Value

A dataframe containing the data including original data and missing data.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(dendro_na)
dendro_na_if <-check.na(df=dendro_na, resolution=10)
dendro_na_merge <- mer.na(dendro_na,dendro_na_if)
head(dendro_na_merge)


Simple plotting about dendrometer or sap flux data

Description

This function draws a simple graph about dendrometer or sap flux data.

Usage

plot_simple(df, facet = FALSE)

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with data for the same temporal resolution and time period.

facet

logical, if TRUE draws independent subgraphs, if FALSE draws an integrated graph. Default is FALSE.

Value

Simple graph(s).

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(sapflux)

#Default is an integrated graph.
plot_simple(df=sapflux)

#Drawing independent subgraphs.
plot_simple(df=sapflux,facet = TRUE )


Reading dendrometer or sap flux data.

Description

This function reads dendrometer or sap flux data from .csv or .xlsx files.

Usage

readfile(file, sheet = NULL, sep = NULL, dec = NULL)

Arguments

file

string file name or path of the file.

sheet

the name or index of the sheet to read .xlsx data from.

sep

string the separator of the files. Only if they are different than the standard separators such as comma for .csv file.

dec

the character used in the file for decimal points.

Value

A dataframe with the dendrometer or sap flux data:

Author(s)

Shuo Wen <shuowen@caf.ac.cn>


Resampling temporal resolution of dendrometer/sap flux data

Description

This function is designed to change the temporal resolution of data. Depending on the objective, the user can define either maximum, minimum, or mean values to resample data in hourly, daily, weekly , monthly or yearly frequency.

Usage

resample(df, by, value)

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS.

by

either H, D, W,M or Y to resample data into hourly, daily, weekly, monthly or yearly resolution.

value

either max, min, mean or sum for the resampling value.

Value

Dataframe with resampled data.

Examples

##Load data
data(sapflux)
# To resample hourly with mean value
resample_h_m <- resample(df = sapflux, by='H', value='mean')
head(resample_h_m)


sap flux data

Description

Sap flux dataset from Wushen Banner, Inner Mongolia Autonomous Region, China.

Usage

sapflux

Format

A data frame with 2160 rows and 9 variables. The variables are respectively

Time

Containing date and time in the format yyyy-mm-dd HH:MM:SS

st1

Sap flux data of tree 1

st2

Sap flux data of tree 2

st3

Sap flux data of tree 3

st4

Sap flux data of tree 4

st5

Sap flux data of tree 5

st6

Sap flux data of tree 6

st7

Sap flux data of tree 7

st8

Sap flux data of tree 8

Source

The data was collected by thermal dissipation probes(STDP30, Beijing Sinton Technology Company, Beijing, China).


Sap flux density calculation.

Description

This function calculates sap flux density by Granier's original equation (Granier, 1985&1987).

Usage

sfcalcu(df, psw = 1, a = 0.0119, b = 1.231)

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with data for the same temporal resolution and time period.

psw

proportion of probe in sapwood (ranging from 0.0 to 1.0), default is 1.

a

The constants of empirical formulas are influenced by factors such as species and individual size, default is 0.0119.

b

The constants of empirical formulas are influenced by factors such as species and individual size, default is 1.231.

Details

Fd = a X K^b

where, Fd is sap flux density, a = 0.0119, b = 1.231.

K = (dTmax - dT)/ dT.(Granier, 1985&1987)

If sensors are partially in contact with heartwood, dT can be overstimated, resulting in an underestimation of Fd. However, we can correct dT by:

dT_sw = [dT - (phw * dT_max)]/psw

Where, dT_sw is dT in sapwood (i.e., adjusted dT), dT is original (cleaned) dT, dT_max is dT under zero-flow conditions (i.e., estimated "baseline"), psw is proportion of probe in sapwood (ranging from 0.0 to 1.0), phw is proportion of probe in heartwood (phw = 1 - psw; ranging from 0.0 to 1.0).

And thus, k-values are calculated manually (using user generated code or spreadsheets) by:

k = (dTmax - dT_sw) / dT_sw.

See more details in Clearwater et al.(1999).

Value

A dataframe containing time series and sap flux density series.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

References

Granier A. (1985). Une nouvelle m´ethode pour la mesure du flux de s'eve brute dans le tronc des arbres. Annales des Sciences Forestières, 42, 193-200.

Granier A. (1987). Evaluation of transpiration in a Douglas-fir stand by means of sap flow measurements. Tree Physiology,3(4), 309-320.

Clearwater et al.(1999). Potential errors in measurement of nonuniform sap flow using heat dissipation probes. Tree Physiology,19(10), 681-687.

Examples

##Load data
data(sapflux)
sapflux_baseline <- dtmaxcalcu(df=sapflux)
sapflux_fd <- sfcalcu(df=sapflux_baseline)
head(sapflux_fd)


Conversion between Date and days of year

Description

This function is to convert Date and days of year into each other.

Usage

transf(df, method = "days", year = NULL)

Arguments

df

dataframe with first column containing date and time in the format yyyy-mm-dd HH:MM:SS and following columns with dendrometer data for the same temporal resolution and time period.

method

string, "days" for Convert Date to days of year, "date" for Convert days of year to Date.

year

To convert days of year to Date, the corresponding year needs to be input.

Value

A dataframe containing the data including Date and days of year.

Author(s)

Shuo Wen <shuowen@caf.ac.cn>

Examples

##Load data
data(dendro)

#The default method is Convert Date to days of year
dendro_days <- transf(df = dendro, method = "days")
head(dendro_days)

#Convert days of year to Date
dendro_days_date <- transf(df = dendro_days, method = "date", year =2025)
head(dendro_days_date)