Skip to content

horizon depths corruption by accumulateDepths() with NA #327

@dylanbeaudette

Description

@dylanbeaudette

I noticed some unusual output from accumulateDepths() when the source SPC contains NA in the top or bottom depths. Further inspection demonstrated unusual output when top == bottom, modification to depths in the absence of horizon names matching pattern, and when the bottom of an old-style O horizon is not directly adjacent to the top depth of the first mineral horizon.

It would be nice if this function could fail gracefully in the presence of "to little" context, such as when horizon depths are NA or top == bottom.

Test effects of NA:

library(aqp)
x <- quickSPC('01:AAAA|BBBBBBBB|CCCCCCC|CrCrCrCrCr')

# no change - expected
x
accumulateDepths(x)

# all top/bottom set to NA
y <- x
y$top[1] <- NA
accumulateDepths(y)

# unexpected changes to all depths
y <- x
y$bottom[1] <- NA
accumulateDepths(y)

Test effects of modifying either top or bottom depths

# unexpected changes to all depths
y <- x
y$bottom[1] <- 0
accumulateDepths(y)

# unexpected changes to all depths
y <- x
y$bottom[1] <- y$top[1]
accumulateDepths(y)

# unexpected changes to all depths
y <- x
y$bottom[2] <- y$top[2]
accumulateDepths(y)


# unexpected changes to all depths
y <- x
y$top[1] <- 10
y$bottom[1] <- 0
accumulateDepths(y)


# unexpected changes  to all depths
y <- x
y$top[1] <- 10
y$bottom[1] <- 0
y$name[1] <- 'O'
accumulateDepths(y)

Test specific problem, a single old-style O horizon with bottom depth matching top depth of next horizon.

# works as expected
y <- x
y$top[1] <- 10
y$bottom[1] <- 0
y$name[1] <- 'O'
y$top[2] <- 0
accumulateDepths(y)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions