ncss-tech / aqp

Algorithms for Quantitative Pedology
http://ncss-tech.github.io/aqp/
54 stars 14 forks source link

support for non-integer depths #106

Open dylanbeaudette opened 4 years ago

brownag commented 4 years ago

If we had fractional centimeter data wouldn't it be possible to just multiply by 10, round, and switch depth units to "mm"? I'd be interested to see what functions break if one were to attempt something like that

dylanbeaudette commented 4 years ago

Yup, that was the original "fix" for Pierre a while back: convert depths from m -> cm and round accordingly.

dylanbeaudette commented 4 years ago

This won't happen until slice() and many related functions have been re-written.

dylanbeaudette commented 1 year ago

Better than it used to be, but dice and slab aren't fully robust to non-integer depths. plotSPC works as expected.

library(aqp)

# testing non-integer depths

x <- list(
  id = 'P1',
  depths = c(6.5, 25.25, 33.3, 100.1, 150),
  name = c('A', 'AB', 'Bw', 'Bt', 'Cr'),
  clay = c(8, 12, 15, 22, 25)
)

s <- quickSPC(x)
plotSPC(s, name.style = 'center-center', cex.names = 1, plot.depth.axis = FALSE, hz.depths = TRUE)

checkHzDepthLogic(s)

## dice()

# almost
head(dice(s, SPC = FALSE), 10)

# nope
head(dice(s, fm = 0:10 ~ ., SPC = FALSE), 10)

## slab

# nope
slab(s, fm = ~ clay, slab.fun = mean)

# nope
slab(s, fm = ~ clay, slab.fun = mean, slab.structure = c(0, 100))