Skip to content

Commit

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

* Github Actions are triggered for `release/**` branches in addition to `main`.
* `r-lib` Github Actions updated to `v2` (#6; @dschlaep).
* `get_data_dims()` now returns consistently an integer vector.
* Linting updated to `lintr` >= 3 and
  lint workflow switched from package tests to Github Action (#5; @dschlaep).
* `isoline_from_raster()` is now based on the `stars` and `sf` packages
  (removing a dependency on `rgeos`; addressing #3; @dschlaep).
* `variogram_range()` is now based on the `stars` and `sf` packages
  (removing a dependency on `rgdal`; addressing #3; @dschlaep).
* `read_netCDF_as_array()` gains arguments `"time_name"` and `"vertical_name"`
  with previous hard-coded values as defaults ("time" and "vertical")
  (#14; @dschlaep)
* New `get_nc_type()` identifies a suitable netCDF data type from an R object.
* `read_netCDF()` gains argument `"verbose_read"` which, if set to `"FALSE"`,
  attempts to silence communication (messages, warnings, and print statements)
  generated from reading a `netCDF` (#9; @dschlaep).
  • Loading branch information
dschlaep authored May 18, 2023
2 parents f8c162b + d344ae3 commit aaa1889
Show file tree
Hide file tree
Showing 34 changed files with 1,047 additions and 804 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/check-standard.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: 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
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true

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
97 changes: 0 additions & 97 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
12 changes: 12 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
linters: lintr::linters_with_tags(
tags = NULL,
#--- Change arguments of linters:
line_length_linter = lintr::line_length_linter(length = 80L),
#--- Turn off linters:
cyclocomp_linter = NULL,
implicit_integer_linter = NULL,
object_name_linter = NULL,
todo_comment_linter = NULL,
yoda_test_linter = NULL)
error_on_lint: TRUE
encoding: "UTF-8"
11 changes: 5 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rSW2st
Title: Spatiotemporal Tools for SOILWAT2 and STEPWAT2 Simulation Experiments
Version: 0.1.0
Version: 0.2.0
Authors@R: c(
person(
"Daniel", "Schlaepfer",
Expand All @@ -17,7 +17,6 @@ Imports:
abind (>= 1.4.5),
sf (>= 0.9.8),
sp (>= 1.4.5),
rgdal (>= 1.5.23),
raster (>= 3.4.5),
stars (>= 0.4.3)
Suggests:
Expand All @@ -27,16 +26,16 @@ Suggests:
ggplot2,
ncdf4 (>= 1.17),
ncmeta (>= 0.3.0),
rgeos,
RNetCDF (>= 2.6.2),
testthat (>= 3.0.0),
terra (>= 1.4.22),
spelling,
lintr,
lintr (>= 3.0.0),
covr
License: GPL-3
URL: https://github.com/DrylandEcology/rSW2st
BugReports: https://github.com/DrylandEcology/rSW2st/issues
Encoding: UTF-8
LazyData: true
Language: en-US
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
Config/testthat/edition: 3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export(create_raster_from_variables)
export(crs_units)
export(epsg_for_utm)
export(get_data_dims)
export(get_nc_type)
export(get_xyspace)
export(is_netCDF_gridded)
export(isoline_from_raster)
Expand Down
22 changes: 22 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# rSW2st v0.2.0

* Github Actions are triggered for `release/**` branches in addition to `main`.
* `r-lib` Github Actions updated to `v2` (#6; @dschlaep).
* `get_data_dims()` now returns consistently an integer vector.
* Linting updated to `lintr` >= 3 and
lint workflow switched from package tests to Github Action (#5; @dschlaep).
* `isoline_from_raster()` is now based on the `stars` and `sf` packages
(removing a dependency on `rgeos`; addressing #3; @dschlaep).
* `variogram_range()` is now based on the `stars` and `sf` packages
(removing a dependency on `rgdal`; addressing #3; @dschlaep).
* `read_netCDF_as_array()` gains arguments `"time_name"` and `"vertical_name"`
with previous hard-coded values as defaults ("time" and "vertical")
(#14; @dschlaep)
* New `get_nc_type()` identifies a suitable netCDF data type from an R object.
* `read_netCDF()` gains argument `"verbose_read"` which, if set to `"FALSE"`,
attempts to silence communication (messages, warnings, and print statements)
generated from reading a `netCDF` (#9; @dschlaep).


# rSW2st v0.1.0
Initial release
4 changes: 2 additions & 2 deletions R/conversions.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ as_points <- function(
x <- matrix(x, nrow = 1, ncol = 2)
}

if (missing(crs)) {
if (missing(crs) || is.null(crs)) {
stop("`crs` is missing and `x` is not a spatial object.")
}

Expand All @@ -104,7 +104,7 @@ as_points <- function(
coords = unname(x),
proj4string = as(crs, "CRS")
),
sf = , # nolint
sf = ,
sfc = sf::st_cast(
x = sf::st_sfc(
sf::st_multipoint(
Expand Down
12 changes: 6 additions & 6 deletions R/crs.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ NULL
#'
#' @export
crs_units <- function(crs) {
sf::st_crs(crs)$units_gdal
sf::st_crs(crs)$units_gdal # nolint: extraction_operator_linter.
}


Expand All @@ -49,7 +49,7 @@ crs_units <- function(crs) {
#' }
#'
#' @references Convert Latitude/Longitude to UTM
# nolint start
# nolint start: line_length_linter.
#' \url{https://www.wavemetrics.com/code-snippet/convert-latitudelongitude-utm}
# nolint end
#' (attributed to Chuck Gantz).
Expand All @@ -72,16 +72,16 @@ utm_zone <- function(x, crs = 4326) {
mxy <- colMeans(xy)

# Make sure longitude is between -180.00 .. 179.9
long <- mxy[1] - floor((mxy[1] + 180) / 360) * 360
long <- mxy[[1L]] - floor((mxy[[1L]] + 180) / 360) * 360

utm_zone <- floor((long + 180) / 6) + 1

if (mxy[2] >= 56 && mxy[2] < 64 && long >= 3 && long < 12) {
if (mxy[[2L]] >= 56 && mxy[[2L]] < 64 && long >= 3 && long < 12) {
utm_zone <- 32
}

# Special zones for Svalbard
if (mxy[2] >= 72 && mxy[2] < 84) {
if (mxy[[2L]] >= 72 && mxy[[2L]] < 84) {
if (long >= 0 && long < 9) {
utm_zone <- 31
} else if (long >= 9 && long < 21) {
Expand All @@ -95,7 +95,7 @@ utm_zone <- function(x, crs = 4326) {

list(
utm_zone = as.integer(unname(utm_zone)),
utm_NS = if (mxy[2] > 0) "N" else "S"
utm_NS = if (mxy[[2L]] > 0) "N" else "S"
)
}

Expand Down
Loading

0 comments on commit aaa1889

Please # to comment.