Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature soildensity #215

Merged
merged 4 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "src/SOILWAT2"]
path = src/SOILWAT2
url = https://github.com/DrylandEcology/SOILWAT2
branch = master
branch = feature_soildensity_type
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: rSOILWAT2
Version: 5.3.1-9000
Version: 6.0.0-9000
Title: An Ecohydrological Ecosystem-Scale Water Balance Simulation Model
Description: Access to the C-based SOILWAT2 v6.5.1 and functionality for
SQLite-database of weather data.
Expand Down Expand Up @@ -45,7 +45,7 @@ License: GPL-3
URL: https://github.com/DrylandEcology/rSOILWAT2
BugReports: https://github.com/DrylandEcology/rSOILWAT2/issues
Encoding: UTF-8
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
LazyData: true
Language: en-US
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ exportMethods("swSite_ModelCoefficients<-")
exportMethods("swSite_ModelFlags<-")
exportMethods("swSite_SWClimits<-")
exportMethods("swSite_SnowSimulationParams<-")
exportMethods("swSite_SoilDensityInputType<-")
exportMethods("swSite_SoilTemperatureConsts<-")
exportMethods("swSite_SoilTemperatureFlag<-")
exportMethods("swSite_TranspCoefficients<-")
Expand Down Expand Up @@ -307,6 +308,7 @@ exportMethods(swSite_ModelCoefficients)
exportMethods(swSite_ModelFlags)
exportMethods(swSite_SWClimits)
exportMethods(swSite_SnowSimulationParams)
exportMethods(swSite_SoilDensityInputType)
exportMethods(swSite_SoilTemperatureConsts)
exportMethods(swSite_SoilTemperatureFlag)
exportMethods(swSite_TranspCoefficients)
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# rSOILWAT2 devel
* `r-lib` Github Actions updated to `v2`;
separate workflows for `R-CMD-check` and `test-coverage` (#202).
* Class `swSite` gains new slot `"SoilDensityInputType"` and associated
methods `swSite_SoilDensityInputType()` (#209).
This encodes if soil density inputs represent matric soil or bulk soil values.


# rSOILWAT2 v5.3.1
Expand Down
20 changes: 20 additions & 0 deletions R/A_swGenericMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,16 @@ setGeneric(
function(object) standardGeneric("swSite_SoilTemperatureConsts")
)

#' \code{swSite_SoilTemperatureFlag}
#' @param object An object of class \code{\linkS4class{swSite}} or
#' \code{\linkS4class{swInputData}}.
#' @seealso \code{\linkS4class{swSite}} and \code{\linkS4class{swInputData}}
setGeneric(
"swSite_SoilDensityInputType",
function(object) standardGeneric("swSite_SoilDensityInputType")
)


#' \code{swSite_TranspirationRegions}
#' @param object An object of class \code{\linkS4class{swSite}} or
#' \code{\linkS4class{swInputData}}.
Expand Down Expand Up @@ -1608,6 +1618,16 @@ setGeneric(
function(object, value) standardGeneric("swSite_SoilTemperatureConsts<-")
)

#' \code{swSite_SoilDensityInputType<-}
#' @param object An object of class \code{\linkS4class{swSite}} or
#' \code{\linkS4class{swInputData}}.
#' @param value A value to assign to a specific slot of the \code{object}.
#' @seealso \code{\linkS4class{swSite}} and \code{\linkS4class{swInputData}}
setGeneric(
"swSite_SoilDensityInputType<-",
function(object, value) standardGeneric("swSite_SoilDensityInputType<-")
)

#' \code{swSite_TranspirationRegions<-}
#' @param object An object of class \code{\linkS4class{swSite}} or
#' \code{\linkS4class{swInputData}}.
Expand Down
28 changes: 28 additions & 0 deletions R/F_swSite.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ setClass(
IntrinsicSiteParams = "numeric",
SoilTemperatureFlag = "logical",
SoilTemperatureConstants = "numeric",
SoilDensityInputType = "integer",
TranspirationRegions = "matrix"
)
)
Expand Down Expand Up @@ -128,6 +129,14 @@ setValidity("swSite", function(object) {
msg <- "@SoilTemperatureConstants length != 10."
val <- if (isTRUE(val)) msg else c(val, msg)
}
if (typeof(object@SoilDensityInputType) != "integer") {
msg <- "@SoilDensityInputType is of integer type."
val <- if (isTRUE(val)) msg else c(val, msg)
}
if (length(object@SoilDensityInputType) != 1L) {
msg <- "@SoilDensityInputType length != 1."
val <- if (isTRUE(val)) msg else c(val, msg)
}
if (typeof(object@TranspirationRegions) != "integer") {
msg <- "@TranspirationRegions is of integer type."
val <- if (isTRUE(val)) msg else c(val, msg)
Expand Down Expand Up @@ -239,6 +248,14 @@ setMethod("swSite_SoilTemperatureFlag", "swSite",
setMethod("swSite_SoilTemperatureConsts", "swSite",
function(object) slot(object, "SoilTemperatureConstants"))

#' @rdname swSite-class
#' @export
setMethod(
"swSite_SoilDensityInputType",
"swSite",
function(object) slot(object, "SoilDensityInputType")
)

#' @rdname swSite-class
#' @export
setMethod("swSite_TranspirationRegions", "swSite",
Expand Down Expand Up @@ -343,6 +360,17 @@ setReplaceMethod("swSite_SoilTemperatureConsts", signature = "swSite",
object
})

#' @rdname swSite-class
#' @export
setReplaceMethod(
"swSite_SoilDensityInputType",
signature = "swSite",
definition = function(object, value) {
object@SoilDensityInputType <- as.integer(value[1L])
validObject(object)
object
})

#' @rdname swSite-class
#' @export
setReplaceMethod("swSite_TranspirationRegions", signature = "swSite",
Expand Down
19 changes: 19 additions & 0 deletions R/K_swContainer.R
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,14 @@ setMethod(
function(object) swSite_SoilTemperatureConsts(object@site)
)

#' @rdname swInputData-class
#' @export
setMethod(
"swSite_SoilDensityInputType",
signature = "swInputData",
function(object) swSite_SoilDensityInputType(object@site)
)

#' @rdname swInputData-class
#' @export
setMethod(
Expand Down Expand Up @@ -1633,6 +1641,17 @@ setReplaceMethod(
}
)

#' @rdname swInputData-class
#' @export
setReplaceMethod(
"swSite_SoilDensityInputType",
signature = "swInputData",
function(object, value) {
swSite_SoilDensityInputType(object@site) <- value
object
}
)

#' @rdname swInputData-class
#' @export
setReplaceMethod(
Expand Down
Binary file modified data/sw_exampleData.rda
Binary file not shown.
4 changes: 4 additions & 0 deletions inst/extdata/example1/Input/siteparam.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ NAN # aspect = surface azimuth angle (degrees): S=0, E=-90, N=±180, W=90;
# Name of CO2 scenario: see input file `carbon.in`
RCP85

# --- Soil characterization ---
# Are inputs of density representing bulk soil (type 1) or the matric component (type 0)?
0

#---- Transpiration regions
# ndx : 1=shallow, 2=medium, 3=deep, 4=very deep
# layer: deepest soil layer number of the region.
Expand Down
6 changes: 6 additions & 0 deletions man/swInputData-class.Rd

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

6 changes: 6 additions & 0 deletions man/swSite-class.Rd

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

20 changes: 20 additions & 0 deletions man/swSite_SoilDensityInputType-set.Rd

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

18 changes: 18 additions & 0 deletions man/swSite_SoilDensityInputType.Rd

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

2 changes: 1 addition & 1 deletion src/SOILWAT2
Loading