Split and Merge Algorithm Usage

Sam Albers and Doug Collinge


Packages needing loading


Split and merge algorithm

Water column identification is provided by the split-and-merge algorithm. Implementation of the split-and-merge algorithm for a water profile occurs within the wtr.layer() function:

Simple application of the split and merge algorithm

Below is a simple one profile example of determining key water column parameters using the split-and-merge algorithm. The default behaviour for wtr.layer is to run the algorithm without specifying the number of segments. wtr.layer() adopt as defaults the convention of a minimum depth (z0) of 2.5 m, a maximum depth (zmax) of 150 m and a error threshold (thres) of 0.1.

wldf <- wtr.layer(depth = latesummer$depth, measure = latesummer$temper)
min_depth nseg mld cline segments
2.5 4 7.0565 16.39025 list(segment_depth = c(2.598, 7.0565, 25.724, 98.139), segment_measure = c(17.9406, 17.38405, 5.51445, 4.46375))

In this example, you’ll note that wldf$cline is formatted as a list-column. A thorough demonstration of a list column can be found here. This type of data format has been included here to consolidate split and merge results and align the output to work well with tidyverse tools. If you are interested in working with the segments data from wtr.layer(), use this approach:

## [[1]]
##   segment_depth segment_measure
## 1        2.5980        17.94060
## 2        7.0565        17.38405
## 3       25.7240         5.51445
## 4       98.1390         4.46375

Note that the axes of the water column profile have been reversed and flipped to better visualize the water column and conform to standard limnological displays.

plot(y = latesummer$depth, x = latesummer$temper, ylim = rev(range(latesummer$depth)))
abline(h = wldf$cline, col='blue')
abline(h = wldf$mld, col='red')
abline(h = wldf$min_depth, col='green')
text(16, wldf$cline+3, "Thermocline", col = 'blue')
text(16, wldf$mld+3, "Mix Layer Depth", col = 'red')
text(16, wldf$min_depth+3, "Minimum Depth", col = 'green')

Important references