Skip to content

Commit

Permalink
Merge pull request #8 from DrylandEcology/release/v0.2.0
Browse files Browse the repository at this point in the history
Release v0.2.0

- Replace rgdal/rgeos with sf/terra/stars #4
- Updating linting to lintr >= v3.0.0 #5
- Update github actions to use r-lib actions v2 #6
  • Loading branch information
dschlaep authored May 24, 2023
2 parents fca01d0 + 01c8b38 commit 254f6e3
Show file tree
Hide file tree
Showing 27 changed files with 369 additions and 451 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, release/**]
pull_request:
branches: [main, release/**]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
94 changes: 0 additions & 94 deletions .github/workflows/check-standard.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, release/**]
pull_request:
branches: [main, release/**]

name: lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, release/**]
pull_request:
branches: [main, release/**]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
13 changes: 13 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
linters: lintr::linters_with_tags(
tags = NULL,
#--- Change arguments of linters:
line_length_linter = lintr::line_length_linter(length = 80L),
#--- Turn off linters:
implicit_integer_linter = NULL,
object_length_linter = NULL,
object_name_linter = NULL,
todo_comment_linter = NULL,
cyclocomp_linter = NULL,
yoda_test_linter = NULL)
error_on_lint: TRUE
encoding: "UTF-8"
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rSW2exter
Title: Access External Data as Input for SOILWAT2 and STEPWAT2 Simulations
Version: 0.1.1
Version: 0.2.0
Authors@R: c(
person(
"Daniel", "Schlaepfer",
Expand All @@ -17,17 +17,18 @@ Imports:
rSW2utils (>= 0.1.0),
rSW2st (>= 0.1.0),
rSW2data (>= 0.1.0),
terra,
raster,
reshape2,
sf,
sp
sf
Suggests:
FedData,
FedData (>= 3.0.2),
soilDB (>= 2.5.7),
sp,
utils,
testthat (>= 3.0.0),
spelling,
lintr,
lintr (>= 3.0.0),
covr
Remotes:
github::DrylandEcology/rSW2utils,
Expand All @@ -37,7 +38,6 @@ License: GPL-3
URL: https://github.com/DrylandEcology/rSW2exter
BugReports: https://github.com/DrylandEcology/rSW2exter/issues
Encoding: UTF-8
LazyData: true
Config/testthat/edition: 3
Language: en-US
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# rSW2exter v0.2.0
* `fetch_mukeys_spatially_NRCS_SDA()` now handles versions of "soilDB"
from `2.5.7` to at least `2.6.14`.
* `extract_soils_NRCS_SDA()` queries include now `localphase`;
this should improve the ability to identify a component of a soil map unit
across NRCS data releases by a combination of
`compname`, `comppct_r`, `localphase`.
* `extract_soils_NRCS_SDA()` gains argument `only_soilcomp` which excludes
non-soil components, i.e., those that are not "Miscellaneous areas" and
are not "NOTCOM" (not completed).
* Linting updated to `lintr` >= 3 and
lint workflow switched from package tests to Github Action (#5).

# rSW2exter v0.1.0
Initial release
30 changes: 17 additions & 13 deletions R/extract_soils_Miller1998_CONUSSoils.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ create_reference_for_Miller1998_CONUSSoil <- function() {
"Miller, D. A., and R. A. White. 1998. A conterminous United States ",
"multilayer soil characteristics dataset for regional climate and ",
"hydrology modeling. Earth Interactions 2:1-26. ",
"https://doi.org/10.1175%2F1087-3562%281998%29002%3C0001%3AACUSMS%3E2.3.CO%3B2 ", # nolint
"https://doi.org/10.1175%2F1087-3562%281998%29002%3C0001%3AACUSMS%3E2.3.CO%3B2 ", # nolint: line_length_linter
"Data accessed [",
format(as.POSIXlt(Sys.Date()), "%Y-%b-%e"),
"]"
Expand Down Expand Up @@ -106,7 +106,7 @@ prepare_script_for_Miller1998_CONUSSoil <- function(
#'
#' @export
create_conditioned_Miller1998_CONUSSoil <- function(
path,
path = ".",
vars = c("rockdepm", "rockvol", "bd", "sand", "clay", "silt"),
lower_limits_by_vars = c(
rockdepm = 0, rockvol = 0, bd = 30, sand = 0, clay = 0, silt = 0
Expand Down Expand Up @@ -215,15 +215,16 @@ check_Miller1998_CONUSSoil <- function(
)
) {

sapply(
vapply(
vars,
function(var) {
file.exists(filepath_Miller1998_CONUSSoil(
path = path,
var = var,
lower_limit = lower_limits_by_vars[var]
))
}
},
FUN.VALUE = NA
)
}

Expand Down Expand Up @@ -253,8 +254,8 @@ fetch_soils_from_Miller1998_CONUSSoil <- function(
# Align with data crs
ftmp <- filepath_Miller1998_CONUSSoil(
path = path,
var = vars[1],
lower_limit = lower_limits_by_vars[vars[1]]
var = vars[[1L]],
lower_limit = lower_limits_by_vars[vars[[1L]]]
)

tmp_crs <- sf::st_crs(raster::brick(ftmp))
Expand Down Expand Up @@ -292,7 +293,7 @@ fetch_soils_from_Miller1998_CONUSSoil <- function(
method = "simple"
)

# nolint start
# nolint start: commented_code_linter
# tmp <- do.call(
# "extract_rSFSW2",
# args = list(
Expand All @@ -312,7 +313,9 @@ fetch_soils_from_Miller1998_CONUSSoil <- function(
}

} else {
stop("Miller1998/CONUSSoil data ", shQuote(basename(ftmp)), " not found.")
stop(
"Miller1998 (CONUSSoil) data ", shQuote(basename(ftmp)), " not found."
)
}
}

Expand Down Expand Up @@ -377,7 +380,7 @@ fetch_soils_from_Miller1998_CONUSSoil <- function(
extract_soils_Miller1998_CONUSSoil <- function(
x,
crs = 4326,
path,
path = ".",
vars = c("bd", "rockvol", "sand", "clay", "silt"),
lower_limits_by_vars = c(bd = 30, rockvol = 0, sand = 0, clay = 0, silt = 0),
replace_missing_fragvol_with_zero = c("none", "all", "at_surface"),
Expand Down Expand Up @@ -410,7 +413,7 @@ extract_soils_Miller1998_CONUSSoil <- function(
verbose = verbose
)

N_layers <- dim(res)[3]
N_layers <- dim(res)[[3L]]


# Calculate restriction depth by >99% rock volume
Expand Down Expand Up @@ -595,9 +598,10 @@ extract_soils_Miller1998_CONUSSoil <- function(
formula = id ~ Horizon_No + variable
)

colnames(locs_table_texture) <- sapply(
X = strsplit(colnames(locs_table_texture), split = "_"),
FUN = function(x) paste0(x[2], "_L", x[1])
colnames(locs_table_texture) <- vapply(
X = strsplit(colnames(locs_table_texture), split = "_", fixed = TRUE),
FUN = function(x) paste0(x[[2L]], "_L", x[[1L]]),
FUN.VALUE = NA_character_
)


Expand Down
Loading

0 comments on commit 254f6e3

Please sign in to comment.