diff --git a/R/readLPJmLInputs.R b/R/readLPJmLInputs.R index 7893b5a..157e5b6 100644 --- a/R/readLPJmLInputs.R +++ b/R/readLPJmLInputs.R @@ -18,45 +18,45 @@ readLPJmLInputs <- function(subtype = "lakeshare") { - files <- c(lakeshare = "glwd_lakes_and_rivers.bin") - file <- toolSubtypeSelect(subtype, files) - - # Data settings - if (subtype %in% c("lakeshare")) { - - unitTrans <- 0.01 - ncells <- 67420 - wyears <- 1 - syear <- 1 - avgRange <- NULL - filetype <- "bin" - bands <- 1 - datatype <- integer() - bytes <- 1 - monthly <- FALSE - } - - # Read in the data - x <- readLPJ(file_name = file, - wyears = wyears, - syear = syear, - averaging_range = avgRange, - ncells = ncells, - file_type = filetype, - bands = bands, - datatype = datatype, - bytes = bytes, - monthly = monthly) - - # Unit transformation - x <- x * unitTrans - - # Transform to magpie object and add dimension details - class(x) <- "array" - x <- collapseNames(as.magpie(x, spatial = 1)) - x <- addLocation(x) - x <- collapseDim(x, dim = "N") - x <- clean_magpie(x) - - return(x) + files <- c(lakeshare = "glwd_lakes_and_rivers.bin") + file <- toolSubtypeSelect(subtype, files) + + # Data settings + if (subtype %in% c("lakeshare")) { + + unitTrans <- 0.01 + ncells <- 67420 + wyears <- 1 + syear <- 1 + avgRange <- NULL + filetype <- "bin" + bands <- 1 + datatype <- integer() + bytes <- 1 + monthly <- FALSE + } + + # Read in the data + x <- readLPJ(file_name = file, + wyears = wyears, + syear = syear, + averaging_range = avgRange, + ncells = ncells, + file_type = filetype, + bands = bands, + datatype = datatype, + bytes = bytes, + monthly = monthly) + + # Unit transformation + x <- x * unitTrans + + # Transform to magpie object and add dimension details + class(x) <- "array" + x <- collapseNames(as.magpie(x, spatial = 1)) + x <- addLocation(x) + x <- collapseDim(x, dim = "N") + x <- clean_magpie(x) + + return(x) }