---
title: "VEIN model"
author: "Sergio Ibarra-Espinosa"
date: "22 de abril de 2017"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

[![Travis-CI Build Status](https://travis-ci.org/atmoschem/vein.svg?branch=master)](https://travis-ci.org/atmoschem/vein)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/ibarraespinosa/vein?branch=master&svg=true)](https://ci.appveyor.com/project/ibarraespinosa/vein)
[![](http://cranlogs.r-pkg.org/badges/vein)](http://cran.rstudio.com/web/packages/vein/index.html)
[![Rdoc](http://www.rdocumentation.org/badges/version/vein)](http://www.rdocumentation.org/packages/vein)
[![DOI](https://zenodo.org/badge/88201850.svg)](https://zenodo.org/badge/latestdoi/88201850)
[![Coverage Status](https://img.shields.io/codecov/c/github/atmoschem/vein/master.svg)](https://codecov.io/github/atmoschem/vein?branch=master)



![](https://raw.githubusercontent.com/atmoschem/vein/master/logovein_small.png)



## Vein Package

**V**ehicular **E**missions **IN**ventory **(VEIN)** model.

_Please read the documentation_.

### System requirements

vein imports functions from spatial packages listed below. In order to
install these packages, firstly the user must install the requirements
mentioned [here](https://www.github.com/r-spatial/sf).

### Packages needed

After installing system dependencies, you need these packages:

- [sf](https://github.com/r-spatial/sf)
- [sp](https://github.com/edzer/sp/) 
- [units](https://github.com/edzer/units/) 

In order to run the demo, this package is also needed:

- [ggplot2](https://github.com/tidyverse/ggplot2)


### Installation

VEIN can be installed via CRAN or github

```{r eval = F}
# 0.3.9 Reaching the puberty   
library(devtools) 
install_github("atmoschem/vein")
library(vein)
demo(VEIN)
```

or

```{r eval=F}
# 0.2.3
install.packages("vein")
library(vein)
```

## What is new on 0.3.0 ?

I decided to jump into a new 'minor' version because it brings lots of cool
improvements.

- vein imports **sf** functions.
- R packages -raster-, -rgdal- and -rgeos- not needed anymore.
- vein now imports **data-table**.
- Add class GriddedEmissionsArray.
- Fix #28, data.table imported in emis_grid. Now it is very fast!
- Fix #49: Documentation in inventory est.
- Fix #50: Fix repetition of x_DF.
- Fix #51: deparse text.
- Fix #52: separate objects in rm with ','
- Fix #55.
- Minor fix on demo(VEIN).
- emis and emis_cold adjust length of ef by length of columns of first
element of the list of data-frames.
- Revised all examples.

Check the [NEWS](https://github.com/atmoschem/vein/blob/master/NEWS.md)


### How to use vein

VEIN consist of: "Elaboration of vehicular emissions inventories,
    consisting in four stages, pre-processing activity data, preparing 
    emissions factors, estimating the emissions and post-processing of emissions 
    in maps and databases."


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`.**

```{r eval = T}
library(vein)
inventory(name = file.path(tempdir(), "YourCity"), show.dir = T,
          show.scripts = T)
```

Please, read the examples in the documentation of each function and run the demo. 


###  Issues

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.

Thanks and enjoy VEIN!

### **future steps**

- Add more support to sf.
- Estimation of evaporative emissions with Copert Tier 3.
- More speciations.
- A book (hopefully released in 2018).

#### Note:
The paper of vein on GMDD under open review. If you use VEIN, please, cite it:

Ibarra-Espinosa, S., Ynoue, R., O'Sullivan, S., Pebesma, E.,
  Andrade, M. D. F., and Osses, M. (2017). VEIN v0.2.2: an R
  package for bottom-up Vehicular Emissions Inventories Geosci.
  Model Dev. Discus, https://doi.org/10.5194/gmd-2017-193, in
  review, 2017.

https://doi.org/10.5194/gmd-2017-193
