This vignette creates a detailed link between the methods described in the paper
Herla, F., Horton, S., Mair, P., & Haegeli, P. (in review). Snow profile alignment and similarity assessment for aggregating, clustering, and evaluating of snowpack model output for avalanche forecasting.
and this companion R package. While the basic workflow and the use of the high-level functions are described in the vignette Basic workflow, this vignette describes how the (default) workflow of the package can be altered and the how the methods could be improved.
The individual steps of aligning snow profiles—taken from the documentation of the core function
resamplingRate = NA) (cf.,
dtw(eponymous R package)
simSPwill be returned.
A series of functions exist that manipulate the snow profiles prior to the alignment or the similarity assessment. All these manipulations happen by default, and can be controlled in the arguments to
Rescaling and resampling
scaleSnowHeight: Scale the total snow height of a profile with a uniform scaling factor (commonly determined from the height of a second profile)
resampleSP: Resample an individual profile
reScaleSampleSPx: Both rescale and resample a set of profiles to identical snow heights and onto a regular grid
Reducing the number of layers
mergeIdentLayers: Merge adjacent layers that have identical properties
rmZeroThicknessLayers: Remove or reset layers of zero thickness (i.e., these layers originate from warping one profile onto another)
Computing a local cost matrix is fundamental to DTW alignments and is carried out in
Assessing the differences of individual snow layers Currently, distance functions are implemented for the layer characteristics grain type, hardness, and deposition date. The distance function for categorical grain types relies on a matrix that stores the distances between different categories. Since the similarity requirements are slighlty different for aligning profiles versus assessing their similarity, two matrices are implemented:
grainSimilarity_align(Table 1A in the paper)
grainSimilarity_evaluate(Table 1B in the paper)
swissSimilarityMatrix(grain type similarity matrix defined by Lehning et al, 2001)
Computing a local cost matrix
First, a distance matrix is computed for each included layer characteristic that stores the distances between individual layer combinations. Then these distance matrices are combined into one resulting distance matrix (i.e., local cost matrix) by weighted averaging. Optionally, a preferential layer matching manipulation can be included into the local cost matrix.
distMatSP all parameters related to the local cost matrix can be controlled, e.g.
layerWeightingMat)—currently, implemented solely based on grain type information.
Obtaining the optimal alignment of pairs of snow profiles is the core task of this package. All functions and controls from the sections 1.1 and 1.2 above can be modified in the call to the core function
dtwSP. Additional controls are, e.g.
Partial alignments (i.e.,
open.end) can be started from the snow surface downwards (
top.down) or from the ground upwards (
bottom.up). When the function is called to align the profiles with multiple different boundary conditions (global, top-down, bottom-up), the alignment that yields the highest similarity is returned.
While DTW computes the matching between the layers, the actual alignment is carried out with a warping function
warpSP. Since that warping is different for bottom-up and top-down alignments, and it is different for the two profiles,
warpSP provides solutions for most combinations.