Computes a logical is_static flag for each row in tag$magnetic using the
acceleration magnitude.
The classification is done in three steps:
Compute the acceleration norm
gn = sqrt(x^2 + y^2 + z^2)for each sample.Apply the hard threshold
abs(gn - 1) < static_thr_hardto build the initial static candidates.If
tag$accelerationis available, cluster the positivevaluesamples into low- and high-activity groups, force the high-activity group toFALSE, then remove outliers among the remaining candidate static points using a MAD rule with thresholdstatic_thr_outlier.
Arguments
- tag
A
GeoPressureRtag object containing a$magneticdata frame withacceleration_x,acceleration_y, andacceleration_z. Iftag$accelerationis present, itsvaluecolumn is used as an activity signal.- static_thr_hard
Numeric or
NULL. Hard threshold around 1 g used to build the initial candidate static set. IfNULL, the default0.15is used.- static_thr_outlier
Numeric or
NULL. MAD threshold used to remove outliers among the candidate static samples. IfNULL, the default3is used.- use_activity
Logical. If
TRUEandtag$accelerationis available, use activity clustering to flag high-activity samples as moving before MAD outlier filtering.
Value
The input tag object with tag$magnetic$is_static added or updated.
tag$magnetic$is_static is a logical vector where TRUE denotes samples
considered static and FALSE denotes samples considered moving.
Examples
library(GeoPressureR)
withr::with_dir(system.file("extdata", package = "GeoMagR"), {
tag <- tag_create("14DM", quiet = TRUE)
tag_static_obj <- tag_static(tag)
table(tag_static_obj$magnetic$is_static)
# A stricter hard threshold keeps fewer samples as static
tag_static_strict <- tag_static(tag, static_thr_hard = 0.05, static_thr_outlier = 2)
table(tag_static_strict$magnetic$is_static)
})
#>
#> FALSE TRUE
#> 952 998
