From 31e6d27110c3b63b17edc25b0e87d25e708b5d70 Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Fri, 13 Sep 2024 10:25:38 -0400 Subject: [PATCH] small documentation edits, fix test list_vpts_aloft --- DESCRIPTION | 2 +- R/calculate_param.R | 10 ++++++---- man/beam_distance.Rd | 2 +- man/beam_height.Rd | 2 +- man/beam_range.Rd | 2 +- man/beam_width.Rd | 2 +- man/calculate_param.Rd | 10 ++++++---- man/gaussian_beam_profile.Rd | 2 +- tests/testthat/test-list_vpts_aloft.R | 6 +++--- 9 files changed, 21 insertions(+), 17 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c00e3372c..af7f0a9cd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -66,6 +66,6 @@ Suggests: LazyData: true Encoding: UTF-8 VignetteBuilder: knitr -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 diff --git a/R/calculate_param.R b/R/calculate_param.R index e960824bd..efad5e905 100644 --- a/R/calculate_param.R +++ b/R/calculate_param.R @@ -21,10 +21,10 @@ #' vectorized. For example the `base` `ifelse` function is not vectorized, #' in these cases alternatives can be used (e.g. `dplyr::if_else`). #' -#' Next some times functions do not operate on a `matrix` or `param` object. -#' One example is the `dplyr::if_else` function, this can be resolved by -#' calling the `c` function on a parameter to convert it to a vector -#' (e.g. `c(DBZH)`). +#' Also note that some functions do not operate on a `matrix` or `param` object. +#' One example is the `dplyr::if_else` function. A workaround is +#' calling the `c()` function on a parameter to convert it to a vector +#' (e.g. `c(DBZH)`, see examples). #' #' @seealso #' * [get_param()] @@ -52,6 +52,8 @@ #' calculate_param(example_scan, DR = 10 * log10((ZDR + 1 - 2 * ZDR^0.5 * RHOHV) / #' (ZDR + 1 + 2 * ZDR^0.5 * RHOHV))) #' +#' # set all reflectivity values to NA when correlation coefficient > 0.95 +#' (indicating precipitation) #' if (require(dplyr, quietly = TRUE)) { #' calculate_param(pvol, #' DBZH=if_else(c(RHOHV)>.95, NA, c(DBZH)) ) diff --git a/man/beam_distance.Rd b/man/beam_distance.Rd index 2d463693e..11ca391a3 100644 --- a/man/beam_distance.Rd +++ b/man/beam_distance.Rd @@ -41,8 +41,8 @@ beam_distance(100000, 5) Other beam_functions: \code{\link{beam_height}()}, -\code{\link{beam_profile_overlap}()}, \code{\link{beam_profile}()}, +\code{\link{beam_profile_overlap}()}, \code{\link{beam_range}()}, \code{\link{beam_width}()}, \code{\link{gaussian_beam_profile}()} diff --git a/man/beam_height.Rd b/man/beam_height.Rd index 787278a33..4a559557e 100644 --- a/man/beam_height.Rd +++ b/man/beam_height.Rd @@ -58,8 +58,8 @@ plot(range, beam_height(range, 0.5), ylab = "beam height [m]", xlab = "range [m] Other beam_functions: \code{\link{beam_distance}()}, -\code{\link{beam_profile_overlap}()}, \code{\link{beam_profile}()}, +\code{\link{beam_profile_overlap}()}, \code{\link{beam_range}()}, \code{\link{beam_width}()}, \code{\link{gaussian_beam_profile}()} diff --git a/man/beam_range.Rd b/man/beam_range.Rd index 1e45b78c6..29b23a23d 100644 --- a/man/beam_range.Rd +++ b/man/beam_range.Rd @@ -38,8 +38,8 @@ beam_range(100000, 5) Other beam_functions: \code{\link{beam_distance}()}, \code{\link{beam_height}()}, -\code{\link{beam_profile_overlap}()}, \code{\link{beam_profile}()}, +\code{\link{beam_profile_overlap}()}, \code{\link{beam_width}()}, \code{\link{gaussian_beam_profile}()} } diff --git a/man/beam_width.Rd b/man/beam_width.Rd index f21165cfc..fdbe53469 100644 --- a/man/beam_width.Rd +++ b/man/beam_width.Rd @@ -32,8 +32,8 @@ plot(range, beam_width(range), ylab = "beam width [m]", xlab = "range [m]") Other beam_functions: \code{\link{beam_distance}()}, \code{\link{beam_height}()}, -\code{\link{beam_profile_overlap}()}, \code{\link{beam_profile}()}, +\code{\link{beam_profile_overlap}()}, \code{\link{beam_range}()}, \code{\link{gaussian_beam_profile}()} } diff --git a/man/calculate_param.Rd b/man/calculate_param.Rd index 79d964f6f..5ec7b17a2 100644 --- a/man/calculate_param.Rd +++ b/man/calculate_param.Rd @@ -39,10 +39,10 @@ For the expression to work it is important that the operation can be vectorized. For example the \code{base} \code{ifelse} function is not vectorized, in these cases alternatives can be used (e.g. \code{dplyr::if_else}). -Next some times functions do not operate on a \code{matrix} or \code{param} object. -One example is the \code{dplyr::if_else} function, this can be resolved by -calling the \code{c} function on a parameter to convert it to a vector -(e.g. \code{c(DBZH)}). +Also note that some functions do not operate on a \code{matrix} or \code{param} object. +One example is the \code{dplyr::if_else} function. A workaround is +calling the \code{c()} function on a parameter to convert it to a vector +(e.g. \code{c(DBZH)}, see examples). } \section{Methods (by class)}{ \itemize{ @@ -73,6 +73,8 @@ pvol <- calculate_param(pvol, DR = 10 * log10((ZDR + 1 - 2 * ZDR^0.5 * RHOHV) / calculate_param(example_scan, DR = 10 * log10((ZDR + 1 - 2 * ZDR^0.5 * RHOHV) / (ZDR + 1 + 2 * ZDR^0.5 * RHOHV))) +# set all reflectivity values to NA when correlation coefficient > 0.95 +(indicating precipitation) if (require(dplyr, quietly = TRUE)) { calculate_param(pvol, DBZH=if_else(c(RHOHV)>.95, NA, c(DBZH)) ) diff --git a/man/gaussian_beam_profile.Rd b/man/gaussian_beam_profile.Rd index edb080804..3dd28fe62 100644 --- a/man/gaussian_beam_profile.Rd +++ b/man/gaussian_beam_profile.Rd @@ -53,8 +53,8 @@ Beam profile is calculated using \link{beam_height} and \link{beam_width}. \code Other beam_functions: \code{\link{beam_distance}()}, \code{\link{beam_height}()}, -\code{\link{beam_profile_overlap}()}, \code{\link{beam_profile}()}, +\code{\link{beam_profile_overlap}()}, \code{\link{beam_range}()}, \code{\link{beam_width}()} } diff --git a/tests/testthat/test-list_vpts_aloft.R b/tests/testthat/test-list_vpts_aloft.R index 6ae77701c..9467e2efd 100644 --- a/tests/testthat/test-list_vpts_aloft.R +++ b/tests/testthat/test-list_vpts_aloft.R @@ -116,11 +116,11 @@ test_that("list_vpts_aloft() warns if data was found for subset of radars or if ) expect_warning( list_vpts_aloft( - date_min = "1900-01-01", - date_max = "2023-05-22", + date_min = "2020-01-01", + date_max = "2020-06-01", radars = c("nobml") ), - "Radar data found between 2023-02 and 2023-05 but not every date has radar data") + "Radar data found between 2020-02 and 2020-06 but not every date has radar data") }) test_that("list_vpts_aloft() warns and returns emtpy vector on no data found",{