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

review dontrun blocks in examples #598

Merged
merged 4 commits into from
Jun 7, 2023
Merged
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: bioRad
Title: Biological Analysis and Visualization of Weather Radar Data
Version: 0.7.0.9588
Version: 0.7.0.95977
peterdesmet marked this conversation as resolved.
Show resolved Hide resolved
Description: Extract, visualize and summarize aerial movements of birds and
insects from weather radar data. See <doi:10.1111/ecog.04028>
for a software paper describing package and methodologies.
Expand Down
6 changes: 3 additions & 3 deletions R/bind_into_vpts.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ bind_into_vpts.vpts <- function(..., attributes_from = 1) {
#' @keywords internal
#'
#' @examples
#' \dontrun{
#' vps <- read_vpfiles(c("my/path/profile1.h5", "my/path/profile2.h5", ...))
#' vpfile1 <- system.file("extdata", "profile.h5", package = "bioRad")
#' vpfile2 <- vpfile1
#' vps <- read_vpfiles(c(vpfile1,vpfile2))
#' ts <- bind_into_vpts(vps)
#' }
vplist_to_vpts <- function(x, radar = NA) {
stopifnot(inherits(x, "list"))
# extract radar identifiers
Expand Down
2 changes: 0 additions & 2 deletions R/calculate_vp.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@
#' (11), pp. 1908-22. \doi{10.1111/2041-210X.13280}
#'
#' @examples
#' \dontrun{
#' # Locate and read the polar volume example file
#' pvolfile <- system.file("extdata", "volume.h5", package = "bioRad")
#'
Expand All @@ -185,7 +184,6 @@
#'
#' # Clean up
#' file.remove("~/volume.h5")
#' }
calculate_vp <- function(file, vpfile = "", pvolfile_out = "",
autoconf = FALSE, verbose = FALSE, warnings = TRUE,
mount, sd_vvp_threshold,
Expand Down
3 changes: 1 addition & 2 deletions R/composite_ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#' This function is a prototype and under active development
#'
#' @examples
#' \dontrun{
#' # Locate and read the polar volume example file
#' pvolfile <- system.file("extdata", "volume.h5", package = "bioRad")
#' pvol <- read_pvolfile(pvolfile)
Expand All @@ -73,7 +72,7 @@
#' # Overlay the ppis, calculating the maximum value observed
#' # across the available scans at each geographic location
#' composite <- composite_ppi(ppis, method = "max")
#'
#' \dontrun{
#' # Download basemap
#' bm <- download_basemap(composite)
#'
Expand Down
44 changes: 19 additions & 25 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
#' # Get summary info
#' example_scan
#'
#' # example_scan was created with
#' \dontrun{
#' pvolfile <- system.file("extdata", "volume.h5", package = "bioRad")
#' pvol <- read_pvolfile(pvolfile)
#' example_scan <- pvol$scans[[1]]
#' save(example_scan, file = "data/example_scan.rda")
#' }
#' ## example_scan was created with:
#' # pvolfile <- system.file("extdata", "volume.h5", package = "bioRad")
#' # pvol <- read_pvolfile(pvolfile)
#' # example_scan <- pvol$scans[[1]]
#' # save(example_scan, file = "data/example_scan.rda")
"example_scan"

#' Vertical profile (`vp`) example
Expand All @@ -39,12 +37,10 @@
#' # Get summary info
#' example_vp
#'
#' # example_vp was created with
#' \dontrun{
#' vpfile <- system.file("extdata", "profile.h5", package = "bioRad")
#' example_vp <- read_vpfiles(vpfile)
#' save(example_vp, file = "data/example_vp.rda")
#' }
#' ## example_vp was created with:
#' # vpfile <- system.file("extdata", "profile.h5", package = "bioRad")
#' # example_vp <- read_vpfiles(vpfile)
#' # save(example_vp, file = "data/example_vp.rda")
"example_vp"

#' Time series of vertical profiles (`vpts`) example
Expand All @@ -63,16 +59,14 @@
#' # Get summary info
#' example_vpts
#'
#' # example_vpts was created with
#' \dontrun{
#' vptsfile <- system.file("extdata", "vpts.txt.zip", package = "bioRad")
#' utils::unzip(vptsfile, exdir = (dirname(vptsfile)), junkpaths = TRUE)
#' vptsfile <- substr(vptsfile, 1, nchar(vptsfile) - 4)
#' example_vpts <- read_vpts(vptsfile, radar = "KBGM", wavelength = "S")
#' rcs(example_vpts) <- 11
#' sd_vvp_threshold(example_vpts) <- 2
#' example_vpts$attributes$where$lat <- 42.2
#' example_vpts$attributes$where$lon <- -75.98
#' save(example_vpts, file = "data/example_vpts.rda", compress = "xz")
#' }
#' ## example_vpts was created with
#' # vptsfile <- system.file("extdata", "vpts.txt.zip", package = "bioRad")
#' # utils::unzip(vptsfile, exdir = (dirname(vptsfile)), junkpaths = TRUE)
#' # vptsfile <- substr(vptsfile, 1, nchar(vptsfile) - 4)
#' # example_vpts <- read_vpts(vptsfile, radar = "KBGM", wavelength = "S")
#' # rcs(example_vpts) <- 11
#' # sd_vvp_threshold(example_vpts) <- 2
#' # example_vpts$attributes$where$lat <- 42.2
#' # example_vpts$attributes$where$lon <- -75.98
#' # save(example_vpts, file = "data/example_vpts.rda", compress = "xz")
"example_vpts"
8 changes: 6 additions & 2 deletions R/download_pvolfiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
#'
#' @examples
#' \dontrun{
#' dir.create("~/bioRad_tmp_files")
#' create temporary directory
#' temp_dir <- paste0(tempdir(),"/bioRad_tmp_files")
#' dir.create(temp_dir)
#' download_pvolfiles(
#' date_min = as.POSIXct("2016-10-02 20:00", tz = "UTC"),
#' date_max = as.POSIXct("2016-10-02 20:05", tz = "UTC"),
#' radar = "KBBX",
#' directory = "~/bioRad_tmp_files",
#' directory = temp_dir,
#' overwrite = TRUE
#' )
#' # Clean up
#' unlink(temp_dir, recursive = T)
#' }
download_pvolfiles <- function(date_min, date_max, radar,
directory = ".", overwrite = FALSE,
Expand Down
7 changes: 4 additions & 3 deletions R/download_vpfiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@
#' # Will successfully download 2016-10 files, but show 404 error for
#' # 2016-11 files, since these are not available.
#' \dontrun{
#' dir.create("~/bioRad_tmp_files")
#' temp_dir <- paste0(tempdir(),"/bioRad_tmp_files")
#' dir.create(temp_dir)
#' download_vpfiles(
#' date_min = "2016-10-01",
#' date_max = "2016-11-30",
#' radars = c("bejab", "bewid"),
#' directory = "~/bioRad_tmp_files",
#' directory = temp_dir,
#' overwrite = TRUE
#' )
#' # Clean up
#' unlink("~/bioRad_tmp_files", recursive = T)
#' unlink(temp_dir, recursive = T)
#' }
download_vpfiles <- function(date_min, date_max, radars, directory = ".",
overwrite = FALSE) {
Expand Down
4 changes: 2 additions & 2 deletions R/integrate_to_ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,18 @@
#' # 0-2000 cm^2/km^2 color scale
#' plot(ppi, zlim = c(0, 2000))
#'
#' \dontrun{
#' # Calculate the range-corrected ppi on finer 2000m x 2000m pixel raster
#' ppi <- integrate_to_ppi(pvol, example_vp, res = 2000)
#'
#' # Plot the vertically integrated density (VID) using a
#' # 0-200 birds/km^2 color scale
#' plot(ppi, param = "VID", zlim = c(0, 200))
#'
#' \dontrun{
#' # Download a basemap and map the ppi
#' bm <- download_basemap(ppi)
#' map(ppi, bm)
#' }
#'
#' # The ppi can also be projected on a user-defined raster, as follows:
#'
Expand All @@ -143,7 +144,6 @@
#' xlim = c(-50000, 50000), ylim = c(-50000, 50000)
#' )
#' plot(ppi, param = "VID", zlim = c(0, 200))
#' }
#' @references
#' * Kranstauber B, Bouten W, Leijnse H, Wijers B, Verlinden L, Shamoun-Baranes
#' J, Dokter AM (2020) High-Resolution Spatial Distribution of Bird
Expand Down
3 changes: 1 addition & 2 deletions R/plot.scan.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@
#' @examples
#' # Plot reflectivity
#' plot(example_scan, param = "DBZH")
#' \dontrun{
#'
#' # Change the range of reflectivities to plot, from -10 to 10 dBZ
#' plot(example_scan, param = "DBZH", zlim = c(-10, 10))
#'
#' # Change the scale name, change the color palette to Viridis colors
#' plot(example_scan, param = "DBZH", zlim = c(-10, 10)) +
#' viridis::scale_fill_viridis(name = "dBZ")
#' }
plot.scan <- function(x, param, xlim = c(0, 100000),
ylim = c(0, 360), zlim = c(-20, 20), na.value = "transparent", ...) {
stopifnot(inherits(x, "scan"))
Expand Down
5 changes: 1 addition & 4 deletions R/read_vpfiles.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,8 @@ read_vp <- function(file) {
#' # load the file:
#' read_vpfiles(vpfile)
#'
#' # load multiple files at once:
#' \dontrun{
#' # to load multiple files at once:
#' # read_vpfiles(c("my/path/profile1.h5", "my/path/profile2.h5", ...))
#' }
#'
read_vpfiles <- function(files) {
if (length(files) == 1) {
return(read_vp(files))
Expand Down
2 changes: 2 additions & 0 deletions R/scan_convert.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ scan_to_spatial <- function(scan, lat, lon, k = 4 / 3, re = 6378, rp = 6357) {
#' the same raster pixel, the last added pixel is given (see [rasterize][raster::rasterize] for details).
#' @export
#' @examples
#' \dontrun{
#' # default projects full extent on 100x100 pixel raster:
#' scan_to_raster(example_scan)
#'
Expand All @@ -86,6 +87,7 @@ scan_to_spatial <- function(scan, lat, lon, k = 4 / 3, re = 6378, rp = 6357) {
#' # using a template raster
#' template_raster <- raster::raster(raster::extent(12, 13, 56, 58), crs = sp::CRS("+proj=longlat"))
#' scan_to_raster(example_scan, raster = template_raster)
#' }
scan_to_raster <- function(scan, nx = 100, ny = 100, xlim, ylim, res = NA, param, raster = NA, lat, lon, crs = NA, k = 4 / 3, re = 6378, rp = 6357) {
if (!is.scan(scan)) stop("'scan' should be an object of class scan")
if (get_elevation_angles(scan) == 90) stop("georeferencing of 90 degree birdbath scan not supported")
Expand Down
5 changes: 3 additions & 2 deletions R/write_pvolfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
#'
#' # write the file:
#' pvolfile_out <- paste0(tempdir(),"pvolfile_out.h5")
#' \dontrun{
#' write_pvolfile(example_pvol, pvolfile_out)
#' }
#'
#' # clean up
#' file.remove(pvolfile_out)
write_pvolfile <- function(pvol, file, overwrite = FALSE, infer_dtype = FALSE) {
assertthat::assert_that(is.pvol(pvol),
msg = "`pvol` must be an object of class `pvol`")
Expand Down
2 changes: 0 additions & 2 deletions man/calculate_vp.Rd

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

3 changes: 1 addition & 2 deletions man/composite_ppi.Rd

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

8 changes: 6 additions & 2 deletions man/download_pvolfiles.Rd

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

7 changes: 4 additions & 3 deletions man/download_vpfiles.Rd

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

12 changes: 5 additions & 7 deletions man/example_scan.Rd

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

10 changes: 4 additions & 6 deletions man/example_vp.Rd

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

22 changes: 10 additions & 12 deletions man/example_vpts.Rd

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

Loading