Restrict the DTW warping window for snow profiles alignment
Restrict the DTW warping window for snow profiles alignment
Given a matrix, this function sets all elements of the matrix that are outside the so-called warping window to NA. The warping window is a slanted band of constant width around the main diagonal (i.e., Sakoe-Chiba-band), and it's size can be controlled with function arguments.
iw: matrix of integers indicating their row number (cf., ?row)
jw: matrix of integers indicating their column number (cf., ?col)
iheight: matrix of query height filled into the columns of the matrix
jheight: matrix of ref height filled into the rows of the matrix
iddate: same as iheight, but containing deposition date information (i.e., POSIXct data converted to numeric through matrix call!)
jddate: same as jheight, but containing deposition date information (i.e., POSIXct data converted to numeric through matrix call!)
profile.size: number of layers in the longer one of the two profiles (scalar)
profile.height: snow height of the deeper one of the two profiles (scalar)
window.size: percentage of profile.size or profile.height defining the size of the warping window (i.e., the most restrictive of the two will be applied)
window.size.abs: Instead of a window.size percentage, an absolute value (in cm!) can be provided
ddate.window.size: number of days that exclude layers from the warping window if their deposition dates differ by more than these days
...: unused---but important to be able to provide other warping functions to distanceSPlayers