## Empty layers object:
snowprofileLayers()
## simple layers example that recycles the hardness 1F+: with warning issued!
## Try what happens if you provide ddate as character array without a timezone.
snowprofileLayers(height = c(10, 25, 50),
hardness = char2numHHI('1F+'),
gtype = c('FC', NA, 'PP'),
ddate = as.POSIXct(c(NA, NA, "2020-02-15 10:45:00"),
tz = "Etc/GMT+7"))
## create snowprofileLayers object from data.frame
## and feed it into a snowprofile object:
df <- data.frame(height = c(10, 25, 50),
hardness = c(2, 3, 1),
gtype = c('FC', NA, 'PP'),
stringsAsFactors = TRUE)
spL <- snowprofileLayers(layerFrame = df)
(sp <- snowprofile(layers = spL))
##### Create top-down recorded snowprofileLayers ####
## check out how the fields 'hs' and 'maxObservedDepth' are auto-filled in the
## resulting snowprofile object!
## 1.) Specify depth and hs:
## In that case the routine will assume that the deepest layer extends down to the ground
(sp1 <- snowprofile(layers = snowprofileLayers(depth = c(40, 25, 0),
hardness = c(2, 3, 1),
gtype = c('FC', NA, 'PP'),
hs = 50)))
## note that sp and sp1 are the same profiles:
all(sapply(names(sp$layers), function(cols) {sp$layers[cols] == sp1$layers[cols]}), na.rm = TRUE)
## 2.) Specify depth, hs and thickness or maxObservedDepth:
## This will include a basal layer of NAs to fill the unobserved space down to the ground.
(sp2 <- snowprofile(layers = snowprofileLayers(depth = c(40, 25, 0),
hardness = c(2, 3, 1),
gtype = c('FC', NA, 'PP'),
hs = 70,
maxObservedDepth = 50)))
## 3.) Specify depth and maxObservedDepth:
## This will include a basal layer of NAs which is 1 cm thick to flag the unknown basal layers.
(sp3 <- snowprofile(layers = snowprofileLayers(depth = c(40, 25, 0),
hardness = c(2, 3, 1),
gtype = c('FC', NA, 'PP'),
gsize = c(2, NA, NA),
maxObservedDepth = 50)))
## 4.) Specify depth and thickness:
## This is equivalent to the example spL3 above!
## This will include a basal layer of NAs which is 1 cm thick to flag the unknown basal layers.
(sp4 <- snowprofile(layers = snowprofileLayers(depth = c(40, 25, 0),
thickness = c(10, 15, 25),
hardness = c(2, 3, 1),
gtype = c('FC', NA, 'PP'))))
## 5.) Specify only depth: issues warning!
(sp5 <- snowprofile(layers = snowprofileLayers(depth = c(40, 25, 0),
hardness = c(2, 3, 1),
gtype = c('FC', NA, 'PP'))))
## plot all 5 top.down-recorded profiles:
set <- snowprofileSet(list(sp1, sp2, sp3, sp4, sp5))
plot(set, SortMethod = "unsorted", xticklabels = "originalIndices",
hardnessResidual = 0.1, hardnessScale = 1.5, TopDown = TRUE,
main = "TopDown Plot")
plot(set, SortMethod = "unsorted", xticklabels = "originalIndices",
hardnessResidual = 0.1, hardnessScale = 1.5, TopDown = FALSE,
main = "BottomUp Plot")
Run the code above in your browser using DataLab