## EXAMPLES OF averageSP
this_example_runs_about_10s <- TRUE
if (!this_example_runs_about_10s) { # exclude from cran checks
## compute the average profile of the demo object 'SPgroup'
## * by labeling SH/DH layers as weak layers,
## - choosing 3 initial conditions with an above average number of weak layers
## - in as many depth ranges as possible
## * and neglecting crusts for initial conditions
avgList <- averageSP(SPgroup, n = 3,
classifyPWLs = list(pwl_gtype = c("SH", "DH")),
classifyCRs = NULL)
opar <- par(mfrow = c(1, 2))
plot(avgList$avg, ymax = max(summary(avgList$set)$hs))
plot(avgList$set, SortMethod = "unsorted", xticklabels = "originalIndices")
par(opar)
## compute the average profile of the demo object 'SPgroup'
## * by labeling SH/DH/FC/FCxr layers with an RTA threshold of 0.65 as weak layers,
## * otherwise as above
SPx <- computeRTA(SPgroup)
avgList <- averageSP(SPx, n = 3,
classifyPWLs = list(pwl_gtype = c("SH", "DH", "FC", "FCxr"),
threshold_RTA = 0.65),
classifyCRs = NULL)
opar <- par(mfrow = c(1, 2))
plot(avgList$avg, ymax = max(summary(avgList$set)$hs))
plot(avgList$set, SortMethod = "unsorted", xticklabels = "originalIndices")
par(opar)
## compute the average profile of the other demo object 'SPgroup2', which
## contains more stability indices, such as SK38 or p_unstable
## * by labeling SH/DH/FC/FCxr layers that either
## - have an SK38 below 0.95, *or*
## - have a p_unstable above 0.77
SPx <- snowprofileSet(SPgroup2)
avgList <- averageSP(SPx,
classifyPWLs = list(pwl_gtype = c("SH", "DH", "FC", "FCxr"),
threshold_SK38 = 0.95, threshold_PU = 0.77))
opar <- par(mfrow = c(1, 2))
plot(avgList$avg, ymax = max(summary(avgList$set)$hs))
plot(avgList$set, SortMethod = "unsorted", xticklabels = "originalIndices")
par(opar)
}
## EXAMPLES OF dbaSP
## either rescale profiles beforehand...
if (FALSE) { # don't run in package check to save time
SPx <- reScaleSampleSPx(SPgroup)$set # rescale profiles
SPx <- snowprofileSet(lapply(SPx, labelPWL)) # label PWLs
DBA <- dbaSP(SPx, 5, plotChanges = TRUE) # average profiles
}
## or use unscaled snow heights:
if (FALSE) { # don't run in package check to save time
SPx <- snowprofileSet(lapply(SPgroup, labelPWL)) # label PWLs
DBA <- dbaSP(SPx, 5, plotChanges = TRUE) # average profiles
}
Run the code above in your browser using DataLab