Commit fc59b506 authored by Toni's avatar Toni
Browse files

Added tariffs to electricty prices and plot ticks of 24 hour

parent b929de99
...@@ -119,13 +119,22 @@ Set ...@@ -119,13 +119,22 @@ Set
; ;
Parameters Parameters
elspotIsoBB(t,tsIso) "Elspot Prices_2013 (EUR/MWh) with backbone timestamp and ISO date" elspotIsoBB(t,tsIso) "Elspot Prices_2013 (EUR/MWh) with backbone timestamp and ISO date"
ts_priceElspot(t) "Elspot Prices_2013 (EUR/MWh)" ts_priceElspotNP(t) "Elspot NordPool Prices_2013 (EUR/MWh)"
ts_priceElspot(t) "Elspot Prices_2013 inc. tarifs and taxes (EUR/MWh)"
; ;
$gdxIn input\elspot_prices_2013.gdx $gdxIn input\elspot_prices_2013.gdx
$load tsIso elspotIsoBB ts_priceElspot=elspotBB $load tsIso elspotIsoBB ts_priceElspotNP=elspotBB
$gdxin $gdxin
* Add taxes Shk snt/kWh veroluokka I : 2,253 snt/kWh --> 22,53 /MWh
* https://www.vero.fi/yritykset-ja-yhteisot/verot-ja-maksut/valmisteverotus/sahkovero/verotaulukot/
* Considering Lumo tarif: Margin call: 0,24 snt/kWh + Basic fee 1,90 /month
* Ignoring basic fee: 0,24 snt/kWh --> 2,4 /MWh
* https://www.sahkon-kilpailutus.fi/en/market-electricity-price/
ts_priceElspot(t)=ts_priceElspotNP(t) + 22.53 + 2.4
*Setting *Setting
Parameter p_price_el_select "Use flat price 1 EUR/MWh (set 0). Use elspot price (set 1)" /1/; Parameter p_price_el_select "Use flat price 1 EUR/MWh (set 0). Use elspot price (set 1)" /0/;
* Adding temperature data * Adding temperature data
......
# Program description (run "Rscript do_r_plot.r -h") # Program description (run "Rscript do_r_plot.r -h")
#
# Author: Toni Lastusilta (VTT) 2022/01
text <- vector("character") text <- vector("character")
text[1 ] <- " Create R plots from a GAMS GDX file" text[1 ] <- " Create R plots from a GAMS GDX file"
text[2 ] <- "" text[2 ] <- ""
...@@ -27,7 +30,17 @@ library(forcats) ...@@ -27,7 +30,17 @@ library(forcats)
library(reshape) library(reshape)
suppressMessages(library(rapportools)) suppressMessages(library(rapportools))
suppressMessages(library(plyr)) suppressMessages(library(plyr))
suppressMessages(library(this.path))
# Settings
# Use custom x-axis ticks distance for graphs (0 disabled)
custom_x_axis_tick_distance = 24
max_nr_of_custom_x_axis_ticks = 20
#Preprocessing : set working directory
r_dir <- this.dir()
print(paste("Rscript working directory:",r_dir,sep=" "))
setwd(r_dir)
#CMD Line Option Management and Error Checking #CMD Line Option Management and Error Checking
option_list = list( option_list = list(
...@@ -53,9 +66,11 @@ option_list = list( ...@@ -53,9 +66,11 @@ option_list = list(
opt_parser = OptionParser(option_list=option_list, description = program_description) opt_parser = OptionParser(option_list=option_list, description = program_description)
opt = parse_args(opt_parser); opt = parse_args(opt_parser);
#Preprocessing : set working directory and delete old pdf # Import own functions
r_dir = "/Users/tltoni/GIT/FlexiB/backbone_building_v2/plots" src_r_functions = paste(r_dir,"/do_r_plot_functions.r",sep="")
setwd(r_dir) source(src_r_functions)
#Preprocessing : delete old pdf
pdf_name=opt$output pdf_name=opt$output
tryCatch({ tryCatch({
if(file.exists(pdf_name)){ if(file.exists(pdf_name)){
...@@ -180,6 +195,7 @@ if (!is.null(opt$window) && !is.na(opt$window)) { ...@@ -180,6 +195,7 @@ if (!is.null(opt$window) && !is.na(opt$window)) {
df_p[,1] <- ordered(df_p[,1]) df_p[,1] <- ordered(df_p[,1])
levels(df_p[,1]) <- 1:nrow(unique(df_p[1])) levels(df_p[,1]) <- 1:nrow(unique(df_p[1]))
df_p[,1] <- as.numeric(as.character(df_p[,1])) df_p[,1] <- as.numeric(as.character(df_p[,1]))
xvar_tail = tail(df_p[,1],n=1)
# Prepare plot p(x,y) # Prepare plot p(x,y)
xvar <- sym(colnames(df_p)[1]) xvar <- sym(colnames(df_p)[1])
...@@ -257,12 +273,13 @@ if(!empty(df_p2)){ ...@@ -257,12 +273,13 @@ if(!empty(df_p2)){
scale_linetype_discrete(name = paste(value2))+ scale_linetype_discrete(name = paste(value2))+
guides(linetype=guide_legend(ncol=3)) guides(linetype=guide_legend(ncol=3))
} }
#g2_copy<-g2 # to avoid errors we create a copy, g2 changes with switch -w g3 <- g2 + scale_x_continuous(breaks = get_custom_x_axis_breaks(custom_x_axis_tick_distance, max_nr_of_custom_x_axis_ticks, 10, xvar_tail))
#plot(g2_copy) #g3_copy<-g3 # to avoid errors we create a copy, g2 changes with switch -w
#plot(g3_copy)
# create PDF # create PDF
pdf(file = pdf_name, width = 6.25, height = 4, family = "Times", pointsize = 6, onefile = TRUE) pdf(file = pdf_name, width = 6.25, height = 4, family = "Times", pointsize = 6, onefile = TRUE)
print(g2) print(g3)
cnt_plots=1; cnt_plots=1;
# additional figures to PDF with switch -w (window) # additional figures to PDF with switch -w (window)
...@@ -273,7 +290,10 @@ if(window_step>=1){ ...@@ -273,7 +290,10 @@ if(window_step>=1){
window_curr_end=window_end window_curr_end=window_end
} }
xlabel <- paste(xvar_desc,xvar,"(",xvar_labels[window_curr_start,1],"=",window_curr_start,", ...,",xvar_labels[window_curr_end,1],"=",window_curr_end,")") xlabel <- paste(xvar_desc,xvar,"(",xvar_labels[window_curr_start,1],"=",window_curr_start,", ...,",xvar_labels[window_curr_end,1],"=",window_curr_end,")")
print(g2 + xlab(xlabel) + coord_cartesian(xlim = c(window_curr_start,window_curr_end), expand=0)) g4 <- g2 +xlab(xlabel) + coord_cartesian(xlim = c(window_curr_start,window_curr_end), expand=0)+
scale_x_continuous(breaks = get_custom_x_axis_breaks(custom_x_axis_tick_distance, max_nr_of_custom_x_axis_ticks, window_step, xvar_tail))
print(g4)
cnt_plots=cnt_plots+1 cnt_plots=cnt_plots+1
} }
} }
......
# Defines assisting functions for Rscript "do_r_plot.r"
#
# Author: Toni Lastusilta (VTT) 2022/01
# Function to set custom distance for x-axis tick marks or return default on failure
get_custom_x_axis_breaks <- function(custom_x_axis_tick_distance, max_nr_of_custom_x_axis_ticks, window_step, xvar_tail){
#print(paste("Input: custom_x_axis_tick_distance",custom_x_axis_tick_distance,"max_nr_of_custom_x_axis_ticks",max_nr_of_custom_x_axis_ticks,"window_step, xvar_tail",window_step, "xvar_tail",xvar_tail," (defines last element of full x-range)"))
nr_x_axis_tick_marks= window_step%/%24
if(nr_x_axis_tick_marks > max_nr_of_custom_x_axis_ticks){
print(paste("Custom x-axis tick marks ignored. nr_x_axis_tick_marks(",nr_x_axis_tick_marks,") > max_nr_of_custom_x_axis_ticks(",max_nr_of_custom_x_axis_ticks,")"))
waiver()
} else {
seq(0,xvar_tail,by=custom_x_axis_tick_distance)
}
}
\ No newline at end of file
...@@ -235,7 +235,7 @@ $set GDXparam r_state ...@@ -235,7 +235,7 @@ $set GDXparam r_state
$set TMPparam r_state_DH1 $set TMPparam r_state_DH1
$set Ylabel Temperture (Celcius) : $set Ylabel Temperture (Celcius) :
$set Ylabel2 %Ylabel2_alt1% $set Ylabel2 %Ylabel2_alt1%
Parameter %TMPparam%(t,*) "Temperature at Domestic Hot Water Tank (Celcius)" ; Parameter %TMPparam%(t,*) "Detached House 1 (DH1)" ;
execute_loaddc "%backbone_output_GDX%", %GDXparam%; execute_loaddc "%backbone_output_GDX%", %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair * Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),'out_temp')=temp_out(t); %TMPparam%(tparam(t),'out_temp')=temp_out(t);
...@@ -248,7 +248,7 @@ $set GDXparam r_state ...@@ -248,7 +248,7 @@ $set GDXparam r_state
$set TMPparam r_state_DH2 $set TMPparam r_state_DH2
$set Ylabel Temperture (Celcius) : $set Ylabel Temperture (Celcius) :
$set Ylabel2 %Ylabel2_alt1% $set Ylabel2 %Ylabel2_alt1%
Parameter %TMPparam%(t,*) "Temperature at Domestic Hot Water Tank (Celcius)" ; Parameter %TMPparam%(t,*) "Detached House 2 (DH2)" ;
execute_loaddc "%backbone_output_GDX%", %GDXparam%; execute_loaddc "%backbone_output_GDX%", %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair * Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),'out_temp')=temp_out(t); %TMPparam%(tparam(t),'out_temp')=temp_out(t);
...@@ -261,7 +261,7 @@ $set GDXparam r_state ...@@ -261,7 +261,7 @@ $set GDXparam r_state
$set TMPparam r_state_AB $set TMPparam r_state_AB
$set Ylabel Temperture (Celcius) : $set Ylabel Temperture (Celcius) :
$set Ylabel2 %Ylabel2_alt1% $set Ylabel2 %Ylabel2_alt1%
Parameter %TMPparam%(t,*) "Temperature at Domestic Hot Water Tank (Celcius)" ; Parameter %TMPparam%(t,*) "Apartment Building (AB)" ;
execute_loaddc "%backbone_output_GDX%", %GDXparam%; execute_loaddc "%backbone_output_GDX%", %GDXparam%;
* Below line is adjusted for each paramGDX and paramPlot pair * Below line is adjusted for each paramGDX and paramPlot pair
%TMPparam%(tparam(t),'out_temp')=temp_out(t); %TMPparam%(tparam(t),'out_temp')=temp_out(t);
......
...@@ -4,7 +4,7 @@ $ontext ...@@ -4,7 +4,7 @@ $ontext
Addiotnally we create data for "do_r_plot.r" Addiotnally we create data for "do_r_plot.r"
$offtext $offtext
set set
i "Set i " /i1*i5/ i "Set i " /i1*i96/
j "Set j " /j1*j3/ j "Set j " /j1*j3/
k "Set k " /k1*k2/ k "Set k " /k1*k2/
; ;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment