Skip to content

Commit 65fbeb0

Browse files
authored
Merge pull request #656 from adokter/bugfix/empty_numeric
handle empty numeric vectors without ifelse
2 parents a6b3485 + a25d6e1 commit 65fbeb0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

R/plot.scan.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ plot.scan <- function(x, param, xlim = c(0, 100000),
7474

7575
rscale <- x$geo$rscale
7676
ascale <- x$geo$ascale
77-
rstart <- ifelse(is.null(x$geo$rstart), 0, x$geo$rstart)
78-
astart <- ifelse(is.null(x$geo$astart), 0, x$geo$astart)
77+
rstart <- max(c(0, x$geo$rstart), na.rm = TRUE)
78+
astart <- max(c(0, x$geo$astart), na.rm = TRUE)
7979

8080
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)
8181
# change the name from "layer" to the parameter names

R/project_as_ppi.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ sample_polar <- function(param, grid_size, range_max, project, ylim, xlim, k = 4
193193
cartesian_to_polar(sp::coordinates(gridTopo), elev, k = k, lat = attributes(param)$geo$lat, re = re, rp = rp),
194194
rangebin = attributes(param)$geo$rscale,
195195
azimbin = attributes(param)$geo$ascale,
196-
azimstart = ifelse(is.null(attributes(param)$geo$astart), 0, attributes(param)$geo$astart),
197-
rangestart = ifelse(is.null(attributes(param)$geo$rstart), 0, attributes(param)$geo$rstart)
196+
azimstart <- max(c(0, attributes(param)$geo$astart), na.rm = TRUE),
197+
rangestart <- max(c(0, attributes(param)$geo$rstart), na.rm = TRUE)
198+
198199
)
199200
# set indices outside the scan's matrix to NA
200201
nrang <- dim(param)[1]

0 commit comments

Comments
 (0)