# diurnal_centroid: Diurnal centroid calculation In sapfluxnetr: Working with 'Sapfluxnet' Project Data

## Description

Calculate the diurnal centroid for sapflow variables

## Usage

 `1` ```diurnal_centroid(variable) ```

## Arguments

 `variable` A numeric vector containing the sapflow values for a day at a regular intervals. Missing values are allowed but not recommended

## Details

The code for this function has been kindly provided by Jacob Nelson in python (see https://github.com/jnelson18/FluxnetTools/blob/master/FileS3.py) and has been translated to a tidy data phylosophy in R to be used inside a `summarise` statement.

## Value

A numeric value with the diurnal centroid value (0 to 24 h)

## Diurnal centroid algorithm

Given a continuous subdaily sapflow values at regular intervals V = {x_1, ..., x_n} to obtain the diurnal centroid each value is multiplied by its interval index and summed up and divided by the sum of the values for the day and finally the value is normalized to 24h:

∑ {x_1 * 1, x_2 * 2, ... , x_n * n} / ∑ {x_1, x_2, ... , x_n} * (24/n)

With even values for all the intervals (i.e. 100 for all), centroid converges to 12h at more than 1000 intervals per day. With only 48 (half hourly measurements) centroid converges to 12.25h and with 24 intervals (hourly measurements) centroid converges to 12.5h. So, using diurnal centroid value in half hourly datasets or above can have a considerable error associated.

## Author(s)

Jacob Nelson & Víctor Granda

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```# dplyr library(dplyr) # check convergence to 12h: diurnal_centroid(rep(1, 1000)) # 12.012 h diurnal_centroid(rep(10000, 1000)) # 12.012 h, variable scale not affects calculation # sapflow diurnal centroid data('ARG_TRE', package = 'sapfluxnetr') sfn_metrics( ARG_TRE, period = '1 day', .funs = list(~ diurnal_centroid(.), ~ data_coverage(., timestep, period_minutes)), solar = FALSE, interval = 'general' ) ```

sapfluxnetr documentation built on Aug. 28, 2020, 1:13 a.m.