| Title: | Processing and Analyzing Dendrometer and Sap Flux Data |
|---|---|
| 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. |
| Authors: | Shuo Wen [aut, cre], Xiaoyan Shang [ctb], Wenjian Zhou [ctb], Zhongjie Shi [ths], Xiao Zhang [ths] |
| Maintainer: | Shuo Wen <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0.3 |
| Built: | 2026-10-04 09:47:33 UTC |
| Source: | https://github.com/cran/DendroFlux |
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.
check.na(df, resolution)check.na(df, resolution)
df |
dataframe with first column containing date and time in the format |
resolution |
integer, indicating the resolution of data in minutes. |
A dataframe containing time series gap(s) and NA values from other series.
Shuo Wen <[email protected]>
##Load data data(dendro_na) dendro_na_if <- check.na(df=dendro_na, resolution=10) head(dendro_na_if)##Load data data(dendro_na) dendro_na_if <- check.na(df=dendro_na, resolution=10) head(dendro_na_if)
Climate dataset from Wushen Banner, Inner Mongolia Autonomous Region, China.
climateclimate
A data frame with 2160 rows and 2 variables. The variables are respectively
Containing date and time in the format yyyy-mm-dd HH:MM:SS
Vapor pressure deficit
data vpd from the China Meteorological Data Network http://data.cma.cn/ variable Time is the corresponding time of vpd
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").
dendcalcu(df, method = "cumul_p")dendcalcu(df, method = "cumul_p")
df |
dataframe with first column containing date and time in the format |
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". |
A dataframe containing time series and cumulative growth (or growth variation).
Shuo Wen <[email protected]>
##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)##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 dataset from Wushen Banner, Inner Mongolia Autonomous Region, China.
dendrodendro
A data frame with 2160 rows and 9 variables. The variables are respectively
Containing date and time in the format yyyy-mm-dd HH:MM:SS
Dendrometer data of tree 1
Dendrometer data of tree 2
Dendrometer data of tree 3
Dendrometer data of tree 4
Dendrometer data of tree 5
Dendrometer data of tree 6
Dendrometer data of tree 7
Dendrometer data of tree 8
The data was collected by dendrometer instrument (TR80, Beijing Sinton Technology Company, Beijing, China).
Dendrometer dataset with missing values from Wushen Banner, Inner Mongolia Autonomous Region, China.
dendro_nadendro_na
A data frame with 2157 rows and 9 variables. The variables are respectively
Containing date and time in the format yyyy-mm-dd HH:MM:SS with gaps in time series
Dendrometer data of tree 1 with NA
Dendrometer data of tree 2 with NA
Dendrometer data of tree 3 with NA
Dendrometer data of tree 4 with NA
Dendrometer data of tree 5 with NA
Dendrometer data of tree 6 with NA
Dendrometer data of tree 7 with NA
Dendrometer data of tree 8 with NA
The data, after manual deletion of some entries, was collected by dendrometer instrument (TR80, Beijing Sinton Technology Company, Beijing, China).
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.
dtmaxcalcu(df, method = "MN", predawn = "06:00:00")dtmaxcalcu(df, method = "MN", predawn = "06:00:00")
df |
dataframe with first column containing date and time in the format |
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. |
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).
A dataframe containing time series , dT series and corresponding dTmax series.
Shuo Wen <[email protected]>
Peters et al.(2018). Quantification of uncertainties in conifer sap flow measured with the thermal dissipation method. New Phytologist, 219(4),1283-1299.
##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)##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)
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.
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 )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 )
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. |
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.
A dataframe containing time series , dT series and corresponding dTmax series.
Shuo Wen <[email protected]>
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.
##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)##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)
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.
dtmaxcalcu.moving(df, method = "MAX", win.size = 11, fill = FALSE)dtmaxcalcu.moving(df, method = "MAX", win.size = 11, fill = FALSE)
df |
dataframe with first column containing date and time in the format |
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. |
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).
A dataframe containing time series , dT series and corresponding dTmax series.
Shuo Wen <[email protected]>
Peters et al.(2018). Quantification of uncertainties in conifer sap flow measured with the thermal dissipation method. New Phytologist, 219(4),1283-1299.
##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)##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)
This function roughly calculate the daily water consumption per square centimeter of water-conducting sapwood area, in cubic meters.
dwaterconsu(df, resolution)dwaterconsu(df, resolution)
df |
dataframe containing date and sap flux density. |
resolution |
integer, indicating the resolution of data in minutes. |
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.
A dataframe containing time series and the daily water consumption per square centimeter of water-conducting sapwood area (Unit: cubic meter per day).
Shuo Wen <[email protected]>
##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)##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)
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.
fill.na(df, method = "spline")fill.na(df, method = "spline")
df |
dataframe from mer.na |
method |
string, 'spline' for the spline interpolation or 'seasonal' for the seasonal interpolation. |
A dataframe containing the data including gaps filled with interpolated values.
Shuo Wen <[email protected]>
##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)##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)
This function merges time series gap(s) and NA values from other series - as indentified by check.na - into the original data.
mer.na(df, df.na)mer.na(df, df.na)
df |
dataframe with the original data |
df.na |
dataframe with time series gap(s) and |
A dataframe containing the data including original data and missing data.
Shuo Wen <[email protected]>
##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)##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)
This function draws a simple graph about dendrometer or sap flux data.
plot_simple(df, facet = FALSE)plot_simple(df, facet = FALSE)
df |
dataframe with first column containing date and time in the format |
facet |
logical, if |
Simple graph(s).
Shuo Wen <[email protected]>
##Load data data(sapflux) #Default is an integrated graph. plot_simple(df=sapflux) #Drawing independent subgraphs. plot_simple(df=sapflux,facet = TRUE )##Load data data(sapflux) #Default is an integrated graph. plot_simple(df=sapflux) #Drawing independent subgraphs. plot_simple(df=sapflux,facet = TRUE )
This function reads dendrometer or sap flux data from .csv or .xlsx files.
readfile(file, sheet = NULL, sep = NULL, dec = NULL)readfile(file, sheet = NULL, sep = NULL, dec = NULL)
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. |
A dataframe with the dendrometer or sap flux data:
Shuo Wen <[email protected]>
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.
resample(df, by, value)resample(df, by, value)
df |
dataframe with first column containing date and time in the format |
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. |
Dataframe with resampled data.
##Load data data(sapflux) # To resample hourly with mean value resample_h_m <- resample(df = sapflux, by='H', value='mean') head(resample_h_m)##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 dataset from Wushen Banner, Inner Mongolia Autonomous Region, China.
sapfluxsapflux
A data frame with 2160 rows and 9 variables. The variables are respectively
Containing date and time in the format yyyy-mm-dd HH:MM:SS
Sap flux data of tree 1
Sap flux data of tree 2
Sap flux data of tree 3
Sap flux data of tree 4
Sap flux data of tree 5
Sap flux data of tree 6
Sap flux data of tree 7
Sap flux data of tree 8
The data was collected by thermal dissipation probes(STDP30, Beijing Sinton Technology Company, Beijing, China).
This function calculates sap flux density by Granier's original equation (Granier, 1985&1987).
sfcalcu(df, psw = 1, a = 0.0119, b = 1.231)sfcalcu(df, psw = 1, a = 0.0119, b = 1.231)
df |
dataframe with first column containing date and time in the format |
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. |
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).
A dataframe containing time series and sap flux density series.
Shuo Wen <[email protected]>
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.
##Load data data(sapflux) sapflux_baseline <- dtmaxcalcu(df=sapflux) sapflux_fd <- sfcalcu(df=sapflux_baseline) head(sapflux_fd)##Load data data(sapflux) sapflux_baseline <- dtmaxcalcu(df=sapflux) sapflux_fd <- sfcalcu(df=sapflux_baseline) head(sapflux_fd)
This function is to convert Date and days of year into each other.
transf(df, method = "days", year = NULL)transf(df, method = "days", year = NULL)
df |
dataframe with first column containing date and time in the format |
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. |
A dataframe containing the data including Date and days of year.
Shuo Wen <[email protected]>
##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)##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)