Skip to content
Snippets Groups Projects
Commit 78efbd85 authored by Alois Dirnaichner's avatar Alois Dirnaichner
Browse files

Remove warning from EDGE_Transport script and correct some indentation issues.

parent 36bd969f
No related branches found
No related tags found
1 merge request!67Request to merge the new transport module EDGE-T
...@@ -93,12 +93,12 @@ if (setlearning | addvintages){ ...@@ -93,12 +93,12 @@ if (setlearning | addvintages){
} }
if (setlearning & file.exists("demand_previousiter.RDS")) { if (setlearning & file.exists("demand_previousiter.RDS")) {
## load previous iteration number of cars ## load previous iteration number of cars
demand_BEVtmp = readRDS("demand_BEV.RDS") demand_BEVtmp = readRDS("demand_BEV.RDS")
## load previous iteration demand ## load previous iteration demand
ES_demandpr = readRDS("demand_previousiter.RDS") ES_demandpr = readRDS("demand_previousiter.RDS")
## calculate non fuel costs and ## calculate non fuel costs and
nonfuel_costs = applylearning(gdx,REMINDmapping,EDGE2teESmap, demand_BEVtmp, ES_demandpr) nonfuel_costs = applylearning(gdx,REMINDmapping,EDGE2teESmap, demand_BEVtmp, ES_demandpr)
saveRDS(nonfuel_costs, "nonfuel_costs_learning.RDS") saveRDS(nonfuel_costs, "nonfuel_costs_learning.RDS")
} }
...@@ -127,21 +127,21 @@ saveRDS(REMIND_prices, paste0("REMINDprices", iter, ".RDS")) ...@@ -127,21 +127,21 @@ saveRDS(REMIND_prices, paste0("REMINDprices", iter, ".RDS"))
if(average_prices){ if(average_prices){
if(max(unique(REMIND_prices$iternum)) >= 20 & max(unique(REMIND_prices$iternum)) <= 30){ if(max(unique(REMIND_prices$iternum)) >= 20 & max(unique(REMIND_prices$iternum)) <= 30){
old_prices <- readRDS(pfile) old_prices <- readRDS(pfile)
all_prices <- rbind(old_prices, REMIND_prices) all_prices <- rbind(old_prices, REMIND_prices)
setkeyv(all_prices, keys) setkeyv(all_prices, keys)
## apply moving avg ## apply moving avg
REMIND_prices <- REMIND_prices[ REMIND_prices <- REMIND_prices[
all_prices[iternum >= 20, mean(tot_price), by=keys], tot_price := V1] all_prices[iternum >= 20, mean(tot_price), by=keys], tot_price := V1]
all_prices <- rbind(old_prices, REMIND_prices) all_prices <- rbind(old_prices, REMIND_prices)
}else{ }else{
all_prices <- REMIND_prices all_prices <- REMIND_prices
} }
saveRDS(all_prices, pfile) saveRDS(all_prices, pfile)
## save REMIND prices (after dampening) ## save REMIND prices (after dampening)
saveRDS(REMIND_prices,paste0("REMINDpricesDampened", iter, ".RDS")) saveRDS(REMIND_prices,paste0("REMINDpricesDampened", iter, ".RDS"))
} }
...@@ -149,15 +149,15 @@ REMIND_prices[, "iternum" := NULL] ...@@ -149,15 +149,15 @@ REMIND_prices[, "iternum" := NULL]
## calculates logit ## calculates logit
if (inconvenience) { if (inconvenience) {
years=copy(REMINDyears) years=copy(REMINDyears)
logit_data <- calculate_logit_inconv_endog( logit_data <- calculate_logit_inconv_endog(
prices= REMIND_prices[tot_price > 0], prices= REMIND_prices[tot_price > 0],
vot_data = vot_data, vot_data = vot_data,
inco_data = inco_data, inco_data = inco_data,
logit_params = logit_params, logit_params = logit_params,
intensity_data = int_dat, intensity_data = int_dat,
price_nonmot = price_nonmot) price_nonmot = price_nonmot)
} else{ } else{
...@@ -172,7 +172,7 @@ logit_data <- calculate_logit_inconv_endog( ...@@ -172,7 +172,7 @@ logit_data <- calculate_logit_inconv_endog(
} }
shares <- logit_data[["share_list"]] ## shares of alternatives for each level of the logit function shares <- logit_data[["share_list"]] ## shares of alternatives for each level of the logit function
shares$VS1_shares=shares$VS1_shares[,-c("sector","subsector_L2","subsector_L3")] ## shares$VS1_shares=shares$VS1_shares[,-c("sector","subsector_L2","subsector_L3")]
mj_km_data <- logit_data[["mj_km_data"]] ## energy intensity at a technology level mj_km_data <- logit_data[["mj_km_data"]] ## energy intensity at a technology level
prices <- logit_data[["prices_list"]] ## prices at each level of the logit function, 1990USD/pkm prices <- logit_data[["prices_list"]] ## prices at each level of the logit function, 1990USD/pkm
...@@ -205,12 +205,12 @@ demByTech <- shares_intensity_demand[["demand"]] ##in [-] ...@@ -205,12 +205,12 @@ demByTech <- shares_intensity_demand[["demand"]] ##in [-]
intensity <- shares_intensity_demand[["demandI"]] ##in million pkm/EJ intensity <- shares_intensity_demand[["demandI"]] ##in million pkm/EJ
norm_demand <- shares_intensity_demand$demandF_plot_pkm ## total demand is 1, required for costs norm_demand <- shares_intensity_demand$demandF_plot_pkm ## total demand is 1, required for costs
if (setlearning) { if (setlearning) {
demand_BEV=calc_num_vehicles( norm_dem_BEV = norm_demand[technology == "BEV" & ## battery vehicles demand_BEV=calc_num_vehicles( norm_dem_BEV = norm_demand[technology == "BEV" & ## battery vehicles
subsector_L1 == "trn_pass_road_LDV_4W", ## only 4wheelers subsector_L1 == "trn_pass_road_LDV_4W", ## only 4wheelers
c("iso", "year", "sector", "vehicle_type", "demand_F") ], c("iso", "year", "sector", "vehicle_type", "demand_F") ],
ES_demand = ES_demand) ES_demand = ES_demand)
## save number of vehicles for next iteration ## save number of vehicles for next iteration
saveRDS(demand_BEV, "demand_BEV.RDS") saveRDS(demand_BEV, "demand_BEV.RDS")
## save the demand for next iteration renaming the column ## save the demand for next iteration renaming the column
...@@ -244,8 +244,8 @@ finalInputs <- prepare4REMIND( ...@@ -244,8 +244,8 @@ finalInputs <- prepare4REMIND(
REMINDtall = REMINDtall, REMINDtall = REMINDtall,
REMIND2ISO_MAPPING=REMIND2ISO_MAPPING) REMIND2ISO_MAPPING=REMIND2ISO_MAPPING)
## add the columns of SSP scenario and EDGE scenario to the output parameters ## add the columns of SSP scenario and EDGE scenario to the output parameters
for (i in names(finalInputs)) { for (i in names(finalInputs)) {
finalInputs[[i]]$SSP_scenario <- scenario finalInputs[[i]]$SSP_scenario <- scenario
......
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