This is a plotting routine for the DTW alignment of two snow profiles. Either provide two snow profiles or a dtwSP alignment object. Don't resize the figure, otherwise the plotted alignment segments will not be in correct place anymore! If you need a specific figure size, use grDevices::png with a width/height aspect ratio of about 5/3.
ref: The reference snowprofile to be warped against
dtwAlignment: dtwSP object (optional)
keep.alignment: Return dtwSP object with resampled query, ref and warped query? boolean
plot.costDensity: First graph, plotCostDensitySP with warping path? boolean, default = FALSE
plot.warpedQuery: plot warped query additionally to query, ref and alignment segments? (i.e. three pane plot) boolean, default = TRUE
label.ddate: Label deposition date in profiles? (Only possible if ddate is given in 'dims', cf distanceSPlayers )
segCol: Color of alignment segments. Passed to gpar , default = "gray70"
segLty: Linestyle of alignment segments. Passed to gpar , default = "dotted"
segLwd: Linewidth of alignment segments, default = 1
segTidy: Tidy up alignment segments, if profiles have not been resampled? boolean, default FALSE i.e. one segment line per (synthetic) layer interface -> supports visual understanding of alignment, but is also often confusing (segTidy currently only implemented for tidying up to gtype and hardness interfaces)
segInd: Index vector of query layers that will get alignment segments drawn. Note, that the profiles might get resampled, so pre-calculate your correct indices!
segEmph: Index vector of query layers, the alignment segments of which will be emphasized (thick and red). Note, that the profiles might get resampled, so pre-calculate your correct indices!
cex: font size, cf. par
mainQu: subtitle for query subfigure
mainRef: subtitle for reference subfigure
mainQwarped: subtitle for warped query subfigure
emphasizeLayers_qu: emphasize Layers in query, see sarp.snowprofile::plot.snowprofile
emphasizeLayers_ref: emphasize Layers in reference, see sarp.snowprofile::plot.snowprofile
failureLayers_qu: draw arrow to failure layers (see sarp.snowprofile::plot.snowprofile )? provide height vector.
failureLayers_qu_col: color of arrow(s) (individual color string or vector, see sarp.snowprofile::plot.snowprofile )
...: Arguments passed to distanceSPlayers and dtwSP
Returns
dtw object with the resampled 'query′and′reference', as well as the warped query '$queryWarped' (only if keep.alignment is TRUE)
Examples
plotSPalignment(SPpairs$B_modeled1, SPpairs$B_modeled2)plotSPalignment(SPpairs$B_modeled1, SPpairs$B_modeled2, dims = c("gtype"), weights = c(1))## alternatively keep alignment:alignment <- plotSPalignment(SPpairs$B_modeled1, SPpairs$B_modeled2, keep.alignment =TRUE)print(paste("Similarity between profiles:", alignment$sim))## alternatively, with precomputed alignment and emphasized layer matches:dtwAlignment <- dtwSP(SPpairs$A_modeled, SPpairs$A_manual, open.end =FALSE)plotSPalignment(dtwAlignment = dtwAlignment, segEmph = c(190,192))## directly after plotting, add text to figure:grid::grid.text("Profiles SPpairs$A (modeled/manual)", x =0.5, y =0.8, gp = grid::gpar(fontsize=12, col="grey"))