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

rename ar6Climate -> MAGICC7_AR6, add cs2 section with all output #1615

Merged
merged 6 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **core** change of preference parameters and associated computation of interest rates/mark ups
- **scripts** add script to automatically check project summations from piamInterfaces
[[#1587](https://github.com/remindmodel/remind/pull/1587)]
- **scripts** add compareScenarios section for MAGICC7 AR6 output
[[#1615](https://github.com/remindmodel/remind/pull/1615)

### fixed
- fixed weights of energy carriers in `pm_IndstCO2Captured`
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Imports:
data.table,
devtools,
dplyr,
edgeTransport,
edgeTransport (>= 1.5.4),
flexdashboard,
GDPuc,
gdx,
Expand All @@ -43,15 +43,15 @@ Imports:
magclass,
magpie4,
magpiesets,
mip,
mip (>= 0.148.11),
modelstats,
mrremind,
mrvalidation,
ncdf4,
nleqslv,
optparse,
piamenv (>= 0.4.0),
piamInterfaces (>= 0.15.1),
piamInterfaces (>= 0.15.2),
plotly,
purrr,
quitte (>= 0.3128.4),
Expand Down
2 changes: 1 addition & 1 deletion output.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ if (! exists("output")) {
# Select output directories if not defined by readArgs
if (! exists("outputdir")) {
modulesNeedingMif <- c("compareScenarios2", "xlsx_IIASA", "policyCosts", "Ariadne_output",
"plot_compare_iterations", "varListHtml", "fixOnRef")
"plot_compare_iterations", "varListHtml", "fixOnRef", "MAGICC7_AR6")
needingMif <- any(modulesNeedingMif %in% output)
if (exists("remind_dir")) {
dir_folder <- c(file.path(remind_dir, "output"), remind_dir)
Expand Down
36 changes: 36 additions & 0 deletions scripts/cs2/MAGICC7_AR6.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
| (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK)
| authors, and contributors see CITATION.cff file. This file is part
| of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of
| AGPL-3.0, you are granted additional permissions described in the
| REMIND License Exception, version 1.0 (see LICENSE file).
| Contact: [email protected]
-->
# Climate

```{r MAGICC6}
showLinePlots(data, "Forcing")
showLinePlots(data, "Temperature|Global Mean")
```

# MAGICC7 AR6 Climate

```{r Climate}

allmagiccvar <- grep("^MAGICC7.*50\\.0th Percentile", unique(data$variable), value = TRUE)
mainmagiccvar <- c("Surface Temperature (GSAT)", "Atmospheric Concentrations|CO2",
"Effective Radiative Forcing|Basket|Anthropogenic")
mainmagiccvar <- paste0("MAGICC7 AR6|", mainmagiccvar, "|50.0th Percentile")
allmagiccvar <- unique(c(mainmagiccvar, allmagiccvar)) # main first

if (length(allmagiccvar) == 0) {
print("No MAGICC7 data found, run output.R -> single -> MAGICC7_AR6")
} else {
for (mv in allmagiccvar) {
showLinePlots(data, mv)
print(plotPercentiles(data, variables = gsub("|50.0th Percentile", "", mv, fixed = TRUE)))
cat("\n\n")
}
}

```
4 changes: 4 additions & 0 deletions scripts/cs2/profiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
"sections": "0",
"userSectionPath": "normalizePath('./scripts/cs2/magpie.Rmd')"
},
"MAGICC7_AR6": {
"sections": "0",
"userSectionPath": "normalizePath('./scripts/cs2/MAGICC7_AR6.Rmd')"
},
"mySection": {
"sections": "0",
"userSectionPath": "normalizePath('./scripts/cs2/mySection.Rmd')"
Expand Down
6 changes: 3 additions & 3 deletions scripts/output/comparison/varListHtml.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ mifs <- c(

details <-
readr::read_delim(
"https://raw.githubusercontent.com/pik-piam/project_interfaces/master/ar6/mapping_template_AR6.csv",
"https://raw.githubusercontent.com/pik-piam/piamInterfaces/master/inst/templates/mapping_template_AR6.csv",
delim = ";",
col_select = c(r21m42, Definition),
col_select = c(piam_variable, Definition),
col_types = "cc"
) |>
dplyr::rename(name = r21m42)
dplyr::rename(name = piam_variable)

remind2::createVarListHtml(
x = mifs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ logmsg <- paste0(
" climateAssessmentYaml = '", climateAssessmentYaml, "' exists? ", file.exists(climateAssessmentYaml), "\n",
" climateAssessmentEmi = '", climateAssessmentEmi, "' exists? ", file.exists(climateAssessmentEmi), "\n",
date(), " =================== EXTRACT REMIND emission data ===========================\n",
" ar6Climate.R: Extracting REMIND emission data\n"
" MAGICC7_AR6.R: Extracting REMIND emission data\n"
)
cat(logmsg)
capture.output(cat(logmsg), file = logFile, append = TRUE)
Expand All @@ -87,7 +87,7 @@ climateAssessmentInputData <- as.quitte(remindReportingFile) %>%
write_csv(climateAssessmentEmi, quote = "none")

logmsg <- paste0(
date(), " ar6Climate.R: Wrote REMIND emission data to '", climateAssessmentEmi, "' for climate-assessment\n"
date(), " MAGICC7_AR6.R: Wrote REMIND emission data to '", climateAssessmentEmi, "' for climate-assessment\n"
)
cat(logmsg)
capture.output(cat(logmsg), file = logFile, append = TRUE)
Expand Down Expand Up @@ -146,15 +146,15 @@ Sys.setenv(MAGICC_WORKER_NUMBER = 1) # TODO: Get this from slurm or nproc
#activate_venv_cmd <- paste("source", normalizePath(file.path(cfg$climate_assessment_root, "..", "venv", "bin", "activate")))
#deactivate_venv_cmd <- "deactivate"

run_harm_inf_cmd <- paste(
runHarmoniseAndInfillCmd <- paste(
"python", file.path(scriptsFolder, "run_harm_inf.py"),
climateAssessmentEmi,
climateAssessmentFolder,
"--no-inputcheck",
"--infilling-database", infillingDatabaseFile
)

run_clim_cmd <- paste(
runClimateEmulatorCmd <- paste(
"python", file.path(scriptsFolder, "run_clim.py"),
normalizePath(file.path(climateAssessmentFolder, paste0(baseFileName, "_harmonized_infilled.csv"))),
climateAssessmentFolder,
Expand All @@ -176,14 +176,14 @@ logmsg <- paste0(
" MAGICC_WORKER_ROOT_DIR = ", Sys.getenv("MAGICC_WORKER_ROOT_DIR") ,"\n",
" MAGICC_WORKER_NUMBER = ", Sys.getenv("MAGICC_WORKER_NUMBER") ,"\n",
date(), " =================== RUN climate-assessment infilling & harmonization ===================\n",
run_harm_inf_cmd, "'\n"
runHarmoniseAndInfillCmd, "'\n"
)
cat(logmsg)
capture.output(cat(logmsg), file = logFile, append = TRUE)

############################# HARMONIZATION/INFILLING #############################

system(run_harm_inf_cmd)
system(runHarmoniseAndInfillCmd)

logmsg <- paste0(date(), " Done with harmonization & infilling\n")
cat(logmsg)
Expand All @@ -192,14 +192,15 @@ capture.output(cat(logmsg), file = logFile, append = TRUE)
############################# RUNNING MODEL #############################

logmsg <- paste0(
date(), " Found ", nparsets, " nparsets, start climate-assessment model runs\n", run_harm_inf_cmd, "\n",
date(), " Found ", nparsets, " nparsets, start climate-assessment climate emulator step\n",
runHarmoniseAndInfillCmd, "\n",
date(), " =================== RUN climate-assessment model ============================\n",
run_clim_cmd, "'\n"
runClimateEmulatorCmd, "'\n"
)
cat(logmsg)
capture.output(cat(logmsg), file = logFile, append = TRUE)

system(run_clim_cmd)
system(runClimateEmulatorCmd)

############################# POSTPROCESS CLIMATE OUTPUT #############################
climateAssessmentOutput <- file.path(
Expand All @@ -208,7 +209,7 @@ climateAssessmentOutput <- file.path(
)

logmsg <- paste0(
date(), " climate-assessment finished\n",
date(), " climate-assessment climate emulator finished\n",
date(), " =================== POSTPROCESS climate-assessment output ==================\n",
" climateAssessmentOutput = '", climateAssessmentOutput, "'\n"
)
Expand All @@ -222,13 +223,15 @@ usePeriods <- as.numeric(grep("[0-9]+", quitte::read_mif_header(remindReportingF
climateAssessmentData <- read.quitte(climateAssessmentOutput) %>%
filter(period %in% usePeriods) %>%
interpolate_missing_periods(usePeriods, expand.values = FALSE) %>%
mutate(variable = gsub("|MAGICCv7.5.3", "", .data$variable, fixed = TRUE)) %>%
mutate(variable = gsub("AR6 climate diagnostics|", "MAGICC7 AR6|", .data$variable, fixed = TRUE)) %>%
write.mif(remindReportingFile, append = TRUE)

deletePlus(remind_reporting_file, writemif = TRUE)
deletePlus(remindReportingFile, writemif = TRUE)

logmsg <- paste0(
date(), " postprocessing done! Results appended to REMIND mif '", remindReportingFile, "'\n",
"ar6Climate.R finished\n"
"MAGICC7_AR6.R finished\n"
)
cat(logmsg)
capture.output(cat(logmsg), file = logFile, append = TRUE)
2 changes: 1 addition & 1 deletion scripts/output/single/checkProjectSummations.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gases <- c("BC", "CO", "CO2", "Kyoto Gases", "NOx", "OC", "Sulfur", "VOC")
vars <- c("", "|Energy", "|Energy Demand|Transportation", "|Energy and Industrial Processes",
"|Energy|Demand", "|Energy|Demand|Transportation")
gasvars <- expand.grid(gases, vars, stringsAsFactors = FALSE)
bunkervars <- unique(sort(paste0("Emissions|", gasvars$Var1, gasvars$Var2)))
bunkervars <- unique(sort(c("Gross Emissions|CO2", paste0("Emissions|", gasvars$Var1, gasvars$Var2))))

for (template in c("AR6", "NAVIGATE")) {
message("\n### Check project summations for ", template)
Expand Down
Loading