Skip to content

Avoid Inf values when defining var_limits for ColorBar()

Hi @nperez

This is the fix for PlotEquiMap() and PlotLayout() when data has infinite values that cause errors in ColorBar() because var_limits is not well-defined. It may solve the problem mentioned here https://earth.bsc.es/gitlab/es/sunset/-/issues/81#note_241390. Here is an example.

# Under s2dv/R directory
invisible(lapply(list("PlotEquiMap.R", "PlotLayout.R", "Reorder.R", "Utils.R", "clim.palette.R", "ColorBar.R"), source))

data <- array(rnorm(20), dim = c(lat = 4, lon = 5))
data[1] <- NA
data[2] <- Inf
data[3] <- -Inf
lon <- seq(10, 50, 10)
lat <- seq(10, 40, 10)
PlotEquiMap(data, lon = lon, lat = lat)

data2 <- aperm(array(data, dim = c(dim(data), time = 2)), c(3, 1, 2))
PlotLayout(fun = PlotEquiMap, plot_dims = c('lat', 'lon'), var = data2, lon = lon, lat = lat)

Cheers,
An-Chi

Merge request reports

Loading