Skip to content

Transfer airpollutants from MAgPIE in coupled mode#2355

Open
dklein-pik wants to merge 7 commits into
remindmodel:developfrom
dklein-pik:ap
Open

Transfer airpollutants from MAgPIE in coupled mode#2355
dklein-pik wants to merge 7 commits into
remindmodel:developfrom
dklein-pik:ap

Conversation

@dklein-pik
Copy link
Copy Markdown
Contributor

Purpose of this PR

Please explain your PR here.

Type of change

Indicate the items relevant for your PR by replacing ◻️ with ☑️.
Do not delete any lines. This makes it easier to understand which areas are affected by your changes and which are not.

Parts concerned

  • ◻️ GAMS Code
  • ☑️ R-scripts
  • ◻️ Documentation (GAMS incode documentation, comments, tutorials)
  • ◻️ Input data / CES parameters
  • ◻️ Tests, CI/CD (continuous integration/deployment)
  • ◻️ Configuration (switches in main.gms, default.cfg, and scenario_config*.csv files)
  • ◻️ Other (please give a description)

Impact

  • ◻️ Bug fix
  • ◻️ Refactoring
  • ☑️ New feature
  • ◻️ Change of parameter values or input data (including CES parameters)
  • ◻️ Minor change (default scenarios show only small differences)
  • ◻️ Fundamental change of results of default scenarios

Checklist

Do not delete any line. Leave unfinished elements unchecked so others know how far along you are.
In the end all checkboxes must be ticked before you can merge
.

  • I executed the automated model tests (make test) after my final commit and all tests pass (FAIL 0)
  • I adjusted the reporting in remind2 if and where it was needed
  • I adjusted the madrat packages (mrremind and other packages involved) for input data generation if and where it was needed
  • My code follows the coding etiquette
  • I explained my changes within the PR, particularly in hard-to-understand areas
  • I checked that the in-code documentation is up-to-date
  • I adjusted forbiddenColumnNames in readCheckScenarioConfig.R in case the PR leads to deprecated switches
  • I updated the CHANGELOG.md correctly (added, changed, fixed, removed, input data/calibration)

Further information (optional)

  • Runs with these changes are here:
  • Comparison of results (what changes by this PR?):

Copilot AI review requested due to automatic review settings May 28, 2026 15:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds coupling support to pass MAgPIE air pollutant emissions into the REMIND workflow (for reporting), and exposes the land-use emissions baseline switch (cm_LU_emi_scen) in the final GDX for traceability.

Changes:

  • Extend scripts/input/magpie.R with air-pollutant variable mappings and export of those emissions to a reporting .cs4r file alongside the existing GDX coupling export.
  • Refactor the MAgPIE→REMIND transfer logic by splitting out a writeToGdx() helper.
  • Add cm_LU_emi_scen as a compiler-flag set in core/sets.gms and adjust scenario_config.csv rows for SSP2_lowEn scenarios.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/input/magpie.R Adds air-pollutant mappings and writes them to a reporting file; refactors GDX writing into a helper.
core/sets.gms Exposes cm_LU_emi_scen as a set in the final GDX.
config/scenario_config.csv Updates SSP2_lowEn scenario rows (but currently changes demand-scenario behavior).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/input/magpie.R

mappingAP <- tibble::tibble(mag = magAP, enty = remAP, factorMag2Rem = 1, parameter = "AirPollutantsMAgPIE")

mag2rem <- bind_rows(mag2rem, mappingAP)
Comment thread scripts/input/magpie.R
group_by(period, region, enty, parameter, unit) |> # define groups for summation, include unit to keep it (needed for export of air pollutants to REMIND reporting)
summarise(value = sum(value), .groups = "drop") |> # sum MAgPIE emissions (variable) that have the same enty in remind
rename(ttot = period, regi = region) |> # use REMIND set names
filter(, regi != "World", between(ttot, 2005, 2150)) # keep REMIND time horizon and remove World region
Comment thread scripts/input/magpie.R
Comment on lines +45 to +49
# Therefore, they wont be written to the gdx but to an extra file the reporting uses.
species <- c("BC","CO","NH3","NO2","OC","SO2","VOC")

magAP <- c(#paste0("Emissions|", species, "|AFOLU|Agriculture"), # exists for BC, CO, OC, SO2 and VOC only (exogenous in MAgPIE)
paste0("Emissions|", c("NH3", "NO2"), "|Land|+|Agriculture"), # exists for NH3, NO2 only (endogeous in MAgPIE)
Comment on lines +40 to +42
SSP2_lowEn-NPi2025;0;;;;;;;;;0;;;;;;;;;;;;;;;;;;;;;;;;;;;;SSP2_lowEn;;;;;;;;;;;;;;;;1;2030;;SSP2-NPi2025;;;SSP2_lowEn-NPi2025: This National Policies Implemented (NPi) scenario follows the Shared Socioeconomic Pathways 2 called Middle of the Road. This scenario also assumes low energy demand trajectories. The NPi reflects currently implemented policies, while fulfilling near-term feasibility and long-term plausibility assessments. Emissions trajectories are aligned with bottom-up studies on the effect of currently implemented policies. Carbon prices are constant in the mid- and long-term.
SSP2_lowEn-PkBudg650;0;;;;;rcp20;globallyOptimal;;;9;650;;functionalForm;;;100;2055;6;;EUR_regi 0.08, USA_regi 0.07, CHA_regi 0.07, CAZ_regi 0.07, JPN_regi 0.07, GLO 0.06;transformative;;;;;;;;;;2050.GLO 0.9;;;;;;;SSP2_lowEn;;;;;;;2;;;;;;;Elec_Push;Mix4ICEban;1;2030;;SSP2-NPi2025;;;SSP2_lowEn-PkBudg650: This climate policy scenario follows the Shared Socioeconomic Pathways 2 called Middle of the Road. This scenario also assumes low energy demand trajectories. The stylized climate policy scenario assumes a peak budget of 650 Gt CO2 on total CO2 emissions from 2015 to 2100. This is a 1.5C scenario, peak warming is allowed to be at or slightly above 1.5C at median climate sensitivity but returns to values below 1.5C in at least 67 % of scenarios by the end of the century.
SSP2_lowEn-PkBudg1000;0;;;;;rcp26;globallyOptimal;;;9;1000;;functionalForm;;;75;2080;7;;EUR_regi 0.08, USA_regi 0.07, CHA_regi 0.07, CAZ_regi 0.07, JPN_regi 0.07, GLO 0.06;transformative;;;;;;;;;;2050.GLO 0.5;;;;;;;SSP2_lowEn;;;;;;;2;;;;;;;;Mix3ICEban;1;2030;;SSP2-NPi2025;;;SSP2_lowEn-PkBudg1050: This climate policy scenario follows the Shared Socioeconomic Pathways 2 called Middle of the Road. This scenario also assumes low energy demand trajectories. The stylized climate policy scenario assumes a peak budget of 1050 Gt CO2 on total CO2 emissions from 2015 to 2100. This is a well below 2C scenario at median climate sensitivity but returns to values below 2C in at least 67 % of scenarios during the whole century.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants