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

+ script checking if fixing to ref run worked, allows to fix that in post-processing #1410

Merged
merged 5 commits into from
Oct 12, 2023

Conversation

orichters
Copy link
Contributor

@orichters orichters commented Sep 13, 2023

Purpose of this PR

  • Add a script that checks whether the fixing to path_gdx_ref for < cm_startyear has worked.
  • In the normal mode, it searches in the config where the input_ref.gdx came from, finds the mif file and starts comparing
  • I suggest to add it to the usual output scripts, it will print a list of wrongly fixed variables to the log file such that people are aware of it.
  • In interactive mode (that is: started via output.R), you can even fix that, and the data are then copied over from the old mif. That should be nothing we usually do, but as long as the fixing is incomplete, it allows to submit datasets that are consistent.
  • I reused some of the code @0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q wrote in the issue above.

Type of change

  • New feature

Checklist:

  • My code follows the coding etiquette
  • I performed a self-review of my own code
  • I explained my changes within the PR, particularly in hard-to-understand areas
  • I checked that the in-code documentation is up-to-date
  • All automated model tests pass (FAIL 0 in the output of make test)
  • The changelog CHANGELOG.md has been updated correctly

This is how the output looks like:

### Checking if mif is correctly fixed on reference run for /p/projects/remind/runs/REMIND_master_2023_07_13/remind/output/SSP2EU-NDC_2023-07-14_05.58.45
Comparing with reference run SSP2EU-NPi for t < 2025

### Incorrect fixing for these variable groups for model=REMIND and scenario=SSP2EU-NDC
# A tibble: 76 × 4
   group                                                      variables period                 reldiff
   <fct>                                                          <int> <chr>                  <chr>
 1 Capital Cost|Transport|Freight                                    40 2005, 2010, 2015, 2020 0.7620000
 2 Capital Cost|Transport|Pass                                       81 2005, 2010, 2015, 2020 0.6840000
 3 Costs|Biomass|Price integral presolve                              1 2005, 2010, 2015, 2020 1.0000000
 4 Costs|Land Use                                                     1 2015, 2020             0.0014200
 5 Costs|Land Use|MAC-costs                                           3 2015, 2020             1.0000000
 6 Emi|CO2|Transport                                                 55 2005, 2010, 2015, 2020 0.3550000
 7 ES|Transport edge|Road                                             1 2005, 2010, 2015, 2020 0.0363000
 8 ES|Transport|Freight                                              33 2005, 2010, 2015, 2020 0.7620000
 9 ES|Transport|Pass                                                 86 2005, 2010, 2015, 2020 0.5970000
10 ES|Transport|VKM                                                 115 2005, 2010, 2015, 2020 0.7620000
11 ES|Transport|VNUM                                                  7 2005, 2010, 2015, 2020 0.1120000
12 FE|Transport|Freight                                              45 2005, 2010, 2015, 2020 1.0000000
13 FE|Transport|LDV                                                   3 2005, 2010, 2015, 2020 0.5100000
14 FE|Transport|non-LDV                                               3 2005, 2010, 2015, 2020 0.5500000
15 FE|Transport|Pass                                                 88 2005, 2010, 2015, 2020 1.0000000
16 FE|Transport|Rail                                                  1 2005, 2010, 2015, 2020 0.1380000
17 FE|Transport|Road                                                  5 2005, 2010, 2015, 2020 0.5500000
18 Forcing                                                            1 2020                   0.0003050
19 Forcing|Aerosol                                                    1 2020                   0.0007830
20 Forcing|Aerosol|BC                                                 1 2020                   0.0005860
21 Forcing|Aerosol|Cloud Indirect                                     1 2020                   0.0004780
22 Forcing|Aerosol|Nitrate Direct                                     1 2020                   0.0012100
23 Forcing|Aerosol|OC                                                 1 2020                   0.0001160
24 Forcing|Aerosol|Other                                              1 2020                   0.0005550
25 Forcing|Aerosol|Sulfate Direct                                     1 2020                   0.0012000
26 Forcing|AN3A                                                       1 2020                   0.0002180
27 Internal|CES Markup Cost|feelhpb                                   1 2005, 2010, 2015, 2020 1.0000000
28 Internal|CES Markup Cost|feheb                                     1 2005, 2010, 2015, 2020 1.0000000
29 Internal|Price|CES                                                32 2005, 2010, 2015, 2020 1.0000000
30 Net Taxes|CO2 market|ESR                                           1 2015, 2020             1.0000000
31 Net Taxes|CO2 market|ETS                                           1 2015, 2020             1.0000000
32 Net Taxes|CO2 market|other                                         1 2015, 2020             1.0000000
33 Net Taxes|SO2                                                      1 2010, 2015, 2020       0.0000439
34 PE|Production|Net                                                  2 2005, 2010, 2015, 2020 0.0023500
35 Price|Carbon                                                       1 2015, 2020             0.0000129
36 Price|Carbon|Demand                                                3 2015, 2020             0.0000129
37 Price|Carbon|ESR                                                   1 2015, 2020             1.0000000
38 Price|Carbon|ETS                                                   1 2015, 2020             1.0000000
39 Price|Carbon|Supply                                                1 2015, 2020             0.0000129
40 Price|CH4                                                          1 2015, 2020             0.0000128
41 Price|Final Energy|Buildings                                      22 2010, 2015, 2020       1.0000000
42 Price|Final Energy|CDR                                            22 2010, 2015, 2020       1.0000000
43 Price|Final Energy|ESR                                            28 2010, 2015, 2020       1.0000000
44 Price|Final Energy|ETS                                            18 2010, 2015, 2020       1.0000000
45 Price|Final Energy|Industry                                       36 2010, 2015, 2020       1.0000000
46 Price|Final Energy|other                                          14 2010, 2015, 2020       1.0000000
47 Price|Final Energy|Stationary                                     14 2010, 2015, 2020       1.0000000
48 Price|Final Energy|Transport                                      39 2010, 2015, 2020       1.0000000
49 Price|N2O                                                          1 2015, 2020             0.0000128
50 Revenue|Government|Tax                                             5 2015, 2020             0.0000130
51 Sales|Transport|Bus                                                5 2005, 2010, 2015, 2020 0.2530000
52 Sales|Transport|LDV                                               54 2005, 2010, 2015, 2020 0.5720000
53 Sales|Transport|Truck                                             24 2005, 2010, 2015, 2020 0.7550000
54 Stock|Transport|Bus                                                5 2005, 2010, 2015, 2020 0.2480000
55 Stock|Transport|LDV                                               54 2005, 2010, 2015, 2020 0.5820000
56 Stock|Transport|Truck                                             24 2005, 2010, 2015, 2020 0.7560000
57 Tech|Electricity|Biomass                                           2 2010, 2015, 2020       0.9980000
58 Tech|Electricity|Coal                                              4 2010, 2015, 2020       0.8170000
59 Tech|Electricity|Gas                                               3 2010, 2015, 2020       0.9340000
60 Tech|Electricity|Geothermal|Capital Costs|w/ Adj Costs             1 2010, 2015, 2020       0.9880000
61 Tech|Electricity|Hydro|Capital Costs|w/ Adj Costs                  1 2010, 2015, 2020       0.5910000
62 Tech|Electricity|Nuclear|Capital Costs|w/ Adj Costs                1 2010, 2015, 2020       0.6810000
63 Tech|Electricity|Solar                                             2 2010, 2015, 2020       0.4280000
64 Tech|Electricity|Storage                                           2 2020                   0.0308000
65 Tech|Electricity|Wind                                              2 2010, 2015, 2020       0.5450000
66 Tech|Gases|Biomass|w/o CC|Capital Costs|w/ Adj Costs               1 2010, 2015, 2020       0.4000000
67 Tech|Heat|Biomass|Capital Costs|w/ Adj Costs                       1 2010, 2015, 2020       0.4620000
68 Tech|Heat|Coal|Capital Costs|w/ Adj Costs                          1 2010, 2015, 2020       0.3490000
69 Tech|Heat|Electricity|Heat Pump|Capital Costs|w/ Adj Costs         1 2010, 2015             0.9940000
70 Tech|Heat|Gas|Capital Costs|w/ Adj Costs                           1 2010, 2015, 2020       0.7640000
71 Tech|Hydrogen|Biomass|w/o CC|Capital Costs|w/ Adj Costs            1 2020                   0.0482000
72 Tech|Hydrogen|Coal|w/o CC|Capital Costs|w/ Adj Costs               1 2015, 2020             0.3580000
73 Tech|Hydrogen|Gas                                                  2 2020                   0.4070000
74 Tech|Liquids|Biomass                                               3 2015, 2020             0.2360000
75 Tech|Liquids|Fossil                                                2 2010, 2015, 2020       0.9720000
76 Temperature|Global Mean                                            1 2020                   0.0001220
Find failing variables in '/p/projects/remind/runs/REMIND_master_2023_07_13/remind/output/SSP2EU-NDC_2023-07-14_05.58.45/log_fixOnRef.csv'.
Returning fixed data.

log_fixOnRef.csv is a csv file that certainly could be improved, now its first lines look like that:

model,scenario,region,variable,unit,period,ref,value
REMIND,ELV_LTS_avtax_nTecC_rc_T44,CAZ,Expenditure|Transport|Fuel,billion $US/yr,2025,135.995994,132.3464589
REMIND,ELV_LTS_avtax_nTecC_rc_T44,CHA,Expenditure|Transport|Fuel,billion $US/yr,2025,292.6705936,308.2949786
REMIND,ELV_LTS_avtax_nTecC_rc_T44,EUR,Expenditure|Transport|Fuel,billion $US/yr,2025,848.9928525,852.9315037
REMIND,ELV_LTS_avtax_nTecC_rc_T44,IND,Expenditure|Transport|Fuel,billion $US/yr,2025,157.0624074,125.1372368
REMIND,ELV_LTS_avtax_nTecC_rc_T44,JPN,Expenditure|Transport|Fuel,billion $US/yr,2025,149.3296907,151.8765628

@orichters orichters marked this pull request as ready for review October 10, 2023 14:20
Copy link
Member

@LaviniaBaumstark LaviniaBaumstark left a comment

Choose a reason for hiding this comment

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

nice function, will help us to address the issue of wrong fixings, thanks

@@ -110,7 +110,7 @@ cfg$logoption <- 2

# Just list the name of the output scripts that should be used by output.R
# At the moment there are several R-scripts located in scripts/output/
cfg$output <- c("reporting","reportCEScalib","rds_report") #,"validation","emulator","reportCEScalib","validationSummary","dashboard")
cfg$output <- c("reporting","reportCEScalib","rds_report","fixOnRef") #,"validation","emulator","reportCEScalib","validationSummary","dashboard")
Copy link
Member

Choose a reason for hiding this comment

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

yes, let's run it always to besure that everything is working later and for gettign teh info now for the fixing

@orichters orichters merged commit b0c4122 into remindmodel:develop Oct 12, 2023
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.

2 participants