Skip to content
Snippets Groups Projects
Commit bfcc9c5e authored by David Klein's avatar David Klein
Browse files

Merge branch 'develop' of https://github.com/remindmodel/remind into develop

parents 37e25722 fa259f8b
No related branches found
No related tags found
2 merge requests!154*refactoring* changed the efficiency plots in the calibration reporting,!148Add link to the documentation of the mif file format.
......@@ -18,7 +18,7 @@ The model documentation for version 2.1.0 can be found at https://rse.pik-potsda
A most recent version of the documentation can also be extracted from the
model source code via the R package goxygen
(https://github.com/pik-piam/goxygen). To extract the documentation, install the
package and run the main function `(goxygen(unitPattern = c("\\[","\\]"), includeCore=T, use_advanced_interfacePlot_function=T))`
package and run the main function `(goxygen(unitPattern = c("\\[","\\]"), includeCore=T, max_num_edge_labels="adjust", max_num_nodes_for_edge_labels = 15))`
in the main folder of the model.
The resulting documentation can be found in the folder "doc".
......@@ -104,6 +104,8 @@ pkgs <- c("gdxrrw",
"luplot")
install.packages(pkgs)
```
Updating R is recommended if problems arise at package installation, please write
us at remind@pik-potsdam.de to discuss alternatives if this is not possible.
For post-processing model outputs *Latex* is required
(https://www.latex-project.org/get/). To be seen by the model it also needs to
added to the PATH variable of your system.
......
......@@ -22,7 +22,7 @@ cfg$title <- "default"
cfg$regionmapping <- "config/regionmappingH12.csv"
#### Current input data revision (<mainrevision>.<subrevision>) ####
cfg$revision <- 5.941
cfg$revision <- 5.942
#### Force the model to download new input data ####
cfg$force_download <- FALSE
......
......@@ -330,8 +330,8 @@ display p_actualbudgetco2;
if(cm_iterative_target_adj eq 9,
*RP* Update tax levels/ multigasbudget values to reach the peak CO2 budget, with a linear increase afterwards given by cm_taxCO2inc_after_peakBudgYr
*** The PeakBudgYr is found automatically by the algorithm (within the time window 204-2100)
*** The PeakBudgYr is found automatically by the algorithm (within the time window 2040-2100)
p_actualbudgetco2(t) = sum(ttot$(ttot.val < t.val AND ttot.val > 2010), (sum(regi, (vm_emiTe.l(ttot,regi,"co2") + vm_emiCdr.l(ttot,regi,"co2") + vm_emiMac.l(ttot,regi,"co2"))) * sm_c_2_co2 * pm_ts(ttot)))
+ sum(regi, (vm_emiTe.l(t,regi,"co2") + vm_emiCdr.l(t,regi,"co2") + vm_emiMac.l(t,regi,"co2")))*sm_c_2_co2 * (pm_ts(t) * 0.5 + 0.5)
+ sum(regi, (vm_emiTe.l("2010",regi,"co2") + vm_emiCdr.l("2010",regi,"co2") + vm_emiMac.l("2010",regi,"co2")))*sm_c_2_co2 * 2;
......@@ -342,7 +342,11 @@ if(cm_iterative_target_adj eq 9,
display s_actualbudgetco2;
display p_actualbudgetco2;
if(cm_emiscen eq 9,
*** --------A: calculate the new CO2 price path, the CO2 tax rescale factor----------------------------------------------------------
if(o_modelstat eq 2 AND ord(iteration)<cm_iteration_max AND s_actualbudgetco2 > 0 AND abs(c_budgetCO2 - s_actualbudgetco2) ge 2, !!only for optimal iterations, and not after the last one, and only if budget still possitive, and only if target not yet reached
display pm_taxCO2eq;
......@@ -356,8 +360,7 @@ if(cm_iterative_target_adj eq 9,
cm_peakBudgYr = 2100;
);
*** --------new convergence----------------------------------------------------------
*** calculating the CO2 tax rescale factor
*** --------A1: for that, calculate the CO2 tax rescale factor---
if(iteration.val lt 10,
p_factorRescale_taxCO2(iteration) = max(0.1, (s_actualbudgetco2/c_budgetCO2) ) ** 3;
......@@ -388,29 +391,35 @@ if(cm_iterative_target_adj eq 9,
else !! if(o_modelstat eq 2 AND ord(iteration)<cm_iteration_max AND s_actualbudgetco2 > 0 AND abs(c_budgetCO2 ))
if(s_actualbudgetco2 > 0 or abs(c_budgetCO2 - s_actualbudgetco2) < 2, !! if model was not optimal, or if budget already reached, keep tax constant
p_taxCO2eq_until2150(t,regi) = p_taxCO2eq_until2150(t,regi); !! nothing changes
p_factorRescale_taxCO2(iteration) = 1;
p_factorRescale_taxCO2_Funneled(iteration) = 1;
p_taxCO2eq_until2150(t,regi) = p_taxCO2eq_until2150(t,regi); !! nothing changes
else
*** if budget has turned negative, reduce CO2 price by 20%
p_taxCO2eq_until2150(t,regi) = 0.8*p_taxCO2eq_until2150(t,regi);
pm_taxCO2eq(t,regi) = 0.8*pm_taxCO2eq(t,regi);
p_factorRescale_taxCO2(iteration) = 0.8;
p_factorRescale_taxCO2_Funneled(iteration) = p_factorRescale_taxCO2(iteration);
p_taxCO2eq_until2150(t,regi) = p_factorRescale_taxCO2(iteration) * p_taxCO2eq_until2150(t,regi);
pm_taxCO2eq(t,regi) = p_factorRescale_taxCO2(iteration) * pm_taxCO2eq(t,regi);
);
); !! if(o_modelstat eq 2 AND ord(iteration)<cm_iteration_max AND s_actualbudgetco2 > 0 AND abs(c_budgetCO2 - s_actualbudgetco2) ge 2,
display pm_taxCO2eq, p_taxCO2eq_until2150;
***-----------------------------------------------
*** -------B: checking the peak timing, if cm_peakBudgYr is still correct or needs to be shifted-----------------------
o_diff_to_Budg(iteration) = (c_budgetCO2 - s_actualbudgetco2);
o_totCO2emi_peakBudgYr(iteration) = sum(t$(t.val = cm_peakBudgYr), sum(regi2, vm_emiAll.l(t,regi2,"co2")) );
o_totCO2emi_allYrs(t,iteration) = sum(regi2, vm_emiAll.l(t,regi2,"co2") );
*RP* calculate how fast emissions are changing around the peaking time to get an idea how close it is possible to get to 0 due to the 5(10) year time steps
o_change_totCO2emi_peakBudgYr(iteration) = sum(ttot$(ttot.val = cm_peakBudgYr), (o_totCO2emi_allYrs(ttot-1,iteration) - o_totCO2emi_allYrs(ttot+1,iteration) )/4 ); !! Only gives a tolerance range, exact value not important. Division by 4 somewhat arbitrary - could be 3 or 5 as well.
display cm_peakBudgYr, o_diff_to_Budg, o_peakBudgYr_Itr, o_totCO2emi_allYrs, o_totCO2emi_peakBudgYr, o_change_totCO2emi_peakBudgYr;
*** check if cm_peakBudgYr is correct: if global emissions are already negative, move cm_peakBudgYr forward
*** ----B1: check if cm_peakBudgYr should be shifted left or right:
if( abs(o_diff_to_Budg(iteration)) < 20, !! only think about shifting peakBudgYr if the budget is close enough to target budget
display "close enough to target budget to check timing of peak year";
loop(ttot$(ttot.val = cm_peakBudgYr), !! look at the peak timing
......@@ -432,7 +441,7 @@ if(cm_iterative_target_adj eq 9,
);
);
else !! don't do anything if the peakBudgYr is already at the corner values (2040, 2100) or if the emissions in the peakBudgYr are close to 0
else !! don't do anything if the peakBudgYr is already at the corner values (2040, 2100) or if the emissions in the peakBudgYr are close enough to 0 (within the range of +/- o_change_totCO2emi_peakBudgYr)
o_peakBudgYr_Itr(iteration+1) = o_peakBudgYr_Itr(iteration)
);
);
......@@ -442,7 +451,8 @@ if(cm_iterative_target_adj eq 9,
pm_taxCO2eq(t,regi)$(t.val le cm_peakBudgYr) = p_taxCO2eq_until2150(t,regi); !! until peakBudgYr, take the contiuous price trajectory
if (o_delay_increase_peakBudgYear(iteration) = 1, !! if there was a flip-floping in the previous iterations, try to solve this
*** -----B2: if there was a flip-floping of cm_peakBudgYr in the previous iterations, try to overome this by adjusting the CO2 price path after the peaking year
if (o_delay_increase_peakBudgYear(iteration) = 1,
display "not shifting peakBudgYr right, instead adjusting CO2 price for following year";
loop(ttot$(ttot.val eq cm_peakBudgYr), !! set ttot to the current peakBudgYr
loop(t2$(t2.val eq pm_ttot_val(ttot+1)), !! set t2 to the following time step
......
......@@ -82,9 +82,9 @@
*
* Regionscode: 690d3718e151be1b450b394c1064b1c5
*
* Input data revision: 5.94
* Input data revision: 5.942
*
* Last modification (input data): Thu Mar 19 16:15:13 2020
* Last modification (input data): Tue Apr 21 12:02:34 2020
*
*###################### R SECTION END (VERSION INFO) ###########################
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -20,20 +20,20 @@
suppressPackageStartupMessages(library(tidyverse))
# TODO: Loading magclass shouldn't actually be necessary... but running on the
# cluster without doing so throws an error...
suppressPackageStartupMessages(library(magclass))
# Function defintions
get_run_names <- function(filepaths) {
# The run names are found between a "/" and the time-stamp of the run.
run_names <- str_match(filepaths, pattern = "^.*\\/(.*)(_....-..-..*)$")[,2]
# If for some reason there isn't a time-stamp, return the name of the folder
if (any(is.na(run_names))) {
run_names <- str_match(filepaths, pattern = "^.*\\/(.*)\\/.*$")[,2]
}
return(run_names)
rm_timestamp <- function(strings,
name_timestamp_seperator = "_",
timestamp_format = "%Y-%m-%d_%H.%M.%S") {
# Get regex pattern of timestamp
regex_timestamp <- gsub("%[mdHMS]", "\\\\d{2}", timestamp_format)
regex_timestamp <- gsub("%Y", "\\\\d{4}", regex_timestamp)
regex_timestamp <- paste0(name_timestamp_seperator, regex_timestamp)
# Substitute timestamps with nothing (thereby removing them)
my_strings_wo_timeStamp <- sub(regex_timestamp, "", strings)
return(my_strings_wo_timeStamp)
}
policy_costs_pdf <- function(policy_costs, fileName="PolicyCost.pdf") {
......@@ -113,21 +113,21 @@ policy_costs_pdf <- function(policy_costs, fileName="PolicyCost.pdf") {
}
# Check for an object called "source_include". If found, that means, this script
# is being called from another (output.R most likely), and the input variables
# are already in the environment. If not found, the input variables are given
# default values, and made over-writable with command line values.
# is being called from another (output.R most likely), and the input variable
# "outputdirs" is already in the environment. If not found, "outputdirs" is given
# default values, and made over-writable with the command line.
if(!exists("source_include")) {
# Set default value
outputdirs <- c("../../femulator_hq/remind_runs_lab/base_allT_lab_0point7_2020-03-12_09.36.25",
"../../femulator_hq/remind_runs_lab/base_allT_lab_0point95_2020-03-16_15.35.20",
"../../femulator_hq/remind_runs_lab/base_allT_lab_0point7_2020-03-12_09.36.25",
"../../femulator_hq/remind_runs_lab/base_allT_lab_0point8_2020-03-12_09.36.24")
outputdirs <- c("../../../output/default_2020-03-03_09.38.01",
"../../../output/default_slim_2020-03-03_11.37.51",
"../../../output/sa_emu_3_2_2020-03-13_16.41.08",
"../../../output/sa_emu_1_posYIntercept_posSlope_2020-04-14_11.08.07")
# Make over-writtable from command line
lucode::readArgs("outputdirs")
}
# Check that the input variable "outputdirs" has an even number of entries.
# Check that "outputdirs" has an even number of entries.
if (length(outputdirs) %% 2!=0) {
cat(paste0(crayon::red("\nERROR: "), "The number of directories is not even!\n"))
cat("Remember, the order in which you choose the directories should be:\n")
......@@ -141,14 +141,14 @@ pol_gdxs <- paste0(outputdirs[seq(1,length(outputdirs),2)], "/fulldata.gdx")
ref_gdxs <- paste0(outputdirs[seq(2,length(outputdirs),2)], "/fulldata.gdx")
# Get run names
pol_names <- get_run_names(pol_gdxs)
ref_names <- get_run_names(ref_gdxs)
pol_names <- rm_timestamp(basename(dirname(pol_gdxs)))
ref_names <- rm_timestamp(basename(dirname(ref_gdxs)))
# Define pol-ref, policyCost pair names
pc_pairs <- paste0(pol_names, "_w.r.t_",ref_names)
# If scrpit was called from output.R, check with user if the pol-ref pairs are the
# ones he wanted.
# If this scrpit was called from output.R, check with user if the pol-ref pairs
# are the ones he wanted.
if(exists("source_include")) {
cat(crayon::blue("\nPlease confirm the set-up:\n"))
cat("From the order with which you selected the directories, the following policy-cost curves will be created:\n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment