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

Development for v6.1.1 #247

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions .github/workflows/check-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ on:
pull_request:
branches: [main, release/**]

name: R-CMD-check
name: R-CMD-check.yml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -33,7 +35,7 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
Expand All @@ -45,7 +47,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

Expand All @@ -72,4 +74,5 @@ jobs:
with:
upload-snapshots: true
error-on: '"error"'
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

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 = master
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: rSOILWAT2
Version: 6.1.0
Version: 6.1.1-9000
Title: An Ecohydrological Ecosystem-Scale Water Balance Simulation Model
Description: Access to the C-based SOILWAT2 v8.0.0 and functionality for
SQLite-database of weather data.
Expand Down
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# rSOILWAT2 v6.1.0-9000
# rSOILWAT2 v6.1.1-9000
* This version produces the same output as the previous version.

## Bugfix
* `dbW_fixWeather()` now handles data objects with all missing values.


# rSOILWAT2 v6.1.0
* This version produces the same output as the previous version.
* `SOILWAT2` updated to v8.0.0 which now includes a simulation domain;
however, this has no impact on `rSOILWAT2`.
Expand Down
16 changes: 8 additions & 8 deletions R/swWeatherGenerator.R
Original file line number Diff line number Diff line change
Expand Up @@ -1717,16 +1717,16 @@ dbW_fixWeather <- function(
tmp <- which(rowSums(!is_miss1) > 0L)
ids <- tmp[c(1L, length(tmp))]

ids_startend <-
ids_startend <- if (length(tmp) > 0L) {
# before start
(weatherData1[["Year"]] < weatherData1[ids[[1L]], "Year"]) |
(weatherData1[["Year"]] == weatherData1[ids[[1L]], "Year"] &
weatherData1[["DOY"]] < weatherData1[ids[[1L]], "DOY"]) |
# after end
(weatherData1[["Year"]] == weatherData1[ids[[2L]], "Year"] &
weatherData1[["DOY"]] > weatherData1[ids[[2L]], "DOY"]) |
(weatherData1[["Year"]] > weatherData1[ids[[2L]], "Year"])

(weatherData1[["Year"]] == weatherData1[ids[[1L]], "Year"] &
weatherData1[["DOY"]] < weatherData1[ids[[1L]], "DOY"]) |
# after end
(weatherData1[["Year"]] == weatherData1[ids[[2L]], "Year"] &
weatherData1[["DOY"]] > weatherData1[ids[[2L]], "DOY"]) |
(weatherData1[["Year"]] > weatherData1[ids[[2L]], "Year"])
}


#--- Interpolate short missing runs
Expand Down
24 changes: 24 additions & 0 deletions R/sw_Pedotransfer_Functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,30 @@ check_swrcp <- function(swrc_name, swrcp) {
#' awc <- diff(c(0, soils[, "depth_cm"])) * as.vector(diff(tmp))
#'
#'
#' # Available water content "SWA" based on van Genuchten / Rosetta
#' soils <- swSoils_Layers(rSOILWAT2::sw_exampleData)
#' w <- diff(c(0, soils[, "depth_cm"]))
#' vwc <- rbind(
#' day1 = rep(0.1, nrow(soils)),
#' day2 = rep(0.2, nrow(soils))
#' )
#' p <- ptf_estimate(
#' sand = soils[, "sand_frac"],
#' clay = soils[, "clay_frac"],
#' fcoarse = soils[, "gravel_content"],
#' bdensity = soils[, "bulkDensity_g/cm^3"],
#' swrc_name = "vanGenuchten1980",
#' ptf_name = "Rosetta3"
#' )
#' swa_base <- swrc_swp_to_vwc(
#' -3,
#' fcoarse = soils[, "gravel_content"],
#' swrc = list(name = "vanGenuchten1980", swrcp = p)
#' )
#' swa <- t(w * (t(vwc) - swa_base))
#' swa[swa <= 0] <- 0 # SWA [cm / layer] above -3 MPa
#'
#'
#' # Shape of SWRCs
#' theta <- seq(0.05, 0.55, by = 0.001)
#' soils <- data.frame(
Expand Down
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ Your computer must be set up adequately (see below for requirements).
correctly install `rSOILWAT2` or explore one of the development branches.


### Binary package
If you require a binary version of the 'rSOILWAT2' package
(e.g., to distribute to someone without development tools)
for a platform to which you do not have access,
then you may consider using one of the cloud services (no endorsements), e.g.,
- [rhub](https://builder.r-hub.io) offers different
`Linux`, `Windows`, and `macOS` flavors as targets



### Minimal requirements
- on any platform:
Expand Down
24 changes: 24 additions & 0 deletions man/swrc_conversion.Rd

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

37 changes: 37 additions & 0 deletions tests/testthat/test_WeatherGenerator_functionality.R
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,40 @@ test_that("Weather generator (integration tests): compare input/output", {
n = 5L
)
})


test_that("Weather: fix dataset", {
#--- Check: fixedValue, interpolatedLienar, substituteData
x0 <- x <- dbW_weatherData_to_dataframe(rSOILWAT2::weatherData)

tmp <- x[, "Year"] == 1981
ids_to_interp <- tmp & x[, "DOY"] >= 144 & x[, "DOY"] <= 145
x[ids_to_interp, -(1:2)] <- NA

tmp <- x[, "Year"] == 1980
ids_to_sub <- tmp & x[, "DOY"] >= 153 & x[, "DOY"] <= 244
x[ids_to_sub, -(1:2)] <- NA

xf <- dbW_fixWeather(x, x0, return_weatherDF = TRUE)

expect_identical(
xf[["weatherData"]][!ids_to_interp, ],
as.data.frame(x0)[!ids_to_interp, ]
)

expect_gt(sum(!is.na(xf[["meta"]])), 0L)

expect_setequal(
names(table(xf[["meta"]])),
c("fixedValue", "interpolateLinear (<= 7 days)", "substituteData")
)


#--- Check: all values missing in - all values missing out
x <- dbW_weatherData_to_dataframe(rSOILWAT2::weatherData)
x[, weather_dataColumns()] <- NA

xf <- dbW_fixWeather(x, return_weatherDF = TRUE)
expect_true(all(is.na(x[, weather_dataColumns()])))
expect_identical(sum(!is.na(xf[["meta"]])), 0L)
})
Loading