Skip to content

Commit

Permalink
* removing exoGAINS messages repetition from log.txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
Renato-Rodrigues committed Feb 10, 2021
1 parent c2a9dde commit 9d2d2c6
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions scripts/input/exoGAINSAirpollutants.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
# | AGPL-3.0, you are granted additional permissions described in the
# | REMIND License Exception, version 1.0 (see LICENSE file).
# | Contact: remind@pik-potsdam.de

# Only output messages to the log if it is the first run of exoGAINS to avoid repetion in the log.txt file
if(!any(grepl("ExoGAINS - log for first iteration...", readLines("log.txt")))){
firstIteration = TRUE
cat("ExoGAINS - log for first iteration...")
} else {
firstIteration = FALSE
}

# Downscaling of REMIND emissions to GAINS sectors using ECLIPSE emission and activity data
#rm(list=ls())

Expand Down Expand Up @@ -69,10 +78,12 @@ RA <- RA["GLO",,invert=TRUE]
################### select GAINS data ###################
##############################################################

cat("List of sectors that are not in the GAINS2REMIND mapping because there is no emission and/or activity data.\nThese sectors will be omitted in the calculations!\n")

missing_sectors <- setdiff(getNames(ef_gains,dim=1),map_GAINS2REMIND$GAINS)
cat(missing_sectors,sep="\n")
# logging missing sectors
if(firstIteration){
cat("List of sectors that are not in the GAINS2REMIND mapping because there is no emission and/or activity data.\nThese sectors will be omitted in the calculations!\n")
missing_sectors <- setdiff(getNames(ef_gains,dim=1),map_GAINS2REMIND$GAINS)
cat(missing_sectors,sep="\n")
}

# select GAINS data according to order in mapping and bring regions into same (alphabetically sorted) order as RA
ef_gains <- ef_gains[getRegions(RA),,map_GAINS2REMIND$GAINS]
Expand Down Expand Up @@ -205,3 +216,8 @@ writeGDX(out,file="pm_emiAPexsolve.gdx",period_with_y = FALSE)
# CEDS16 <- add_columns(CEDS16,addnm = getNames(avi_E,dim=1)) # filled with NA
# CEDS16[,,getNames(avi_E,dim=1)] <- 0 # replace NA with zero
# CEDS16["GLO",,getNames(avi_E[,,ssp_scenario])] <- avi_E[,,ssp_scenario] # data only contains BC and NOx emissions from aircraft

if(firstIteration){
cat("ExoGAINS - end of first iteration.")
}

0 comments on commit 9d2d2c6

Please sign in to comment.