You can learn more about VEIN reading the documentation in PDF, online, reading the book online, or buy it in Kindle or Paperback
Vehicular Emissions Inventories. An R package to estimate vehicular emissions. It currently covers the following pollutants in speed functions:
vein imports functions from spatial packages listed below. In order to install these packages, firstly the user must install the requirements mentioned here.
After installing system dependencies, you will need these packages:
In order to run the demo, this package is also needed:
VEIN can be installed via CRAN or github
library(devtools)
install_github("atmoschem/vein")
library(vein)
demo(VEIN)
or
install.packages("vein")
library(vein)
demo(VEIN)
future steps:
VEIN consist of: “Elaboration of vehicular emissions inventories, consisting in four stages:
This implies the use of several functions in a coordinates ans structured way, therefore it is added the new function inventory which creates a structured set of directories and scripts to run VEIN. Please, open the file ‘main.R’ and run each line to understand VEIN. Remember, if you have doubts with any function, just type ‘?’ with the name of the function. For intance: ?inventory
.
Using inventory
library(vein)
inventory(name = file.path(tempdir(), "YourCity"),
vehcomp = c(PC = 1, LCV = 1, HGV = 1, BUS = 1, MC = 1),
show.dir = T,
show.scripts = T)
files at /tmp/RtmpEorTs8/YourCity
Directories:
[1] "/tmp/RtmpEorTs8/YourCity"
[2] "/tmp/RtmpEorTs8/YourCity/ef"
[3] "/tmp/RtmpEorTs8/YourCity/emi"
[4] "/tmp/RtmpEorTs8/YourCity/emi/BUS_01"
[5] "/tmp/RtmpEorTs8/YourCity/emi/HGV_01"
[6] "/tmp/RtmpEorTs8/YourCity/emi/LCV_01"
[7] "/tmp/RtmpEorTs8/YourCity/emi/MC_01"
[8] "/tmp/RtmpEorTs8/YourCity/emi/PC_01"
[9] "/tmp/RtmpEorTs8/YourCity/est"
[10] "/tmp/RtmpEorTs8/YourCity/images"
[11] "/tmp/RtmpEorTs8/YourCity/network"
[12] "/tmp/RtmpEorTs8/YourCity/post"
[13] "/tmp/RtmpEorTs8/YourCity/post/df"
[14] "/tmp/RtmpEorTs8/YourCity/post/grids"
[15] "/tmp/RtmpEorTs8/YourCity/post/streets"
[16] "/tmp/RtmpEorTs8/YourCity/profiles"
[17] "/tmp/RtmpEorTs8/YourCity/veh"
Scripts:
[1] "est/BUS_01_input.R"
[2] "est/HGV_01_input.R"
[3] "est/LCV_01_input.R"
[4] "est/MC_01_input.R"
[5] "est/PC_01_input.R"
[6] "main.R"
[7] "post.R"
[8] "traffic.R"
Please, read the examples in the documentation of each function and run the demo.
age functions:
data("net")
PC_E25_1400 <- age_ldv(x = net$ldv, name = "PC_E25_1400")
plot(PC_E25_1400, xlab = "age of use")
If you want to know the vehicles per street and by age of use, just add the net. Age functions now returns ‘sf’ objects if the net argument is present.
PC_E25_1400net <- age_ldv(x = net$ldv, name = "PC_E25_1400", net = net)
plot(PC_E25_1400net)
temporal factors and netspeed
data("net")
data("pc_profile")
pc_week <- temp_fact(net$ldv+net$hdv, pc_profile)
dfspeed <- netspeed(pc_week, net$ps, net$ffs, net$capacity, net$lkm, alpha = 1.5)
plot(dfspeed)
If you want ot check the speed at different hours by street, just add net:
dfspeednet <- netspeed(pc_week, net$ps, net$ffs, net$capacity, net$lkm,
alpha = 1.5, net = net)
sp::spplot(as(dfspeednet, "Spatial"),
c("S1", "S9"), scales = list(Draw = T),
col.regions = rev(cptcity::cpt()))
V <- 0:150
ef1 <- ef_ldv_speed(v = "PC",t = "4S", cc = "<=1400", f = "G", eu = "PRE",
p = "CO")
efs <- EmissionFactors(ef1(1:150))
plot(Speed(1:150), efs, xlab = "speed[km/h]", type = "b", pch = 16)
euro <- c(rep("V", 5), rep("IV", 5), rep("III", 5), rep("II", 5),
rep("I", 5), rep("PRE", 15))
lef <- lapply(1:40, function(i) {
ef_ldv_speed(v = "PC", t = "4S", cc = "<=1400", f = "G",
eu = euro[i], p = "CO", show.equation = FALSE) })
E_CO <- emis(veh = PC_E25_1400, lkm = net$lkm, ef = lef, speed = dfspeed,
profile = pc_profile)
#plot(E_CO, xlab = "Hours", ylab = "[g/h]")
E_CO_DF <- emis_post(arra = E_CO, veh = "PC", size = "<1400", fuel = "G",
pollutant = "CO", by = "veh")
E_CO_STREETS <- emis_post(arra = E_CO, pollutant = "CO", by = "streets_wide")
You can use this function in two ways
when spobj is “character”, it is a path to wrfinput file and then runs eixport::wrf_grid to create a grid based on a wrf_input file.
make_grid
.The spobj is the spatial net. The size of the grid has the size of the net. You have to specify the grid spacing.data(net)
E_CO_STREETSnet <- emis_post(arra = E_CO, pollutant = "CO", by = "streets_wide",
net = net)
g <- make_grid(net, 1/102.47/2) #500m in degrees
plot(g)
E_CO_g <- emis_grid(spobj = E_CO_STREETSnet, g = g, sr= 31983)
#sp::spplot(as(E_CO_g, "Spatial"),
# c("V1", "V9"), scales = list(Draw = T),
# col.regions = rev(cptcity::cpt()))
At this step, you can feed you grid with emissions from other sources!
eixport::wrf_create(wrfinput_dir = "PathToWrfInput", wrfchemi_dir = "OutputPathWrfChemInput")
gwrf <- eixport::wrf_grd("PathToWrfInput")
E_CO_gwrf <- emis_grid(spobj = E_CO_STREETSnet, g = gwrf)
gr <- GriddedEmissionsArray(E_CO_gwrf, rows = 19, cols = 23, times = 168, T)
eixport::wrf_put(file = "Path/To/WRFChemInputFile, name = "E_CO", POL = gr)
Thanks and enjoy VEIN!
If you use VEIN, please, cite it (BIBTEX, ENDNOTE):
Ibarra-Espinosa, S., Ynoue, R., O’Sullivan, S., Pebesma, E., Andrade, M. D. F., and Osses, M.: VEIN v0.2.2: an R package for bottom-up vehicular emissions inventories, Geosci. Model Dev., 11, 2209-2229, https://doi.org/10.5194/gmd-11-2209-2018, 2018.
@article{gmd-11-2209-2018,
author = {Ibarra-Espinosa, S. and Ynoue, R. and O'Sullivan, S. and Pebesma, E. and Andrade, M. D. F. and Osses, M.},
title = {VEIN v0.2.2: an R package for bottom--up vehicular emissions inventories},
journal = {Geoscientific Model Development},
volume = {11},
year = {2018},
number = {6},
pages = {2209--2229},
url = {https://www.geosci-model-dev.net/11/2209/2018/},
doi = {10.5194/gmd-11-2209-2018}
}
If you encounter any issues while using VEIN, please submit your issues to: https://github.com/atmoschem/vein/issues/
If you have any suggestions just let me know to sergio.ibarra@usp.br.
Please, read this guide. Contributions of all sorts are welcome, issues and pull requests are the preferred ways of sharing them. When contributing pull requests, please follow the Google’s R Style Guide. This project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.