window_idx: Calculate index values marking truncation endpoints for a...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/window_idx.R

Description

Calculate index values marking the truncation endpoints for a window within a series of cumulative sums. In a phenological context these endpoints define the beginning and end of a quantitatively specified growing season.

Usage

1
window_idx(s, c, cy, lb, ub)

Arguments

s

A vector of numeric values representing a uniformly sampled series of cumulative sums. s can be obtained using sum_cycle

c

A numeric value indicating the number of cycles in series s.

cy

A positive integer in the range [0,c] indicating the cycle (year) within which to calculate truncation endpoints.

lb

A numeric value in the range [0,0.5] indicating the percent of cumulative total to truncate from the first half of cycle number cy. For example, 0.15 will result in remove the interval corresponding to [0%,15%] representing a window that begins after 15% of cumulative annual total is crossed.

ub

A numeric value in the range (0.5,1] indicating the percent of cumulative total to truncate from the last half of cycle cy. For example, 0.8 will result in removing (80%,100%] of cumulative NDVI representing a window that begins after the 85% of cumulative annual total is crossed.

Details

window_idx returns a vector of two values indicating endpoints for a window within series S. Cumulative sums within these endpoints are used to place threshold crossings in the data such as growing season start and end points. Since a growing season can be based on crossing points of cumulative sums. Make S a series of cumulative sums and s a subset of growing season values within S. s can be defined on the basis of thresholds crossings of cumulative sums as follows. For a given threshold value, t, let j(t) be the index j for S such that

{i: t < S_i < (t-1)}

Then min[j(t)] is the index of S marking the first value larger than t, which is also the beginning of the growing season. max[j(t)] marks the ending index.

Figure 2. This visualization shows how the subset of values representing the growing season are selected based on a cumulative NDVI threshold percentage of 15%. The growing season is defined to start after cumulative NDVI reaches 15% of the total for that phenology-centered year and ends at 85%.
Figure: ex2.png

Value

Returns a vector of the five indexes (from the input) marking the following timing metrics: early season (lb), early-mid season (midpoint of lb and 50 (50 cumulative total and ub), and late season (ub).

Author(s)

Bjorn J. Brooks, Danny C. Lee, William W. Hargrove, Lars Y. Pomara

References

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
dpy <- 365                 # Days/yr
c <- 12                    # Num. of years/cycles
spc <- 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,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 resultant vec (point of max activity)
av_ang <- avec_ang(rv_ang)  # Angle marking point of least activity
av_idx <- rad2idx(av_ang, spc=spc) # Index (1-spc) marking avg start of yr
ann_cum <- sum_cycle(v,av_idx,spc=spc)$cumsum # Accum. vals within each yr
# Find seasonal beg, end index for the 2nd yr using 15th pctile of cum NDVI
cy <- 2                    # The second yr of data (which is 2001 here)
es.idx <- window_idx(ann_cum,c-1,cy,0.15,0.8)[1] # Idx of ann_cum marking ES
ms.idx <- window_idx(ann_cum,c-1,cy,0.15,0.8)[2] # Idx of ann_cum marking MS
ls.idx <- window_idx(ann_cum,c-1,cy,0.15,0.8)[3] # Idx of ann_cum marking LS
es <- t[es.idx]          # Early growing season day of pheno yr
ems <- t[es.idx]         # Early-mid growing season day of pheno yr
ms <- t[ms.idx]          # Mid (50th %tile) growing season day
lms <- t[ls.idx]         # Late-mid growing season day of pheno yr
ls <- t[ls.idx]          # Late growing season day of pheno yr
Sintv <- ls-es           # Days in the growing season
ann_cum[es.idx:ls.idx]   # Show cumulative NDVI vals for growing season

bjornbrooks/PolarMetrics documentation built on Dec. 22, 2020, 1:42 a.m.