{"id":490,"name":"vein","description":"An R package to estimate Vehicular Emissions INventories.","url":"https://gitlab.com/ibarraespinosa/vein","last_synced_at":"2026-04-13T16:30:20.177Z","repository":{"id":56801046,"uuid":"18672162","full_name":"ibarraespinosa/vein","owner":"ibarraespinosa","description":"","archived":false,"fork":false,"pushed_at":null,"size":null,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":null,"default_branch":"master","last_synced_at":"2026-01-08T17:24:20.174Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":null,"metadata":{},"created_at":"2020-05-09T01:23:33.840Z","updated_at":"2023-06-01T05:32:44.992Z","dependencies_parsed_at":"2022-08-22T19:31:01.655Z","dependency_job_id":null,"html_url":"https://gitlab.com/ibarraespinosa/vein","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:gitlab/ibarraespinosa/vein","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners/ibarraespinosa","download_url":"https://gitlab.com/ibarraespinosa/vein/-/archive/master/vein-master.zip","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein/sbom","scorecard":null,"host":{"name":"gitlab.com","url":"https://gitlab.com","kind":"gitlab","repositories_count":4521539,"owners_count":7348,"icon_url":"https://github.com/gitlab.png","version":null,"created_at":"2022-05-30T11:31:42.605Z","updated_at":"2026-01-12T22:45:04.389Z","status":"online","status_checked_at":"2026-03-27T02:00:08.384Z","response_time":261,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.382Z","robots_txt_url":"https://gitlab.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners"}},"owner":{"login":"ibarraespinosa","name":"Sergio Ibarra Espinosa","uuid":"user-2208081","kind":"user","description":"","email":null,"website":"","location":"Boulder, Colorado","twitter":null,"company":null,"icon_url":"https://gitlab.com/uploads/-/system/user/avatar/2208081/avatar.png","repositories_count":14,"last_synced_at":"2023-05-27T08:01:06.951Z","metadata":{},"html_url":"https://gitlab.com/ibarraespinosa","funding_links":[],"total_stars":null,"followers":null,"following":null,"created_at":"2023-05-27T08:01:07.018Z","updated_at":"2023-05-27T08:01:07.018Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners/ibarraespinosa","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners/ibarraespinosa/repositories"},"packages":[],"commits":{"id":1638835,"full_name":"ibarraespinosa/vein","default_branch":"master","total_commits":218,"total_committers":2,"total_bot_commits":0,"total_bot_committers":0,"mean_commits":109.0,"dds":0.14220183486238536,"past_year_total_commits":0,"past_year_total_committers":0,"past_year_total_bot_commits":0,"past_year_total_bot_committers":0,"past_year_mean_commits":0.0,"past_year_dds":0.0,"last_synced_at":"2026-04-10T15:15:26.102Z","last_synced_commit":"1ab93fe35ae528855d53c1fe948e610d66b85bee","created_at":"2024-07-24T20:00:47.225Z","updated_at":"2026-04-10T15:15:25.849Z","committers":[{"name":"ibarraespinosa","email":"sergio.ibarra@usp.br","login":null,"count":187},{"name":"Sergio Ibarra Espinosa","email":"zergioibarra@gmail.com","login":null,"count":31}],"past_year_committers":[],"commits_url":"https://commits.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein/commits","host":{"name":"gitlab.com","url":"https://gitlab.com","kind":"gitlab","last_synced_at":"2026-04-12T00:00:14.559Z","repositories_count":23879,"commits_count":4153701,"contributors_count":114301,"owners_count":12293,"icon_url":"https://github.com/gitlab.png","host_url":"https://commits.ecosyste.ms/api/v1/hosts/gitlab.com","repositories_url":"https://commits.ecosyste.ms/api/v1/hosts/gitlab.com/repositories"}},"issues_stats":{"full_name":"ibarraespinosa/vein","html_url":"https://gitlab.com/ibarraespinosa/vein","last_synced_at":"2026-04-10T15:02:38.288Z","status":"error","issues_count":null,"pull_requests_count":null,"avg_time_to_close_issue":null,"avg_time_to_close_pull_request":null,"issues_closed_count":null,"pull_requests_closed_count":null,"pull_request_authors_count":null,"issue_authors_count":null,"avg_comments_per_issue":null,"avg_comments_per_pull_request":null,"merged_pull_requests_count":null,"bot_issues_count":null,"bot_pull_requests_count":null,"past_year_issues_count":null,"past_year_pull_requests_count":null,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":null,"past_year_pull_requests_closed_count":null,"past_year_pull_request_authors_count":null,"past_year_issue_authors_count":null,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":null,"past_year_bot_pull_requests_count":null,"past_year_merged_pull_requests_count":null,"created_at":"2024-08-09T03:30:39.151Z","updated_at":"2026-04-10T15:02:38.289Z","repository_url":"https://issues.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein","issues_url":"https://issues.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/ibarraespinosa%2Fvein/issues","issue_labels_count":{"improve":2},"pull_request_labels_count":{},"issue_author_associations_count":{},"pull_request_author_associations_count":{},"issue_authors":{"ibarraespinosa":10},"pull_request_authors":{},"host":{"name":"gitlab.com","url":"https://gitlab.com","kind":"gitlab","last_synced_at":"2026-04-12T00:00:13.248Z","repositories_count":0,"issues_count":0,"pull_requests_count":0,"authors_count":61892,"icon_url":"https://github.com/gitlab.png","host_url":"https://issues.ecosyste.ms/api/v1/hosts/gitlab.com","repositories_url":"https://issues.ecosyste.ms/api/v1/hosts/gitlab.com/repositories","owners_url":"https://issues.ecosyste.ms/api/v1/hosts/gitlab.com/owners","authors_url":"https://issues.ecosyste.ms/api/v1/hosts/gitlab.com/authors"},"past_year_issue_labels_count":{},"past_year_pull_request_labels_count":{},"past_year_issue_author_associations_count":{},"past_year_pull_request_author_associations_count":{},"past_year_issue_authors":{},"past_year_pull_request_authors":{},"maintainers":[],"active_maintainers":[]},"events":null,"keywords":[],"dependencies":[{"ecosystem":"cran","filepath":"DESCRIPTION","sha":null,"kind":"manifest","created_at":"2022-08-22T19:31:01.485Z","updated_at":"2022-08-22T19:31:01.485Z","repository_link":"https://gitlab.com/ibarraespinosa/vein/blob/master/DESCRIPTION","dependencies":[{"id":2299712451,"package_name":"R","ecosystem":"cran","requirements":"\u003e= 3.5.0","direct":true,"kind":"depends","optional":false},{"id":2299712452,"package_name":"sf","ecosystem":"cran","requirements":"\u003e= 1.0.1","direct":true,"kind":"imports","optional":false},{"id":2299712453,"package_name":"data.table","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712454,"package_name":"units","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712455,"package_name":"graphics","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712456,"package_name":"stats","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712457,"package_name":"dotCall64","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712458,"package_name":"cptcity","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712459,"package_name":"fields","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712460,"package_name":"grDevices","ecosystem":"cran","requirements":"*","direct":true,"kind":"imports","optional":false},{"id":2299712461,"package_name":"knitr","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false},{"id":2299712462,"package_name":"rmarkdown","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false},{"id":2299712463,"package_name":"testthat","ecosystem":"cran","requirements":"*","direct":true,"kind":"suggests","optional":false}]}],"score":2.3025850929940455,"created_at":"2023-09-11T11:54:34.845Z","updated_at":"2026-04-13T16:30:20.178Z","avatar_url":null,"language":null,"category":"Emissions","sub_category":"Emission Observation and Modeling","monthly_downloads":0,"total_dependent_repos":0,"total_dependent_packages":0,"readme":"\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\u003c!-- date: \"19 de Octubre de 2016\" --\u003e\n\n# VEIN \u003cimg src=\"man/figures/logo.png\" align=\"right\" alt=\"\" width=\"220\" /\u003e\n\n- build: [![AppVeyor Build\n  Status](https://ci.appveyor.com/api/projects/status/github/ibarraespinosa/vein?branch=master\u0026svg=true)](https://ci.appveyor.com/project/ibarraespinosa/vein)\n  [![Coverage\n  Status](https://img.shields.io/codecov/c/github/atmoschem/vein/master.svg)](https://codecov.io/github/atmoschem/vein?branch=master)\n- cran:\n  [![](http://cranlogs.r-pkg.org/badges/vein)](http://cran.rstudio.com/web/packages/vein/index.html)\n  [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/vein)](http://cran.r-project.org/web/packages/vein)\n  [![CRAN\n  Downloads](http://cranlogs.r-pkg.org/badges/grand-total/vein?color=orange)](http://cran.r-project.org/package=vein)\n  [![Package\n  Status](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)\n  ![CRAN/METACRAN](https://img.shields.io/cran/l/vein?style=plastic)\n- doi:\n  [![DOI](https://zenodo.org/badge/88201850.svg)](https://zenodo.org/badge/latestdoi/88201850)\n- github: [![Github\n  Stars](https://img.shields.io/github/stars/atmoschem/vein.svg?style=social\u0026label=Github)](https://github.com/atmoschem/vein)\n  ![GitHub code size in\n  bytes](https://img.shields.io/github/languages/code-size/atmoschem/vein)\n  ![GitHub issues](https://img.shields.io/github/issues/atmoschem/vein)\n  \u003c!-- ![Liberapay giving](https://img.shields.io/liberapay/gives/sergio.ibarra) --\u003e\n  ![GitHub commit\n  activity](https://img.shields.io/github/commit-activity/y/ibarraespinosa/vein)\n  [![R build\n  status](https://github.com/atmoschem/vein/workflows/R-CMD-check/badge.svg)](https://github.com/atmoschem/vein/actions)\n\n\u003c!-- ![](https://github.com/atmoschem/vein/raw/master/all_comp.gif) --\u003e\n\n# **V**ehicular **E**missions **IN**ventories (VEIN)\n\n![vein](https://user-images.githubusercontent.com/27447280/234115392-b1c891ff-474d-40a3-b9a7-e816ded9bc70.gif)\n\n### TODO\n\n- get_project with Chinese EF\n- Include speed functions with Fortran\n- Include CB6\n- Add EF from HBEFA?\n- See issues [GitHub](https://github.com/atmoschem/vein/issues) and\n  [GitLab](https://gitlab.com/ibarraespinosa/vein/-/issues)\n\n### System requirements\n\nvein imports functions from spatial packages listed below. In order to\ninstall these packages, firstly the user must install the requirements\nmentioned [here](https://www.github.com/r-spatial/sf).\n\n### Installation\n\n#### CRAN\n\nVEIN can be installed via CRAN or github\n\n``` r\ninstall.packages(\"vein\")\n```\n\n#### GitHub\n\n``` r\nremotes::install_github(\"atmoschem/vein\")\n```\n\nor if you have a **32 bits** machine\n\n``` r\ninstall_github(\"atmoschem/vein\",\nINSTALL_opts = \"--no-multiarch\")\n```\n\n------------------------------------------------------------------------\n\n#### demo\n\nThen, if you want, run the demo\n\n``` r\nlibrary(vein) \ndemo(VEIN)\n```\n\n### \n\n## Approaches\n\n### 1. get a project (easier)\n\nAt the moment, most of the projects covers Brazilian regions, but I will\ninclude China, Europe or USA approaches as soon as I can.\n\nUse the function\n[get_project](https://atmoschem.github.io/vein/reference/get_project.html)\nand read the documentation, there you can see more projects as well.\n\nCheck the projects here:\n(\u003chttps://atmoschem.github.io/vein/reference/get_project.html\u003e)\\[\u003chttps://atmoschem.github.io/vein/reference/get_project.html\u003e\\]\n\n``` r\nlibrary(vein)\n?get_project\nget_project(directory = \"awesome_city\")\n```\n\nThe structure of the new directory “awesome_city” is:\n\n``` r\nawesome_city\n├── config\n│   ├── clean.R\n│   ├── config.R\n│   ├── inventory.xlsx\n│   └── packages.R\n├── main.R\n├── main.Rproj\n├── network\n│   ├── net.gpkg\n│   └── net.rds\n├── scripts\n│   ├── evaporatives.R\n│   ├── exhaust.R\n│   ├── fuel_eval.R\n│   ├── net.R\n│   ├── pavedroads.R\n│   ├── plots.R\n│   ├── post.R\n│   ├── traffic.R\n│   └── wrf.R\n└── wrf\n└── wrfinput_d02\n```\n\nYou have to open the file `main.Rproj` with Rstudio and then open and\nrun `main.R`\n\nTo run `main.R` you will need these extra packages:\n\n- ggplot2\n- readxl\n- eixport (If you plan to generate WRF Chem emissions file)\n\nIf you do not have them already, you can install:\n\n``` r\ninstall.packages(c(\"ggplot2\", \"readxl\", \"eixport\"))\n```\n\n## Too complicated? Watch a YouTube\n\n\u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/tHSWIjg26vg\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\n\u003c/iframe\u003e\n\n[English](https://www.youtube.com/embed/tHSWIjg26vg)\n\n\u003ciframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/6-07Y0Eimng\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen\u003e\n\u003c/iframe\u003e\n\n[Portuguese](https://www.youtube.com/watch?v=6-07Y0Eimng)\n\n### 2. Use inventory (a bit not so easy)\n\nRead the instruction of inventory\n\n``` r\n?inventory\n```\n\n#### 1) Examples with traffic data:\n\n1.  If you know the distribution of the vehicles by age of use , use:\n    [my_age](https://atmoschem.github.io/vein/reference/my_age.html)\n2.  If you know the sales of vehicles or better the registry of new\n    vehicles, use\n    [age](https://atmoschem.github.io/vein/reference/age.html) to apply\n    a survival function.\n3.  If you know the theoretical shape of the circulating fleet and you\n    can use\n    [age_ldv](https://atmoschem.github.io/vein/reference/age_ldv.html),\n    [age_hdv](https://atmoschem.github.io/vein/reference/age_hdv.html)\n    or\n    [age_moto](https://atmoschem.github.io/vein/reference/age_moto.html).\n    For instance, you dont know the sales or registry of vehicles, but\n    somehow you know the shape of this curve.\n4.  You can use/merge/transform/adapt any of these functions.\n\n``` r\nlibrary(vein)\ndata(\"net\")\nPC_E25_1400 \u003c- age_ldv( x = net$ldv)\n\nplot(PC_E25_1400)\n#\u003e Weighted mean =  11.17\n```\n\n![](man/figures/unnamed-chunk-3-1.png)\u003c!-- --\u003e\n\nIf you want to know the vehicles per street and by age of use, just add\nthe net. Age functions now returns ‘sf’ objects if the net argument is\npresent.\n\n``` r\nPC_E25_1400net \u003c- age_ldv(\n  x = net$ldv, \n  net = net\n)\nplot(PC_E25_1400net, \n  key.pos = 4, \n  pal = cptcity::cpt(\n    colorRampPalette = T, \n    rev = T))\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e Warning: plotting the first 9 out of 50 attributes; use max.plot = 50 to plot\n#\u003e all\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n```\n\n![](man/figures/unnamed-chunk-4-1.png)\u003c!-- --\u003e\n\n- [temp_fact](https://atmoschem.github.io/vein/reference/temp_fact.html)\n- [netspeed](https://atmoschem.github.io/vein/reference/netspeed.html)\n\ntemporal factors and netspeed\n\n``` r\ndata(\"net\")\ndata(\"pc_profile\")\npc_week \u003c- temp_fact(\n  net$ldv + net$hdv, \n  pc_profile\n)\ndfspeed \u003c- netspeed(\n  q = pc_week, \n  ps = net$ps, \n  ffs = net$ffs, \n  cap = net$capacity, \n  lkm = net$lkm, \n  alpha = 1.5\n)\nplot(dfspeed)\n#\u003e Weighted mean =  44.16\n```\n\n![](man/figures/unnamed-chunk-5-1.png)\u003c!-- --\u003e\n\nIf you want ot check the speed at different hours by street, just add\nnet:\n\n``` r\ndfspeednet \u003c- netspeed(\n  q = pc_week, \n  ps = net$ps, \n  ffs = net$ffs, \n  cap = net$capacity, \n  lkm = net$lkm,\n  alpha = 1.5, \n  net = net\n)\nplot(\n  dfspeednet[, c(\"S1\", \"S9\")], \n  key.pos = 4, \n  pal = cptcity::cpt(colorRampPalette = T, \n                     rev = T), \n  axes = T\n)\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n```\n\n![](man/figures/unnamed-chunk-6-1.png)\u003c!-- --\u003e \\#### 2) Emission Factors\n\n- [ef_ldv_speed](https://atmoschem.github.io/vein/reference/ef_ldv_speed.html)\n- [ef_hdv_speed](https://atmoschem.github.io/vein/reference/ef_hdv_speed.html)\n- [ef_ldv_scaled](https://atmoschem.github.io/vein/reference/ef_ldv_scaled.html)\n- [ef_hdv_scaled](https://atmoschem.github.io/vein/reference/ef_hdv_scaled.html)\n- [EmissionFactors](https://atmoschem.github.io/vein/reference/EmissionFactors.html)\n- [EmissionFactorsList](https://atmoschem.github.io/vein/reference/EmissionFactorsList.html)\n\n``` r\nV \u003c- 0:150\nef1 \u003c- ef_ldv_speed(\n  v = \"PC\",\n  t = \"4S\", \n  cc = \"\u003c=1400\", \n  f = \"G\",\n  eu = \"PRE\",\n  p = \"CO\"\n)\nef2 \u003c- ef_ldv_speed(\n  v = \"PC\",\n  t = \"4S\", \n  cc = \"\u003c=1400\", \n  f = \"G\",\n  eu = \"III\",\n  p = \"CO\"\n)\n\nef1 \u003c- EmissionFactors(ef1(1:150))\nef2 \u003c- EmissionFactors(ef2(1:150))\ncolplot(data.frame(PRE = ef1, III = ef2))\n```\n\n![](man/figures/unnamed-chunk-7-1.png)\u003c!-- --\u003e\n\n#### 3) Estimation of emissions\n\n- [emis](https://atmoschem.github.io/vein/reference/emis.html)\n\n``` r\neuro \u003c- c(\n  rep(\"V\", 5), \n  rep(\"IV\", 5), \n  rep(\"III\", 5), \n  rep(\"II\", 5),\n  rep(\"I\", 5), \n  rep(\"PRE\", 15)\n)\nlef \u003c- lapply(1:40, function(i) {\n  ef_ldv_speed(\n    v = \"PC\", \n    t = \"4S\",\n    cc = \"\u003c=1400\", \n    f = \"G\",\n    eu = euro[i], \n    p = \"CO\", \n    show.equation = FALSE\n  ) \n})\nE_CO \u003c- emis(\n  veh = PC_E25_1400, \n  lkm = net$lkm, \n  ef = lef, \n  speed = dfspeed,\n  profile = pc_profile\n)\n```\n\n#### 4) Post Emissions\n\n- [emis_post](https://atmoschem.github.io/vein/reference/emis_post.html)\n- When the argument by = “veh” the emissions are aggregated by age and\n  hour.\n- When the argument by = “streets_wide”, aggregated the emissions by\n  street. In this cae, if you add the argument net with the respective\n  streets, it returns an spatial net with the hourly emissions.\n\n``` r\nE_CO_DF \u003c- emis_post(\n  arra = E_CO,  \n  veh = \"PC\", \n  size = \"\u003c1400\", \n  fuel = \"G\",\n  pollutant = \"CO\", \n  by = \"veh\", \n  type_emi = \"exhaust\"\n)\nE_CO_STREETS \u003c- emis_post(\n  arra = E_CO, \n  pollutant = \"CO\", \n  by = \"streets\", \n  net = net\n)\nplot(\n  E_CO_STREETS[, c(\"V1\", \"V9\")], \n  key.pos = 4, \n  pal = cptcity::cpt(colorRampPalette = T, \n                     rev = T), \n  axes = T)\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n```\n\n![](man/figures/unnamed-chunk-9-1.png)\u003c!-- --\u003e\n\n#### Grids\n\n- [make_grid](https://atmoschem.github.io/vein/reference/make_grid.html).\n\n1)  Create a grid using `make_grid`.The spobj is the spatial net. The\n    size of the grid has the size of the net. You have to specify the\n    grid spacing.\n2)  Create a grid using a path to wrfinput file instead a net. The grid\n    will have the size of the wrf_input. You don’t have to specify the\n    grid spacing.\n\n``` r\ndata(net)\nE_CO_STREETSnet \u003c- emis_post(\n  arra = E_CO, \n  pollutant = \"CO\",\n  by = \"streets_wide\",\n  net = net\n)\ng \u003c- make_grid(\n  spobj = net, \n  width = 1/102.47\n)\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e Number of lon points: 12\n#\u003e Number of lat points: 10\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\nE_CO_g \u003c- emis_grid(\n  spobj = E_CO_STREETSnet, \n  g = g, \n  sr= 31983\n)\n#\u003e Your units are:\n#\u003e g\n#\u003e Transforming spatial objects to 'sr'\n#\u003e old-style crs object detected; please recreate object with a recent sf::st_crs()\n#\u003e Sum of street emissions 148791715.29\n#\u003e Sum of gridded emissions 148791715.29\nna \u003c- paste0(\"V\", 1:168)\nfor(i in 1:168) E_CO_g[[na[i]]] \u003c- E_CO_g[[na[i]]] * units::set_units(1, \"1/h\")\nplot(\n  E_CO_g[, c(\"V1\", \"V9\")], \n  key.pos = 4, \n  pal = cptcity::cpt(colorRampPalette = T, \n                     rev = T,\n                     pal = \"mpl_viridis\"), \n  axes = T, \n  lty = 0\n)\n```\n\n![](man/figures/unnamed-chunk-10-1.png)\u003c!-- --\u003e\n\n#### Creating a WRFChem Input file using [eixport](https://atmoschem.github.io/eixport/):\n\n1.  Create a grid using\n    [make_grid](https://atmoschem.github.io/vein/reference/make_grid.html)\n    and a wrfinput file\n2.  Run\n    [emis_grid](https://atmoschem.github.io/vein/reference/emis_grid.html)\n    to grid your emissions.\n3.  Create a\n    [GriddedEmissionsArray](https://atmoschem.github.io/vein/reference/GriddedEmissionsArray.html).\n4.  Create a wrfchem input file\n    \\[eixport::wrf_create\\](\u003chttps://atmoschem.github.io/eixport/reference/wrf_create.html\u003e.\n5.  Put the\n    [GriddedEmissionsArray](https://atmoschem.github.io/vein/reference/GriddedEmissionsArray.html)\n    into the wrf chem input file using\n    [eixport::wrf_put](https://atmoschem.github.io/eixport/reference/wrf_put.html).\n\n``` r\nlibrary(eixport)\ndir.create(file.path(tempdir(), \"EMISS\"))\nwrf_create(wrfinput_dir         = system.file(\"extdata\", package = \"eixport\"),\nwrfchemi_dir         = file.path(tempdir(), \"EMISS\"),\ndomains              = 2,\nframes_per_auxinput5 = 1, #hours\nauxinput5_interval_m = 60,\nverbose              = TRUE)\npath_to_wrfi \u003c- paste0(system.file(\"extdata\", package = \"eixport\"), \"/wrfinput_d02\")\npath_to_wrfc \u003c- list.files(file.path(tempdir(), \"EMISS\"), full.names = TRUE)[1]\ngwrf \u003c- eixport::wrf_grid(path_to_wrfi)\nE_CO_gwrf \u003c- emis_grid(spobj = E_CO_STREETSnet, g = gwrf)\ngr \u003c- GriddedEmissionsArray(E_CO_gwrf, rows = 51, cols = 63, times = 1)\neixport::wrf_put(file = path_to_wrfc, name = \"E_CO\", POL = gr)\n```\n\n#### Creating a WRFChem Input file using AS4WRF\n\n1.  Create a grid using\n    [make_grid](https://atmoschem.github.io/vein/reference/make_grid.html)\n    and your net.\n2.  Run\n    [emis_grid](https://atmoschem.github.io/vein/reference/emis_grid.html)\n    to grid your emissions.\n3.  Run\n    [eixport::to_as4wrf](https://atmoschem.github.io/eixport/reference/to_as4wrf.html)\n    to create a data.frame the specifications for AS4WRF.ncl.\n4.  Export data.frame to a text.file. Recall that AS4WRF requires all\n    the lumped species.\n5.  Contact the developer of AS4WRF Angel Vara \u003calvv1986@gmail.com\u003e to\n    get a copy and run AS4WRF.ncl.\n\nThanks and enjoy VEIN!\n\n## Citation\n\nIf you use VEIN, please, cite it\n([BIBTEX](https://gmd.copernicus.org/articles/11/2209/2018/gmd-11-2209-2018.bib),\n[ENDNOTE](https://gmd.copernicus.org/articles/11/2209/2018/gmd-11-2209-2018.ris)):\n\nIbarra-Espinosa, S., Ynoue, R., O’Sullivan, S., Pebesma, E., Andrade, M.\nD. F., and Osses, M.: VEIN v0.2.2: an R package for bottom-up vehicular\nemissions inventories, Geosci. Model Dev., 11, 2209-2229,\n\u003chttps://doi.org/10.5194/gmd-11-2209-2018\u003e, 2018.\n\n    @article{gmd-11-2209-2018,\n    author = {Ibarra-Espinosa, S. and Ynoue, R. and O'Sullivan, S. and Pebesma, E. and Andrade, M. D. F. and Osses, M.},\n    title = {VEIN v0.2.2: an R package for bottom--up vehicular emissions inventories},\n    journal = {Geoscientific Model Development},\n    volume = {11},\n    year = {2018},\n    number = {6},\n    pages = {2209--2229},\n    url = {https://gmd.copernicus.org/articles/11/2209/2018/},\n    doi = {10.5194/gmd-11-2209-2018}\n    }\n\n## Special thanks to all the contributors\n\n[![Contributors](https://contrib.rocks/image?repo=atmoschem/vein)](https://github.com/atmoschem/vein/graphs/contributors)\n\n## Communications, doubts etc\n\n- Earth-Sciences on Stackoverflow, tag\n  [vein-r-package](https://earthscience.stackexchange.com/questions/tagged/vein-r-package)\n- Drop me an email \u003csergio.ibarra@usp.br\u003e or \u003czergioibarra@hotmail.com\u003e\n  (你好中国朋友 - Hello Chinese friends!)\n- Check the group on GoogleGroups\n  [Group](https://groups.google.com/d/forum/veinmodel).\n- Check the project on\n  [ResearchGate](https://www.researchgate.net/project/VEIN-An-R-package-for-vehicular-emissions-inventories).\n\n## Issues\n\nIf you encounter any issues while using VEIN, please submit your issues\nto: \u003chttps://github.com/atmoschem/vein/issues/\u003e If you have any\nsuggestions just let me know to \u003csergio.ibarra@usp.br\u003e.\n\n### Contributing\n\nPlease, read\n[this](https://github.com/atmoschem/vein/blob/master/CONTRIBUTING.md)\nguide. Contributions of all sorts are welcome, issues and pull requests\nare the preferred ways of sharing them. When contributing pull requests,\nplease follow the [Google’s R Style\nGuide](https://google.github.io/styleguide/Rguide.xml). This project is\nreleased with a [Contributor Code of\nConduct](https://github.com/atmoschem/vein/blob/master/CODE_OF_CONDUCT.md).\nBy participating in this project you agree to abide by its terms.\n\n### Note for non-english and anaconda users\n\nSometimes you need to install R and all dependencies and a way for doing\nthat is using anaconda. Well, as my system is in portuguese, after\ninstalling R using anaconda it changed the decimal character to ‘,’. In\norder to change it back to english meaning decimal separator as ‘.’, I\nadded this variable into the .bashrc\n\n    nano ~/.bashrc\n    export Lang=C\n\nMore details on\n[StackOverflow](https://stackoverflow.com/questions/13575180/how-to-change-language-settings-in-r)\n\n\u003c!-- You can learn more about VEIN reading the documentation in [PDF](https://cran.r-project.org/web/packages/vein/vein.pdf), [online](https://atmoschem.github.io/vein/), reading the book [online](https://ibarraespinosa.github.io/VEINBOOK/), or buy it in  [Kindle](https://www.amazon.com/VEINBOOK-Estimating-vehicular-emissions-package-ebook-dp-B07L7XRFKC/dp/B07L7XRFKC/ref=mt_kindle?_encoding=UTF8\u0026me=\u0026qid=) or  [Paperback](https://www.amazon.com/gp/product/1791571158?pf_rd_p=1581d9f4-062f-453c-b69e-0f3e00ba2652\u0026pf_rd_r=EMDPZM3G7BWCHAD9F4QP) --\u003e\n\u003c!-- ![](https://i.imgur.com/RcfNmDm.jpg) --\u003e\n","funding_links":[],"readme_doi_urls":["https://doi.org/10.5194/gmd-11-2209-2018"],"works":{},"citation_counts":{},"total_citations":0,"keywords_from_contributors":["atmospheric-modelling","atmospheric-science"],"project_url":"https://ost.ecosyste.ms/api/v1/projects/490","html_url":"https://ost.ecosyste.ms/projects/490"}