Skip to content

Commit

Permalink
handle empty numeric vectors without ifelse
Browse files Browse the repository at this point in the history
  • Loading branch information
iskandari committed Mar 28, 2024
1 parent 1dd4aa3 commit a25d6e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions R/plot.scan.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ plot.scan <- function(x, param, xlim = c(0, 100000),

rscale <- x$geo$rscale
ascale <- x$geo$ascale
rstart <- ifelse(is.null(x$geo$rstart), 0, x$geo$rstart)
astart <- ifelse(is.null(x$geo$astart), 0, x$geo$astart)
rstart <- max(c(0, x$geo$rstart), na.rm = TRUE)
astart <- max(c(0, x$geo$astart), na.rm = TRUE)

data <- raster::as.data.frame(raster::flip(raster::raster(t(data), ymn = astart, ymx = astart + 360, xmn = rstart, xmx = rstart + rscale * dimraster[1]), direction = "y"), xy = TRUE)
# change the name from "layer" to the parameter names
Expand Down
5 changes: 3 additions & 2 deletions R/project_as_ppi.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ sample_polar <- function(param, grid_size, range_max, project, ylim, xlim, k = 4
cartesian_to_polar(sp::coordinates(gridTopo), elev, k = k, lat = attributes(param)$geo$lat, re = re, rp = rp),
rangebin = attributes(param)$geo$rscale,
azimbin = attributes(param)$geo$ascale,
azimstart = ifelse(is.null(attributes(param)$geo$astart), 0, attributes(param)$geo$astart),
rangestart = ifelse(is.null(attributes(param)$geo$rstart), 0, attributes(param)$geo$rstart)
azimstart <- max(c(0, attributes(param)$geo$astart), na.rm = TRUE),
rangestart <- max(c(0, attributes(param)$geo$rstart), na.rm = TRUE)

)
# set indices outside the scan's matrix to NA
nrang <- dim(param)[1]
Expand Down

0 comments on commit a25d6e1

Please sign in to comment.