diff --git a/NEWS.md b/NEWS.md index 95f0f3df..98d27909 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ + +# bioRad 0.7.3.9000 + +** Bugfixes + +* Updated the default refractive index value used in conversion of linear reflectivity (eta) to logarithmic reflectivity (dBZ) (#642). The effect is a 7% increase in animal densities in output of functions `integrate_to_ppi()` and `read_cajun()` only. + # bioRad 0.7.3 ## New features diff --git a/R/dbz_eta.R b/R/dbz_eta.R index b6bf1110..df444d60 100644 --- a/R/dbz_eta.R +++ b/R/dbz_eta.R @@ -24,7 +24,7 @@ #' # radar cross section of 11 cm^2 per individual #' dbz_to_eta(7, 5) / 11 # C-band #' dbz_to_eta(7, 10) / 11 # S-band -dbz_to_eta <- function(dbz, wavelength, K = 0.93) { +dbz_to_eta <- function(dbz, wavelength, K = sqrt(0.93)) { assertthat::assert_that(is.numeric(dbz)) assertthat::assert_that(is.numeric(wavelength) & all(wavelength > 0), msg = "`wavelength` must be a strictly positive numeric.") assertthat::assert_that(is.numeric(K) & all(K > 0), msg = "`K` must be a strictly positive numeric.") @@ -53,7 +53,7 @@ dbz_to_eta <- function(dbz, wavelength, K = 0.93) { #' # cross section of 11 cm^2 per individual #' eta_to_dbz(1000 * 11, 5) # C-band #' eta_to_dbz(1000 * 11, 10) # S-band -eta_to_dbz <- function(eta, wavelength, K = 0.93) { +eta_to_dbz <- function(eta, wavelength, K = sqrt(0.93)) { assertthat::assert_that(is.numeric(eta) & all(eta>=0), msg = "`eta` must be a strictly positive numeric.") assertthat::assert_that(is.numeric(wavelength) & all(wavelength > 0), msg = "`wavelength` must be a strictly positive numeric.") assertthat::assert_that(is.numeric(K) & all(K > 0), msg = "`K` must be a strictly positive numeric.") diff --git a/man/dbz_to_eta.Rd b/man/dbz_to_eta.Rd index 2c6d982f..82c8e39d 100644 --- a/man/dbz_to_eta.Rd +++ b/man/dbz_to_eta.Rd @@ -4,7 +4,7 @@ \alias{dbz_to_eta} \title{Convert reflectivity factor (dBZ) to reflectivity (eta)} \usage{ -dbz_to_eta(dbz, wavelength, K = 0.93) +dbz_to_eta(dbz, wavelength, K = sqrt(0.93)) } \arguments{ \item{dbz}{Numeric. Reflectivity factor, in dBZ.} diff --git a/man/eta_to_dbz.Rd b/man/eta_to_dbz.Rd index 1b02cfc3..fecae70e 100644 --- a/man/eta_to_dbz.Rd +++ b/man/eta_to_dbz.Rd @@ -4,7 +4,7 @@ \alias{eta_to_dbz} \title{Convert reflectivity (eta) to reflectivity factor (dBZ)} \usage{ -eta_to_dbz(eta, wavelength, K = 0.93) +eta_to_dbz(eta, wavelength, K = sqrt(0.93)) } \arguments{ \item{eta}{Numeric. Reflectivity, in cm^2/km^3.} diff --git a/tests/testthat/test-dbz_eta.R b/tests/testthat/test-dbz_eta.R index 884f09b2..939f4840 100644 --- a/tests/testthat/test-dbz_eta.R +++ b/tests/testthat/test-dbz_eta.R @@ -6,7 +6,7 @@ test_that("dbz_to_eta() returns error on incorrect parameters", { }) test_that("dbz_to_eta() returns the correct eta", { - expect_equal(dbz_to_eta(7, 5), 2122.439, tolerance = 0.0001) + expect_equal(dbz_to_eta(7, 5), 2282.193, tolerance = 0.0001) }) }) @@ -19,7 +19,7 @@ test_that("eta_to_dbz() returns error on incorrect parameters", { }) test_that("eta_to_dbz() returns the correct dbz", { - expect_equal(eta_to_dbz(10000, 10), 25.77285, tolerance = 0.0001) + expect_equal(eta_to_dbz(10000, 10), 25.45768, tolerance = 0.0001) }) }) diff --git a/tests/testthat/test-read_cajun.R b/tests/testthat/test-read_cajun.R index c3baa990..e8089f48 100644 --- a/tests/testthat/test-read_cajun.R +++ b/tests/testthat/test-read_cajun.R @@ -64,11 +64,12 @@ test_that("read_cajun() returns expected data", { write.csv(x = cajun_csv, non_empty_file_path) expect_equal( ignore_attr = TRUE, + tolerance=0.0001, read_cajun(non_empty_file_path, wavelength = c("S"))$data, dplyr::tribble( ~height, ~u, ~v, ~w, ~ff, ~dd, ~sd_vvp, ~gap, ~dbz, ~eta, ~dens, ~DBZH, ~n, ~n_dbz, ~n_all, ~n_dbz_all, ~elev1, ~nvolumes_gr35_e1, ~elev2, ~nvolumes_gr35_e2, ~vcp, ~percent_rain, - 1L, 9.1082, 5.4677, NA, 36.8916, 29911L, 7.2845, FALSE, 3.7747820481656, 50L, 4.54545454545455, 0.00727495214460544, NA, -6404.5974442746, NA, 851.2421, 12.5202, 0.3646, 216L, 1.3329, 0L, 852.3826, - 2L, 14.4428, 10.1568, NA, 44.6877, 49823L, 10.2681, FALSE, 8.54599459536223, 150L, 13.6363636363636, 0.00727495214460544, NA, -241.9400975439, NA, 212.6159, 11.5492, 0.3646, 216L, 1.3329, 0L, 213.7921 + 1L, 9.1082, 5.4677, NA, 36.8916, 29911L, 7.2845, FALSE, 3.459612, 50L, 4.54545454545455, -0.3078956, NA, -6404.5974442746, NA, 851.2421, 12.5202, 0.3646, 216L, 1.3329, 0L, 852.3826, + 2L, 14.4428, 10.1568, NA, 44.6877, 49823L, 10.2681, FALSE, 8.230824, 150L, 13.6363636363636, -0.3078956, NA, -241.9400975439, NA, 212.6159, 11.5492, 0.3646, 216L, 1.3329, 0L, 213.7921 ) ) })