From e917fd36a038ca1d4733d3eb70f786edcd67466c Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Wed, 27 Nov 2024 15:03:57 -0500 Subject: [PATCH 1/2] fix issue #658 (continued) --- R/integrate_to_ppi.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/integrate_to_ppi.R b/R/integrate_to_ppi.R index 59649162..05276520 100644 --- a/R/integrate_to_ppi.R +++ b/R/integrate_to_ppi.R @@ -318,13 +318,10 @@ integrate_to_ppi <- function(pvol, vp, nx = 100, ny = 100, xlim, ylim, zlim = c( }) output <- rasters[[1]] } - eta_expected_sum <- rowSums( - do.call(cbind, - lapply(1:length(rasters), function(i) (rasters[[i]]$eta_expected))), - na.rm = TRUE) + eta_expected_sum <- + rowSums(do.call(cbind, lapply(1:length(rasters), function(i) (rasters[[i]]$eta_expected))), na.rm = TRUE) eta_sum <- - rowSums(do.call(cbind, lapply(1:length(rasters), function(i) - (rasters[[i]]$eta))), na.rm = TRUE) + rowSums(do.call(cbind, lapply(1:length(rasters), function(i) (rasters[[i]]$eta))), na.rm = TRUE) output@data$eta_sum_expected <- eta_expected_sum output@data$eta_sum <- eta_sum output@data$R <- eta_sum / eta_expected_sum @@ -511,6 +508,12 @@ add_expected_eta_to_scan <- function(scan, vp, quantity = "dens", attributes(eta_expected)$param <- "eta_expected" scan$params$eta_expected <- eta_expected + # set eta_expected values to zero whenever the reflectivity quantity is NA + # NA values indicate the pixel was never irradiated, so no reflectivity return expected + na_idx <- is.na(scan$params[[param]]) & !is.nan(scan$params[[param]]) + scan$params[["eta_expected"]][na_idx] <- 0 + + # return the scan with added scan parameters 'eta' and 'eta_expected' scan } From f8cbd27e5434ec423826bcd76fd12fe6d6476cca Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Fri, 10 Jan 2025 13:12:15 -0500 Subject: [PATCH 2/2] update news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index b722415c..f22594bd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,8 @@ * correct type of gap field in vpts objects for profiles stored in ODIM HDF5 format (.h5) (#635, #691) +* interpret NA values in field DBZH in integrate_to_ppi() as pixels that were not irradiated (#658) + # bioRad 0.8.1 ## bugfixes