Skip to content

Commit

Permalink
fix issue #658 (continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
adokter committed Nov 27, 2024
1 parent 9bf2c02 commit e917fd3
Showing 1 changed file with 9 additions and 6 deletions.
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 e917fd3

Please sign in to comment.