Skip to content

Commit

Permalink
Merge pull request #685 from adokter/integrate_to_ppi_NA_fix
Browse files Browse the repository at this point in the history
fix issue #658 (continued)
  • Loading branch information
adokter authored Jan 10, 2025
2 parents a02a98a + f8cbd27 commit b39c870
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions R/integrate_to_ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit b39c870

Please sign in to comment.