Skip to content

Commit

Permalink
check if regional AR exceeds global AR limit
Browse files Browse the repository at this point in the history
  • Loading branch information
flohump committed Oct 21, 2024
1 parent 9d70e39 commit 1baf266
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/output/extra/highres.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,22 @@ highres <- function(cfg = cfg, res = "c1000", tc = NULL) {
a <- readGDX(gdx,"f60_bioenergy_dem_emulator", react = "silent")
if(!is.null(a)) write.magpie(a,"modules/60_bioenergy/input/glo.2ndgen_bioenergy_demand.csv")

#get regional afforestation patterns from low resolution run with c200
#get regional afforestation/reforestation (AR) patterns from low resolution run with c200
aff <- dimSums(landForestry(gdx)[,,c("aff","ndc")],dim=3)
#Take away initial NDC area for consistency with global afforestation limit
#Take away initial NDC area for consistency with global AR limit
aff <- aff-setYears(aff[,1,],NULL)
#calculate maximum regional afforestation over time
#calculate maximum regional AR over time
aff_max <- setYears(aff[,1,],NULL)
for (r in getRegions(aff)) {
aff_max[r,,] <- max(aff[r,,])
}
aff_max[aff_max < 0] <- 0
write.magpie(aff_max,"modules/32_forestry/input/f32_max_aff_area.cs4")
cfg$gms$s32_max_aff_area_glo <- 0
#check
#check if regional AR exceeds global AR limit
if(cfg$gms$s32_max_aff_area < Inf) {
indicator <- abs(sum(aff_max)-cfg$gms$s32_max_aff_area)
if(indicator > 1e-06) warning(paste("Global and regional afforestation limit differ by",indicator,"Mha"))
indicator <- sum(aff_max)-cfg$gms$s32_max_aff_area
if(indicator > 1e-06) warning(paste("Regional AR exceeds global AR limit by",indicator,"Mha"))
}

Sys.sleep(2)
Expand Down

0 comments on commit 1baf266

Please sign in to comment.