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

Add ACEA vehicle numbers to compare to in the report #73

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions R/generateEDGEdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ generateEDGEdata <- function(input_folder, output_folder,

saveRDS(POP, file = level2path("POP.RDS"))
saveRDS(IEAbal_comparison$IEA_dt2plot, file = level2path("IEAcomp.RDS"))
## copy ACEA data for comparison
acea_files <- list.files(file.path(input_folder, "ACEA"), pattern="*.csv", full.names=T)
file.copy(acea_files, level2path(""), overwrite = T)
md_template = level2path("report.Rmd")
## ship and run the file in the output folder
file.copy(system.file("Rmd", "report.Rmd", package = "edgeTransport"),
Expand Down
50 changes: 49 additions & 1 deletion inst/Rmd/report.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ plotCost(costs = techcost, vt = "Passenger Rail_tmp_vehicletype")
```
# ES validation for selected categories and regions

## Passenger transport in DEU 2018
## Passenger transport in DEU 2018 - Verkehr-in-Zahlen

```{r, echo=FALSE, warning=FALSE, message=FALSE}

Expand Down Expand Up @@ -1786,3 +1786,51 @@ ViZ,LDV, 913.3

es_deu_verkehrinzahlen(demandkm)
```

## Vehicle numbers in the EU - ACEA

```{r, echo=FALSE, warning=FALSE, message=FALSE}
vn_eu_acea <- function(demand_km, loadFactor, annual_mileage){

all_eu <- c(EU_regions, NEU_regions)

## vkm
demand_vkm <- merge(demand_km, loadFactor,
by=colnames(demand_km)[2:ncol(demand_km)])
demand_vkm[, demandVKM := demand_F/loadFactor]
nas <- demand_vkm[is.na(demandVKM)]
if(length(nas)){
warning(sprintf("Missing demand for %s", unique(nas$vehicle_type)))
}
demand_vkm <- demand_vkm[!is.na(demandVKM)]

## mileage
demand_vkm <- merge(demand_vkm, annual_mileage,
by=colnames(demand_km)[2:ncol(demand_km)])
no_mileage <- demand_vkm[is.na(vkm.veh) | vkm.veh == 0]
if(length(no_mileage)){
warning(sprintf("Missing demand for %s", unique(no_mileage$vehicle_type)))
}
demand_vkm[, veh_num := demandVKM/vkm.veh]

aceadt <- rbindlist(list(
fread("acea_cars.csv")[, group:="cars"],
fread("acea_lcm.csv")[, group:="lcv"],
fread("acea_trucks.csv")[, group:="trucks"]
))

mapping_TRACCS_iso= fread(
system.file(
"extdata", "mapping_countries_EU.csv", package="edgeTransport"), skip=0)
aceadt <- merge(aceadt, mapping_TRACCS_iso, by.x="country", by.y="country_name")

demand_eu <- demand_vkm[region %in% aceadt$iso]

## apply ACEA classification
demand_eu[subsector_L2 == "trn_pass_road_LDV", group := "cars"]
demand_eu[subsector_L3 == "trn_freight_road" & vehicle_type == "Truck (0-3.5t)", group := "lcv"]
demand_eu[subsector_L3 == "trn_freight_road" & vehicle_type != "Truck (0-3.5t)", group := "trucks"]


}
```