Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix warning in highres output script #735

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading