Skip to content

Commit

Permalink
don't write intermediate ecoregionProducer outputs to disk
Browse files Browse the repository at this point in the history
  • Loading branch information
achubaty committed Nov 14, 2018
1 parent 5e18641 commit dbcb6e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 1 addition & 7 deletions Boreal_LBMRDataPrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,12 @@ estimateParameters <- function(sim) {

message("ecoregionProducer: ", Sys.time())
# Note: this ecoregionMap is NOT the Canadian EcoRegion -- it is for LBMR, which uses "ecoregion"
ecoregionMap <- Cache( postProcess, sim$ecoDistrict,
studyArea = sim$shpStudyArea)
ecoregionMap <- Cache(postProcess, sim$ecoDistrict, studyArea = sim$shpStudyArea, filename2 = NULL)
ecoregionFiles <- Cache(ecoregionProducer,
#studyAreaRaster = initialCommFiles$initialCommunityMap,
#ecoregionMapFull = sim$ecoDistrict,
ecoregionMap = ecoregionMap,
ecoregionName = "ECODISTRIC",
ecoregionActiveStatus = ecoregionstatus,
rasterToMatch = initialCommFiles$initialCommunityMap, #sim$rasterToMatch,
#studyArea = sim$studyArea,
#rstStudyArea = rstStudyRegionBinary,
#maskFn = fastMask,
userTags = "stable")

message("3: ", Sys.time())
Expand Down
8 changes: 5 additions & 3 deletions R/ecoregionProducers.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ ecoregionProducer <- function(ecoregionMap, ecoregionName,

ecoregionFactorValues <- na.omit(unique(ecoregionMap[]))

ecoregionTable <- data.table(mapcode = seq_along(ecoregionFactorValues[!is.na(ecoregionFactorValues)]),
ecoregion = as.numeric(ecoregionFactorValues[!is.na(ecoregionFactorValues)]))
ecoregionTable <- data.table(
mapcode = seq_along(ecoregionFactorValues[!is.na(ecoregionFactorValues)]),
ecoregion = as.numeric(ecoregionFactorValues[!is.na(ecoregionFactorValues)])
)
message("ecoregionProducer mapvalues: ", Sys.time())
ecoregionMap[] <- plyr::mapvalues(ecoregionMap[], from = ecoregionTable$ecoregion, to = ecoregionTable$mapcode)
ecoregionActiveStatus[, ecoregion := as.character(ecoregion)]
Expand All @@ -21,7 +23,7 @@ ecoregionProducer <- function(ecoregionMap, ecoregionName,
ecoregionTable <- dplyr::left_join(ecoregionTable,
ecoregionActiveStatus,
by = "ecoregion") %>%
data.table
data.table()
ecoregionTable[is.na(active), active := "no"]
ecoregionTable <- ecoregionTable[,.(active, mapcode, ecoregion)]
return(list(ecoregionMap = ecoregionMap,
Expand Down

0 comments on commit dbcb6e8

Please sign in to comment.