Skip to content

Commit

Permalink
renaming aloc_taxpartsize() & adding PSCS_levels()
Browse files Browse the repository at this point in the history
  • Loading branch information
smroecker committed May 28, 2024
1 parent 6aef529 commit 81f3cbb
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 17 deletions.
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(HzDepthLogicSubset)
export(L1_profiles)
export(NCSP)
export(PSCS_levels)
export(ReactionClassLevels)
export(SANN_1D)
export(SoilProfileCollection)
Expand All @@ -15,7 +16,6 @@ export(aggregateColor)
export(aggregateSoilDepth)
export(alignTransect)
export(allocate)
export(aloc_taxpartsize)
export(aqp.env)
export(argillic.clay.increase.depth)
export(barron.torrent.redness.LAB)
Expand Down Expand Up @@ -100,6 +100,7 @@ export(hz_dissolve)
export(hz_intersect)
export(hz_lag)
export(hz_segment)
export(hz_to_taxpartsize)
export(invertLabelColor)
export(lunique)
export(maxDepthOf)
Expand Down
15 changes: 8 additions & 7 deletions R/allocate.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#'
#' @return A vector or \code{data.frame} object.
#'
#' @author Stephen Roecker
#'
#' @references
#' Abrol, I., Yadav, J. & Massoud, F. 1988. \href{https://www.fao.org/3/x5871e/x5871e00.htm}{Salt-affected soils and their management}. No. Bulletin 39. Rome, FAO Soils.
#'
Expand Down Expand Up @@ -656,7 +658,9 @@ allocate <- function(..., to = c("FAO Salt Severity", "FAO Black Soil", "ST Diag
#'
#' @return A \code{data.frame} object containing the original idcol and aggregated particle size control section allocation.
#'
#' @seealso \code{\link{texture_to_taxpartsize}}
#' @author Stephen Roecker
#'
#' @seealso [texture_to_taxpartsize()], [PSCS_levels()]
#'
#' @export

Expand Down Expand Up @@ -697,17 +701,14 @@ allocate <- function(..., to = c("FAO Salt Severity", "FAO Black Soil", "ST Diag
#' pscs <- data.frame(id = h$id, rbind(estimatePSCS(h)))
#' names(pscs)[2:3] <- c("top", "bottom")
#'
#' aloc_taxpartsize(horizons(h), pscs)
#' hz_to_taxpartsize(horizons(h), pscs)
#'
#'
aloc_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", idcol = "id", depthcols = c("top", "bottom")) {
hz_to_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", idcol = "id", depthcols = c("top", "bottom")) {
# need to incorporate fine sand for special cases of strongly contrasting classes and rock fragments (?)
# frags = "frags",

# strongly contrasting
pscs_sc <- NULL
pscs_sc <- c("Ashy over clayey", "Ashy over clayey-skeletal", "Ashy over loamy", "Ashy over loamy-skeletal", "Ashy over medial", "Ashy over medial-skeletal", "Ashy over pumiceous or cindery", "Ashy over sandy or sandy-skeletal", "Ashy-skeletal over clayey", "Ashy-skeletal over fragmental or cindery", "Ashy-skeletal over loamy-skeletal", "Ashy-skeletal over sandy or sandy-skeletal", "Cindery over loamy", "Cindery over medial", "Cindery over medial-skeletal", "Clayey over coarse-gypseous", "Clayey over fine-gypseous", "Clayey over fragmental", "Clayey over gypseous-skeletal", "Clayey over loamy", "Clayey over loamy-skeletal", "Clayey over sandy or sandy-skeletal", "Clayey-skeletal over sandy or sandy-skeletal", "Coarse-loamy over clayey", "Coarse-loamy over fragmental", "Coarse-loamy over sandy or sandy-skeletal", "Coarse-silty over clayey", "Coarse-silty over sandy or sandy-skeletal", "Fine-loamy over clayey", "Fine-loamy over fragmental", "Fine-loamy over sandy or sandy-skeletal", "Fine-silty over clayey", "Fine-silty over fragmental", "Fine-silty over sandy or sandy-skeletal", "Hydrous over clayey", "Hydrous over clayey-skeletal", "Hydrous over fragmental", "Hydrous over loamy", "Hydrous over loamy-skeletal", "Hydrous over sandy or sandy-skeletal", "Loamy over ashy or ashy-pumiceous", "Loamy over coarse-gypseous", "Loamy over fine-gypseous", "Loamy over pumiceous or cindery", "Loamy over sandy or sandy-skeletal", "Loamy-skeletal over cindery", "Loamy-skeletal over clayey", "Loamy-skeletal over fragmental", "Loamy-skeletal over gypseous-skeletal", "Loamy-skeletal over sandy or sandy-skeletal", "Medial over ashy", "Medial over ashy-pumiceous or ashy-skeletal", "Medial over clayey", "Medial over clayey-skeletal", "Medial over fragmental", "Medial over hydrous", "Medial over loamy", "Medial over loamy-skeletal", "Medial over pumiceous or cindery", "Medial over sandy or sandy-skeletal", "Medial-skeletal over fragmental or cindery", "Medial-skeletal over loamy-skeletal", "Medial-skeletal over sandy or sandy-skeletal", "Pumiceous or ashy-pumiceous over loamy", "Pumiceous or ashy-pumiceous over loamy-skeletal", "Pumiceous or ashy-pumiceous over medial", "Pumiceous or ashy-pumiceous over medial-skeletal", "Pumiceous or ashy-pumiceous over sandy or sandy skeletal", "Sandy over clayey", "Sandy over loamy", "Sandy-skeletal over loamy") |>
tolower()

x$rn <- 1:nrow(x)
# xy <- hz_intersect(x, y, idcol = idcol, depthcols = depthcols)
Expand Down Expand Up @@ -804,7 +805,7 @@ aloc_taxpartsize <- function(x, y, taxpartsize = "taxpartsize", clay = "clay", i
sc = gsub("over fine over|over very-fine over", "over clayey over", sc)
sc = gsub("over sandy|over sandy-skeletal", "over sandy or sandy-skeletal", sc)

idx_sc = sc %in% pscs_sc
idx_sc = sc %in% .pscs_sc
sc[idx_sc] = sc[idx_sc]
})
xy_lag <- NULL
Expand Down
6 changes: 4 additions & 2 deletions R/segment.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#'
#' @author Stephen Roecker
#'
#' @seealso [dice()], [glom()]
#' @seealso [dice()], [glom()], [hz_dissolve()], [hz_lag()], [hz_intersect()]
#'
#' @export
#'
Expand Down Expand Up @@ -242,7 +242,7 @@ segment <- function(object, intervals, trim = TRUE, hzdepcols = c("top", "bottom
#'
#' @author Stephen Roecker
#'
#' @seealso \code{\link{checkHzDepthLogic}}
#' @seealso [hz_lag()], [hz_intersect()], [hz_segment()] , [checkHzDepthLogic()]
#'
#' @export
#'
Expand Down Expand Up @@ -432,6 +432,7 @@ dissolve_hz <- function(object, by, id = "idcol", hztop = "top", hzbot = "bottom
#'
#' @author Stephen Roecker
#'
#' @seealso [hz_dissolve()], [hz_lag()], [hz_segment()]
#'
#' @export
#'
Expand Down Expand Up @@ -544,6 +545,7 @@ hz_intersect <- function(x, y, idcol = "id", depthcols = c("top", "bottom")) {
#'
#' @author Stephen Roecker
#'
#' @seealso [hz_dissolve()], [hz_intersect()], [hz_segment()]
#'
#' @export
#'
Expand Down
29 changes: 29 additions & 0 deletions man/PSCS_levels.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/allocate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/hz_dissolve.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/hz_intersect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/hz_lag.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/hz_segment.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions man/aloc_taxpartsize.Rd → man/hz_to_taxpartsize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions man/texture.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 81f3cbb

Please sign in to comment.