
\subsection{Results and Discussion}

%\subsection*{Emission Estimates}

After inputting the database of vehicles and their respective emission factors, VEIN is ready to use the \textit{emis} function. The VEIN package counts with several \textit{emis} functions according to the type of emission being estimated. The \textit{emis} function assembles data and outputs from other VEIN functions and estimates the emissions for the number of hours and days in the week. This function reads the morning rush hour traffic data by age of vehicle use and extrapolates it with the profile data-frame, as previously explained. 
It reads the emission factors stored in a list with length matching the age distribution of the vehicle category and then reads the list of speeds. This function returns the emissions at each street in an array with 4 dimensions: 1) number of streets;
2) max age of age distribution; 3) hours (usually 24); and 4) days (usually 7). 

For example, an estimation of the traffic simulations of Figure \ref{fig:ldv} with 1505 streets, fleet of 41 years age distribution, 24 hours of the day, 7 days of the week will produce an emissions array with dimensions 1505, 41, 24 and 7. 
The vehicle fleet used to produce the age distribution shown in green of Figure \ref{fig:ages} has 41 years of length.% The VEIN model requires that the emission factors and fleet have the same length, vehicle categories must match.
	
	\begin{verbatim}
	data(pc_profile)
E_CO <- emis(veh = pc1,
  lkm = net$lkm, ef = lef, speed = speed, 
  agemax = 41, profile = pc_profile, 
  hour = 24, day = 7, array = TRUE)

	\end{verbatim}
	
	This emissions array output for 1505 streets and vehicle fleet with 41 years age distribution,  24 hours and 7 days of the week, has the size of 82.9 Mb. 
    Hence, it is recommended to use the function \textit{emis\_post} and then delete the original emissions array. The arguments include: the emissions array, type of vehicle, size or weight, fuel, pollutant, and \textit{by}. The \textit{emis\_post} function was created to preserve the most important information in the emissions array, to use less memory size and to be compatible with the packages 'sp' \citep{sp2} and 'ggplot2' \citep{ggplot2}. VEIN outputs could also be used with the package 'openair' \cite{carslaw2012openair}. \textit{emis\_post} returns a data-frame, but the argument \textit{by} determines the shape of the data-frame. 
    When \textit{by} has the value 'veh', it returns a data-frame with an aggregation of the emissions array by each age of vehicle use with columns: vehicle name, emission (in grams), vehicle type, size, fuel, pollutant, age, hour and day. This output allows the user to visualize hourly emissions at each day of the week, as shown in Figure \ref{fig:emis_hour}. 
    %This Figure shows CO emissions of passenger cars with VEIN data \textit{net}, \textit{pc\_profile}, \textit{fkm} and \textit{fe2015}. This provides detailed information to authorities who aim to restrict vehicular emissions with high temporal detail. %The Supplementary Material shows an example of VEIN estimating emissions and generating Figures of this paper.
	
	\begin{figure}[H]
		\centering
		\includegraphics[width=15cm]{figures/emis_hour.png}
		\caption{Emissions of CO $g \cdot h^{-1}$ for LDV.}
		\label{fig:emis_hour}
	\end{figure}
	
	VEIN enables the user to identify which type of vehicle emits more by age of use. This is particularly useful for environmental authorities who aim to reduce local traffic emissions and restrict the circulation of high emitter vehicles. Figure \ref{fig:emis_age} shows the CO emissions of gasoline fueled light duty vehicles (LDV = passenger cars + light commercial vehicles) by age of vehicle use. The average age of these vehicles is 15.17 years, as denoted by the green curve in Figure \ref{fig:ages}. The total number of vehicles is 1946955 (between 8 and 9 LT, on a Monday). 
    The total CO emissions is 18816.43 $t \cdot y^{-1}$, considering a year of 52 weeks, but the emissions are concentrated for the vehicles between 20 and 23 years of use, with 8256.243 $t \cdot y^{-1}$ representing 43\%. 
    During those years, the emissions standard was PROCONVE L2, equivalence with Euro 1 (see Table \ref{tab:euro}) and also the introduction of the catalytic system in Brazil. Therefore, the high emissions are due to deteriorated vehicles. 
    This information is useful for reducing air pollution, thus supporting the aims of environmental planners and local authorities.
	
	\begin{figure}[H]
		\centering
		\includegraphics[width=15cm]{figures/emis_age.png}
		\caption{Emissions of CO $t \cdot y^{-1}$ for LDV by age of use.}
		\label{fig:emis_age}
	\end{figure}
	
%\subsubsection*{Post emission}
    
	The estimation of emissions in spatial dimensions is an important feature of VEIN. This is accomplished by using the function \textit{emis\_post} with the argument \textit{by} equal to 'streets\_narrow' or 'streets\_wide'. Both options return a data-frame with different characteristics. When \textit{by} is equal to 'streets\_narrow', it returns a data-frame with four columns: id (indicating the number of row),  emissions,  hour and day of the week. The number of rows in the data-frame is the original number of selected streets multiplied by the hours and days of the week. For example, when there are 1505 streets, 24 hours and 7 days of the week, it returns a data-frame with 252840 rows having a size of 5.8 Mb. This option is useful for plotting the temporal behavior of specific streets with 'ggplot2' \citep{ggplot2} or 'ggmap' \citep{ggmap}. 
    
	In most cases, users will be interested when the argument \textit{by} is equal to 'streets\_wide'. This produces a data-frame with number of rows matching number of streets for the domain and number of columns as hours. Figure \ref{fig:emis_street} shows the CO g $\cdot h^{-1}$ emissions for LDV at each street on a Friday at 19:00 hours. 
	
	\begin{verbatim}
E_CO_STREETS <- emis_post(E_CO, "CO", 
  by = "streets_wide")
  net@data <- cbind(net@data, E_CO_STREETS)

	\end{verbatim}
	
	The emissions are concentrated in two streets, a motorway and a trunk street at the northern part of the emissions map. This image was generated with the function 'spplot' in the package 'sp'.%, as explained in the supplementary material.  
	
	
	\begin{figure}[H]
		\centering
		\includegraphics[trim=1.3cm 0cm 0cm 1cm,clip=true,width=15cm]{figures/emis_street.png}
		\caption{Emissions of CO $g \cdot h^{-1}$ for LDV, Friday 19:00.}
		\label{fig:emis_street}
	\end{figure}
	
	
	Figure \ref{fig:emis_street} also shows a rectangular grid, which can be used for allocating the emissions. This grid was created with the function \textit{make\_grid}, which has the arguments, \textit{width}, \textit{height} and a boolean argument \textit{polygon}. When the argument 'polygon' is TRUE, it returns a {\tt SpatialPolygonsDataFrame}. When it is FALSE, it returns a {\tt SpatialGridDataFrame}. The units of 'width' and 'height' depend on the coordinate reference systems of the data. In the following chunk of code, the values 0.049 represent approximately 500 m in lat/lon degrees distance.
	
	The allocation of emissions in each grid cell is produced by a spatial interception between the emissions at each street and the polygon-grid. The arguments of these functions are the {\tt SpatialLinesDataFrame} object, the grid, the spatial reference for projecting the data to planar coordinates, and the type 'lines' or 'points'. This is performed with the function \textit{emis\_grid}, which is able to perform several tasks. These tasks include the calculation for the length of road at each street link with the function 'gLength' in the package 'rgeos'. \citep{rgeos} imports the function 'intersect' in the package 'raster' \citep{raster} and returns the original grid with the data-frame for the respective emissions at each cell. This is the sum of emissions for the streets inside the grid cell. These functions require that all columns of the streets be numeric. Figure \ref{fig:emis_grid} shows the emissions grid for the same area, including the original road network. The grid in Figure \ref{fig:emis_grid} is the same as Figure \ref{fig:emis_street}, with resolution of 500 m. By comparing Figures \ref{fig:emis_street} and \ref{fig:emis_grid}, one can observe that they have the same spatial pattern of emissions with higher emissions at the northeastern part of the city center. This is due to the motorways and trunk roads.
	
	\begin{verbatim}
		g <- make_grid(net,0.0049,0.0049,T)
		E_CO_g <- emis_grid(net,
		g,"+init=epsg:31983", "lines")
	\end{verbatim}
	
It is recommended that function \textit{emis\_post} be used with the argument 'by = streets\_wide', in order to return a data-frame with hourly emissions for each street. This output can be used with the functions \textit{emis\_grid} to create an emissions grid map, as shown in Figure \ref{fig:emis_grid}. This is particularly helpful when the user plans to use the data to construct inputs for air quality models	
	
	\begin{figure}[h]
		\centering
\includegraphics[trim=1.3cm 0cm 0cm 1cm,clip=true,width=15cm]{figures/emis_grid.png}
		\caption{Emissions of CO $g \cdot h^{-1}$ of LDV, Friday 19:00, 0.5 x 0.5 km$^2$.}
		\label{fig:emis_grid}
	\end{figure}
	
% \subsubsection*{VOC and PM speciation}

	Atmospheric simulations of ozone require knowledge about the compounds of the emitted Volatile Organic Compounds (VOC), that are necessary for the different chemical mechanisms. For example, a São Paulo study of ozone concentrations using models BRAMS/SPM \citep{edmilson} and WRF/Chem \citep{grell2005fully}, involved detailed VOC speciation \citep{Andrade2015}. It is important to mention that there is evidence to prove that reducing Black Carbon emissions would help to lower the Global Radiative Forcing and improve population health \citep{bc}. Hence, the speciation of emissions is important and VEIN provides this information. The VEIN function \textit{speciate} splits VOC and PM into their constituents. The arguments of these functions are: emissions estimation, type of speciation, type of vehicle, fuel and Euro Standard. There are four types of PM speciation: 'bcom' \citep{copert}, 'tyre', 'break', and 'road' \citep{wear}, however, there is only one type of VOC speciation: 'iag' \citep{sameh}. For PM, the default speciation is 'bcom', which splits the exhaust emissions into black carbon and organic matter. 
 
% \subsubsection*{Input of atmospheric models}
    
 Emissions inventories are used as an input for air quality models. The VEIN model provides functions to produce data that can be used as inputs for atmospheric models. \cite{Angel2015} presented a system for assimilating anthropogenic emissions (AAS4WRF) into the WRF-Chem model. AAS4WRF consists of a NCL \citep{ncl} script that reads a text file in long format and a WRFinput header for the desired domain. The VEIN model provides the function \textit{emis\_wrf} to automatically create a data-frame in the correct format with columns longitude, latitude, id of grid cell, pollutants, local time and GMT time in format POSIXct. 
 The arguments of \textit{emis\_wrf} are \textit{sdf}, which is a list of {\tt SpatialPolygonsDataFrames}, one per pollutant.  
 \textit{nr} indicates how many times the hours of estimations will be repeated. %For instance, if the emissions inventory covers one week and \textit{nr} is 2, the data-frame will cover 2 weeks.
 \textit{dmyhm} indicates the day, month, year, hour and minute of the first hour of emissions in local time.
 \textit{tz} is the time-zone and \textit{utc} indicates the difference in hours between local and GMT time. \textit{islist} indicates if the first argument, \textit{df} is a list (islist=TRUE) or a data-frame (islist=FALSE).
 
    \begin{verbatim}
E_CO_g@data <- E_CO_g@data[,-1]
ldf <- list("co"=E_CO_g)
df_wrf <- emis_wrf(ldf,nr=1,
  dmyhm = "04-08-2014 00:00",
  tz = "America/Sao_Paulo",
  utc = -3, islist = TRUE)
	\end{verbatim}
	


%\subsubsection{HEADING}
%TEXT