Description Usage Arguments Details Value Author(s) References Examples
Calculate the cumulative sums within each cycle in a uniformly sampled series. This function is useful where the phenological (or variable-defined) year is offset from the calendar year. Note that 1) This function assumes every cycle contains the same number of elements, and 2) This function truncates the values before the start of the first cycle and after the end of the last cycle, which for a series of n cycles results in an output series with n - 1 cycles.
1 | sum_cycle(v, b, spc)
|
v |
A vector of numeric values representing a uniformly sampled series of data that oscillate over multiple cycles. |
b |
A positive integer indicating the index (i.e., 1 -> spc) in
the average cycle corresponding to the beginning (or period of least
activity) of the average cycle. Within polar space, |
spc |
A numeric value indicating the number of samples per cycle (e.g., samples per year). |
sum_cycle
calculates the cumulative sums within cycles
beginning from a specified offset (i.e., argument b > 1). Let b
be the index for the beginning of cycle c and e be the index
for the ending index for the cycle {v_b, v_b+1, …, v_e}. Within each cycle the sum at each
index j is calculated as the sum of all values leading up to and
including j following:
c_j = v_i + v_i+1 + … + v_j
This is repeated over c - 1 cycles in series v to obtain a new series of cumulative sums.
Returns a vector of values (and their corresponding indices from the
input vector) representing the cumulative sums within each cycle based on a
specified beginning point. If b
> 1 then the output vector will have
spc
fewer values, which were truncated due to the offset. Output
vector will begin at b
, the average minimum not at the beginning of
the time series, unless the average min is the beginning (b
= 1).
Bjorn J. Brooks, Danny C. Lee, William W. Hargrove, Lars Y. Pomara
Brooks, B.J., Lee, D.C., Desai, A.R., Pomara, L.Y., Hargrove, W.W. (2017). Quantifying seasonal patterns in disparate environmental variables using the PolarMetrics R package.
1 2 3 4 5 6 7 8 9 10 11 12 13 | dpy <- 365 # Days/yr
spy <- 46 # Number of samples in one cycle (yr)
data(mndvi) # Load data
t <- as.vector(mndvi$day) # Days since January 1, 2000
r <- t2rad(t, dpc=dpy) # Transform days of year to radians
v <- as.vector(mndvi$wc) # MODIS NDVI for Willow Creek tower, WI
vx <- mean(vec.x(r,v), na.rm=TRUE) # Avg horizontal vector
vy <- mean(vec.y(r,v), na.rm=TRUE) # Avg vertical vector
rv_ang <- vec_ang(vx,vy) # Angle of the resultant vector (the direction
# that the average vector points)
av_ang <- avec_ang(rv_ang) # Angle marking point of least activity
av_idx <- rad2idx(av_ang, spc=spy) # Index (1-spc) marking avg start of yr
ann_cum <- sum_cycle(v,av_idx,spc=spy)$cumsum # Accum. vals within each yr
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.