Skip to content

Fix summation errors: load parameter values from ref gdx because they are not covered by the fixing mechanism#2389

Merged
dklein-pik merged 3 commits into
remindmodel:developfrom
dklein-pik:develop
Jul 3, 2026
Merged

Fix summation errors: load parameter values from ref gdx because they are not covered by the fixing mechanism#2389
dklein-pik merged 3 commits into
remindmodel:developfrom
dklein-pik:develop

Conversation

@dklein-pik

Copy link
Copy Markdown
Contributor

Purpose of this PR

Some time ago, CO2 landuse change subcategories were introduced into REMIND as pure parameters (p_co2lucSub), which are passed through solely for reporting purposes but are not modified or used in calculations. Since they are parameters, they are not covered by the fixing mechanism. In contrast, their sum (vm_emiMacSector(t,regi, “co2luc”)) is a variable that is covered by the fixing mechanism. As a result, p_co2lucSub for years < cm_startyear was not fixed by the fixing mechanism to the values from the NPi, but were always read from the lookup table (f_macBaseMagpie). This led to summation errors, as the sum (vm_emiMacSector, fixed to ref as a variable) and the subcategories (p_co2lucSub, read from the lookup table) could be inconsistent.

This PR loads p_co2lucSub for years < cm_startyear from the GDX—specifically, the same one used for fixing the variables—thereby ensuring consistency and eliminating the summation errors (reported in the issues listed below).

Fixes https://github.com/remindmodel/development_issues/issues/769
Fixes https://github.com/remindmodel/development_issues/issues/768

Type of change

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

  • 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)

Copilot AI review requested due to automatic review settings July 3, 2026 08:04
@dklein-pik dklein-pik requested a review from fbenke-pik July 3, 2026 08:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an inconsistency in historical (t < cm_startyear) CO2 land-use change subtype reporting by loading the p_co2lucSub parameter from the same reference GDX used by the fixing mechanism, preventing mismatches between the fixed aggregate (vm_emiMacSector(...,"co2luc")) and its reported subcomponents.

Changes:

  • Load p_co2lucSub from input_ref when cm_startyear > 2005 to align pre-startyear values with the fixed reference run.
  • Only overwrite p_co2lucSub values for ttot >= cm_startyear from the lookup table (f_macBaseMagpie), leaving earlier years consistent with the reference GDX.

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

Comment thread core/datainput.gms Outdated
Comment thread core/datainput.gms Outdated
@dklein-pik dklein-pik merged commit be78ab5 into remindmodel:develop Jul 3, 2026
2 checks passed
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.

3 participants