run_the_examples <- FALSE # exclude long-running examples
if (run_the_examples) {
## compute average timeseries for simplistic example data set 'SPspacetime'
## first: label weak layers (you can choose your own rules and thresholds!)
SPspacetime <- snowprofileSet(lapply(SPspacetime, function(sp) {
labelPWL(sp, pwl_gtype = c("SH", "DH", "FC", "FCxr"), threshold_RTA = 0.8)
})) # label weak layers in each profile of the profile set 'SPspacetime'
## second: average along several days
avgTS <- averageSPalongSeason(SPspacetime)
## explore resulting object
names(avgTS)
# timeseries figure
plot(avgTS$avgs, main = "average time series")
# add line representing median snow height
lines(avgTS$meta$date, avgTS$meta$hs_median)
# add line representing median new snow amounts
lines(avgTS$meta$date, avgTS$meta$hs - avgTS$meta$thicknessPPDF_median, lty = 'dashed')
# individual profile sets from one day
plot(avgTS$sets[[1]], SortMethod = "hs", main = "individual profiles from first day")
## backtrack individual layers of the average profile...
individualLayers <- backtrackLayers(avgProfile = avgTS$avgs[[1]],
profileSet = avgTS$sets[[1]],
layer = findPWL(avgTS$avgs[[1]], pwl_gtype = c("SH", "DH"),
pwl_date = "2018-10-17", threshold_RTA = 0.8))
## ... to retrieve summary statistics or distributions, e.g. stability distribution
hist(individualLayers[[1]]$rta)
hist(individualLayers[[1]]$depth)
## see the Vignette about averaging profiles for more examples!
}
Run the code above in your browser using DataLab