plotSPalignment {sarp.snowprofile.alignment} | R Documentation |
Align and plot two snow profiles using DTW
Description
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.
Usage
plotSPalignment(
query,
ref,
dtwAlignment = NULL,
keep.alignment = FALSE,
plot.costDensity = FALSE,
plot.warpedQuery = TRUE,
label.ddate = FALSE,
segCol = "gray70",
segLty = "dotted",
segLwd = 1,
segTidy = FALSE,
segInd = TRUE,
segEmph = NA,
cex = 1,
mainQu = "query",
mainRef = "reference",
mainQwarped = "warped query",
emphasizeLayers_qu = FALSE,
emphasizeLayers_ref = FALSE,
failureLayers_qu = FALSE,
failureLayers_qu_col = "red",
...
)
Arguments
query |
The query snowprofile to be warped |
ref |
The reference snowprofile to be warped against |
dtwAlignment |
|
keep.alignment |
Return |
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 |
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. |
mainQu |
subtitle for query subfigure |
mainRef |
subtitle for reference subfigure |
mainQwarped |
subtitle for warped query subfigure |
emphasizeLayers_qu |
emphasize Layers in query, see plot.snowprofile |
emphasizeLayers_ref |
emphasize Layers in reference, see plot.snowprofile |
failureLayers_qu |
draw arrow to failure layers (see plot.snowprofile)? provide height vector. |
failureLayers_qu_col |
color of arrow(s) (individual color string or vector, see plot.snowprofile) |
... |
Value
dtw object with the resampled '$query' and '$reference', as well as the warped query '$queryWarped' (only if keep.alignment is TRUE)
Author(s)
fherla
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"))