char_peak_id: Identify charcoal peaks and apply minimum-count screening

View source: R/char_peak_id.R

char_peak_idR Documentation

Identify charcoal peaks and apply minimum-count screening

Description

Mirrors CharPeakID.m from the MATLAB v2.0 codebase. For each threshold column, samples where C_peak exceeds the threshold are flagged, consecutive exceedances are collapsed to a single event (keeping the last sample of each run, i.e. the oldest, matching the MATLAB v1.1 / v2.0 convention), and each event is screened against a minimum-count criterion using the Shuie-Bain (1982) extension of the Detre-White (1970) test for unequal sediment volumes.

Usage

char_peak_id(charcoal, pretreatment, peak_analysis, char_thresh)

Arguments

charcoal

Named list containing:

peak

C_peak series (accI - accIS or accI / accIS), length N.

ybpI

Age at each interpolated sample (cal yr BP), length N.

accI

Interpolated charcoal accumulation rate, length N.

countI

Interpolated charcoal count, length N.

volI

Interpolated sediment volume (cm^3), length N.

pretreatment

Named list with element yrInterp (interpolation resolution, years).

peak_analysis

Named list with elements threshType (1 = global, 2 = local), threshValues (numeric vector, length T), and minCountP (alpha for minimum-count screen).

char_thresh

Named list returned by [char_thresh_global()] or [char_thresh_local()], containing possible (251-bin grid) and pos ([N \times T] threshold matrix).

Details

## Threshold value matrix For **global** thresholds (threshType == 1), char_thresh$pos is a constant-row [N \times T] matrix reused directly. For **local** thresholds (threshType == 2), char_thresh$pos is already [N \times T] (per-sample values).

## Consecutive-peak removal After flagging all exceedances, a diff-based pass retains only the last sample of each consecutive run – the oldest sample within a group of contiguous above-threshold values. This matches the MATLAB v1.1 algorithm (which the v2.0 comment documents correctly despite the v1.1 comment being misleading).

## Minimum-count test For each identified peak i in column j, a time window of \pm 150 yr is constructed around the peak, then narrowed to the adjacent peaks when they fall within the window. The test statistic is

d = \frac{|c_{\min} - (c_{\min}+c_{\max})\,v_{\min}/(v_{\min}+v_{\max})| - 0.5} {\sqrt{(c_{\min}+c_{\max})\,v_{\min}\,v_{\max}/(v_{\min}+v_{\max})^2}}

and the p-value is 1 - \Phi(d) (standard normal CDF; equivalent to MATLAB's 1 - tcdf(d, 1e10) because t_{1\times10^{10}} \to z). Peaks with p > \alpha_{\text{peak}} are removed.

Value

A named list with two components:

charcoal

Input charcoal list augmented with:

  • charPeaks[N \times T] numeric: 1 at peak samples, 0 elsewhere.

  • charPeaksThresh[N \times T] numeric: threshold value at each identified peak, 0 elsewhere.

  • peaksTotal – numeric vector length T: total peaks per threshold column.

  • threshFRI – numeric matrix (\leq N \times T): fire-return intervals derived from peak ages per threshold column.

char_thresh

Input char_thresh list augmented with minCountP[N \times T] matrix of Shuie-Bain p-values (NaN where not computed).

See Also

[char_thresh_local()], [char_thresh_global()], [CharAnalysis()]


CharAnalysis documentation built on May 3, 2026, 5:06 p.m.