Skip to content

Commit

Permalink
Merge branch 'master' into organicCS
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag authored Oct 10, 2024
2 parents 02282d2 + 07b8170 commit 0ce34a4
Show file tree
Hide file tree
Showing 125 changed files with 4,421 additions and 1,255 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ jobs:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
Expand All @@ -52,15 +51,8 @@ jobs:
brew install --cask xquartz
- uses: r-lib/actions/setup-r-dependencies@v2
if: matrix.config.r == '3.6'
with:
extra-packages: any::rcmdcheck, soiltexture=?ignore-before-r=4.3.0, markovchain=?ignore-before-r=4.0.0, Hmisc=?ignore
needs: check

- uses: r-lib/actions/setup-r-dependencies@v2
if: matrix.config.r != '3.6'
with:
extra-packages: any::rcmdcheck, markovchain=?ignore-before-r=4.0.0
extra-packages: any::rcmdcheck, soiltexture=?ignore-before-r=4.3.0, sf=?ignore-before-r=4.0.0, markovchain=?ignore-before-r=4.0.0, Hmisc=?ignore, knitr=?ignore-before-r=4.0.0, rmarkdown=?ignore-before-r=4.0.0, testthat=?ignore-before-r=4.0.0,
needs: check

- name: Install soilDB from r-universe (R-devel only)
Expand All @@ -70,6 +62,14 @@ jobs:
shell: Rscript {0}

- uses: r-lib/actions/check-r-package@v2
if: matrix.config.r != '3.6'
with:
upload-snapshots: true

- uses: r-lib/actions/check-r-package@v2
if: matrix.config.r == '3.6'
with:
args: 'c("--no-manual", "--as-cran", "--ignore-vignettes", "--no-tests")'
build_args: 'c("--no-manual", "--no-build-vignettes")'
upload-snapshots: true

2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract: The Algorithms for Quantitative Pedology (AQP) project was started in
the scientist to focus on ideas rather than boilerplate data processing tasks <doi:10.1016/j.cageo.2012.10.020>.
These functions and data structures have been extensively tested and documented,
applied to projects involving hundreds of thousands of soil profiles, and deeply
integrated into widely used tools such as SoilWeb <https://casoilresource.lawr.ucdavis.edu/soilweb-apps/>.
integrated into widely used tools such as SoilWeb <https://casoilresource.lawr.ucdavis.edu/soilweb-apps>.
Components of the AQP project (aqp, soilDB, sharpshootR, soilReports packages) serve
an important role in routine data analysis within the USDA-NRCS Soil Science Division.
The AQP suite of R packages offer a convenient platform for bridging the gap between
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
Package: aqp
Version: 2.0.3
Version: 2.0.4
Title: Algorithms for Quantitative Pedology
Authors@R: c(person(given="Dylan", family="Beaudette", role = c("aut", "cre"), email = "[email protected]"), person(given="Pierre", family="Roudier", email="[email protected]", role = c("aut", "ctb")), person(given="Andrew", family="Brown", email="[email protected]", role = c("aut", "ctb")))
Author: Dylan Beaudette [aut, cre], Pierre Roudier [aut, ctb], Andrew Brown [aut, ctb]
Maintainer: Dylan Beaudette <[email protected]>
Depends: R (>= 3.5.0)
Imports: grDevices, graphics, stats, utils, methods, grid, lattice, cluster, sp, stringr, data.table, farver
Suggests: colorspace, ape, soilDB, sf, latticeExtra, tactile, compositions, sharpshootR, markovchain, xtable, testthat, Gmedian, Hmisc, tibble, RColorBrewer, scales, digest, MASS, mpspline2, soiltexture, gower, knitr, rmarkdown, plyr
Description: The Algorithms for Quantitative Pedology (AQP) project was started in 2009 to organize a loosely-related set of concepts and source code on the topic of soil profile visualization, aggregation, and classification into this package (aqp). Over the past 8 years, the project has grown into a suite of related R packages that enhance and simplify the quantitative analysis of soil profile data. Central to the AQP project is a new vocabulary of specialized functions and data structures that can accommodate the inherent complexity of soil profile information; freeing the scientist to focus on ideas rather than boilerplate data processing tasks <doi:10.1016/j.cageo.2012.10.020>. These functions and data structures have been extensively tested and documented, applied to projects involving hundreds of thousands of soil profiles, and deeply integrated into widely used tools such as SoilWeb <https://casoilresource.lawr.ucdavis.edu/soilweb-apps/>. Components of the AQP project (aqp, soilDB, sharpshootR, soilReports packages) serve an important role in routine data analysis within the USDA-NRCS Soil Science Division. The AQP suite of R packages offer a convenient platform for bridging the gap between pedometric theory and practice.
Suggests: mvtnorm, colorspace, ape, soilDB, sf, latticeExtra, tactile, compositions, sharpshootR, markovchain, xtable, testthat, Gmedian, Hmisc, tibble, RColorBrewer, scales, digest, MASS, mpspline2, soiltexture, gower, knitr, rmarkdown, plyr
Description: The Algorithms for Quantitative Pedology (AQP) project was started in 2009 to organize a loosely-related set of concepts and source code on the topic of soil profile visualization, aggregation, and classification into this package (aqp). Over the past 8 years, the project has grown into a suite of related R packages that enhance and simplify the quantitative analysis of soil profile data. Central to the AQP project is a new vocabulary of specialized functions and data structures that can accommodate the inherent complexity of soil profile information; freeing the scientist to focus on ideas rather than boilerplate data processing tasks <doi:10.1016/j.cageo.2012.10.020>. These functions and data structures have been extensively tested and documented, applied to projects involving hundreds of thousands of soil profiles, and deeply integrated into widely used tools such as SoilWeb <https://casoilresource.lawr.ucdavis.edu/soilweb-apps>. Components of the AQP project (aqp, soilDB, sharpshootR, soilReports packages) serve an important role in routine data analysis within the USDA-NRCS Soil Science Division. The AQP suite of R packages offer a convenient platform for bridging the gap between pedometric theory and practice.
License: GPL (>= 3)
LazyLoad: yes
Repository: CRAN
URL: https://github.com/ncss-tech/aqp, https://ncss-tech.github.io/AQP/
BugReports: https://github.com/ncss-tech/aqp/issues
Language: en-US
Encoding: UTF-8
RoxygenNote: 7.3.0
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ export(hzOffset)
export(hzTopographyCodeToLineType)
export(hzTopographyCodeToOffset)
export(hzTransitionProbabilities)
export(hz_dissolve)
export(hz_intersect)
export(hz_lag)
export(hz_segment)
export(hz_to_taxpartsize)
export(invertLabelColor)
export(lookup_taxpartsize)
export(lunique)
export(maxDepthOf)
export(minDepthOf)
Expand Down Expand Up @@ -138,6 +144,7 @@ export(slice.fast)
export(slicedHSD)
export(soilColorSignature)
export(soilPalette)
export(soilTextureColorPal)
export(spc_in_sync)
export(spec2Munsell)
export(splitLogicErrors)
Expand All @@ -151,6 +158,7 @@ export(texmod_to_fragvoltot)
export(textureTriangleSummary)
export(texture_to_taxpartsize)
export(texture_to_texmod)
export(thicknessOf)
export(thompson.bell.darkness)
export(unroll)
export(warpHorizons)
Expand All @@ -168,6 +176,7 @@ exportMethods("horizons<-")
exportMethods("hzID<-")
exportMethods("hzdesgnname<-")
exportMethods("hzidname<-")
exportMethods("hzmetaname<-")
exportMethods("hztexclname<-")
exportMethods("initSpatial<-")
exportMethods("metadata<-")
Expand Down Expand Up @@ -200,6 +209,7 @@ exportMethods(hzID)
exportMethods(hzMetadata)
exportMethods(hzdesgnname)
exportMethods(hzidname)
exportMethods(hzmetaname)
exportMethods(hztexclname)
exportMethods(idname)
exportMethods(isEmpty)
Expand Down Expand Up @@ -310,6 +320,7 @@ importFrom(stats,as.dist)
importFrom(stats,as.formula)
importFrom(stats,cmdscale)
importFrom(stats,complete.cases)
importFrom(stats,cov)
importFrom(stats,dist)
importFrom(stats,formula)
importFrom(stats,median)
Expand Down
18 changes: 15 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# aqp 2.0.3 (2023-12-19)
* performance improvements in `profileInformationIndex()`
# aqp 2.0.4 (2024-10-10)
* CRAN release
* ragged bottom lines in `plotSPC()` now adjusted as function of number of profiles and device width
* additional metadata from `plotSPC()` saved to `last_spc_plot` in `aqp.env`
* added Munsell values of 8.5 and 9.5 to Munsell LUT and (interpolated) reference spectra (#318)
* `munsell2rgb()` now safely selects the closest Munsell value and chroma to those available in the package LUT
* new function `soilTextureColorPal()` for suggesting a color palette suitable for soil texture class

# aqp 2.0.3 (2024-04-18)
* CRAN release
* `simulateColor()` gains new method `mvnorm` for simulating plausible colors
- package mvtnorm added to SUGGESTS
* performance improvements in `profileInformationIndex()`, `dice()`, `slab()`, `spc2mpspline()`, `fillHzGaps()`, and `flagOverlappingHz()`
* aesthetic improvements in `huePositionCircle()`
* new function `thicknessOf()` used for calculating thickness of horizons within each profile of a `SoilProfileCollection` based on horizon-level logical expressions encoded in a function. Default behavior uses pattern matching on the horizon designation name.

# aqp 2.0.2 (2023-11-18)
* CRAN release
Expand Down Expand Up @@ -598,7 +610,7 @@ Incremental changes, should have no effect on previous code:

# aqp 1.0 (2012-03-26)
* 1.0 release, still missing condensed vignettes- should be ready soon
* see http://casoilresource.lawr.ucdavis.edu/drupal/taxonomy/term/56 for samples
* see https://casoilresource.lawr.ucdavis.edu/drupal/taxonomy/term/56 for samples
* A small bug in profile_compare() was fixed, where slices were evaluated as 'soil' based on the bottom depth of the profile, and NOT on the presence of actual data. See ?profile_compare for details. This change will have a minor affect on profile comparisons in cases where Cr or R horizons (usually missing most characterization data) have been extended down to some arbitrary depth (usually 150 or 200 cm) AND a maximum depth of evaluation (max_d) was set beyond the actual depth of most profiles in the collection.

# aqp 0.99-9.8 (2012-03-02)
Expand Down
23 changes: 10 additions & 13 deletions R/Class-SoilProfileCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,9 @@ setClass(
aqp_hzdesgn = "",
aqp_hztexcl = "",
depth_units = 'cm',
stringsAsFactors = FALSE,

# calculate data order (original)
original.order = order(as.character(horizons[[idcol]]),
horizons[[depthcols[1]]])
stringsAsFactors = FALSE
)

# the target order to check/maintain is the default for a new SPC
# metadata$target.order <- metadata$original.order

# add any custom metadata
metadata <- c(metadata,
new.metadata[!names(new.metadata) %in% names(metadata)])
Expand Down Expand Up @@ -955,10 +948,12 @@ setMethod("site", signature(object = "SoilProfileCollection"),
setGeneric("diagnostic_hz", function(object, ...)
standardGeneric("diagnostic_hz"))

#' Retrieve diagnostic data from SoilProfileCollection
#'
#' @description Get diagnostic feature data from SoilProfileCollection. Result is returned in the same \code{data.frame} class used to initially construct the SoilProfileCollection.
#' Get or Set Diagnostic Horizon data in a SoilProfileCollection
#'
#' @description Diagnostic horizons describe features of the soil relevant to taxonomic classification. A single profile may have multiple diagnostic features or horizons, each of which may be comprised of multiple horizons.
#'
#' - `diagnostic_hz()` (get method): Get diagnostic feature data from a SoilProfileCollection.
#'
#' @param object a SoilProfileCollection
#'
#' @docType methods
Expand All @@ -975,9 +970,11 @@ setMethod(f = 'diagnostic_hz', signature(object = 'SoilProfileCollection'),
setGeneric("restrictions", function(object, ...)
standardGeneric("restrictions"))

#' Retrieve restriction data from SoilProfileCollection
#' Get or Set Restriction data in a SoilProfileCollection
#'
#' @description Get restriction data from SoilProfileCollection. Result is returned in the same \code{data.frame} class used to initially construct the SoilProfileCollection.
#' @description Restrictions describe root-limiting features in the soil. A single profile may have multiple restrictions.
#'
#' - `restrictions()` (get method): Get restriction data from a SoilProfileCollection.
#'
#' @param object a SoilProfileCollection
#' @docType methods
Expand Down
6 changes: 3 additions & 3 deletions R/L1_profiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
L1_profiles <- function(x, fm, basis = 1, method = c('regex', 'simple', 'constant'), maxDepthRule = c('max', 'min'), maxDepthConstant = NULL) {

# sanity check, need this for L1 median
if(!requireNamespace('Gmedian'))
stop('package `Gmedian` is required', call.=FALSE)

if(!requireNamespace('Gmedian')) {
stop('package `Gmedian` is required', call. = FALSE)
}

# sanity checks: is this an SPC?
if(! inherits(x, 'SoilProfileCollection')) {
Expand Down
5 changes: 1 addition & 4 deletions R/SoilProfileCollection-integrity.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ setMethod('reorderHorizons',

h <- object@horizons

if (is.null(target.order))
target.order <- metadata(object)$original.order
if (is.null(target.order))
target.order <- 1:nrow(h)
stopifnot(!is.null(target.order))

current.order <- match(target.order,
order(as.character(h[[idname(object)]]),
Expand Down
73 changes: 73 additions & 0 deletions R/SoilProfileCollection-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@
customattr <- customattr[!names(customattr) %in% names(attributes(SoilProfileCollection()))]
attributes(dest)[names(customattr)] <- attributes(src)[names(customattr)]

# original.order metadata no longer created, not transferred
cols <- names(m)[names(m) != "original.order"]

metadata(dest)[cols] <- m[cols]
dest
}
Expand Down Expand Up @@ -291,3 +293,74 @@ setReplaceMethod("GHL",
allowednames = "horizon"
)
})

setGeneric("hzmetaname", function(object, attr, required = FALSE)
standardGeneric("hzmetaname"))

#' @title Get or Set Horizon Metadata Column Name
#' @name hzmetaname
#' @aliases hzmetaname hzmetaname,SoilProfileCollection-method hzmetaname<- hzmetaname,SoilProfileCollection-method
#' @details Store the column name containing a specific type of horizon data in the metadata slot of the SoilProfileCollection.
#' @description `hzmetaname()`: Get column name containing horizon data of interest
#' @param object a SoilProfileCollection
#' @param attr character. Base name for attribute to be stored in metadata. This is prefixed with `"aqp_hz"` for horizon-level metadata for column attributes. e.g. `attr="clay"` results in metadata value retrieved from `"aqp_hzclay"`.
#' @param required logical, is this attribute required? If it is, set to `TRUE` to trigger error on invalid result
#' @docType methods
#' @rdname hzmetaname
#' @export
setMethod("hzmetaname", signature(object = "SoilProfileCollection"),
function(object, attr, required = FALSE) {
.require.metadata.aqp(object,
attr = paste0("aqp_hz", attr),
attrlabel = paste0("Horizon metadata (", attr, ") column"),
message = "\nSee ??hzmetaname",
required = required)
})

setGeneric('hzmetaname<-', function(object, attr, required = FALSE, value)
standardGeneric('hzmetaname<-'))

#' @description `hzmetaname<-`: Set horizon designation column name
#' @param object A _SoilProfileCollection_
#' @param attr _character_. Base name for attribute to be stored in metadata. This is prefixed with `"aqp_hz"` for horizon-level metadata for column attributes. e.g. `attr="clay"` results in metadata value retrieved from `"aqp_hzclay"`.
#' @param value _character_. Name of horizon-level column containing data corresponding to `attr`.
#' @param required _logical_. Is this attribute required? If it is, set to `TRUE` to trigger error on invalid `value`.
#' @docType methods
#' @seealso [guessHzAttrName()]
#' @rdname hzmetaname
#' @export
#' @examples
#'
#' data(sp1)
#'
#' # promote to SPC
#' depths(sp1) <- id ~ top + bottom
#'
#' # set important metadata columns
#' hzdesgnname(sp1) <- "name"
#' hztexclname(sp1) <- "texture"
#'
#' # set custom horizon property (clay content) column
#' hzmetaname(sp1, "clay") <- "prop"
#'
#' # inspect metadata list
#' metadata(sp1)
#'
#' # get horizon clay content column
#' hzmetaname(sp1, "clay")
#'
#' # uses hzdesgname(), hztexclname(), hzmetaname(attr="clay") in function definition
#' estimatePSCS(sp1)
setReplaceMethod("hzmetaname",
signature(object = "SoilProfileCollection"),
function(object, attr, required = FALSE, value) {
.set.metadata.aqp(
object = object,
value = value,
required = required,
attr = paste0("aqp_hz", attr),
attrlabel = paste0("Horizon metadata (", attr, ") column"),
message = "\nSee ??hzmetaname",
allowednames = "horizon"
)
})
Loading

0 comments on commit 0ce34a4

Please sign in to comment.