EmissV
Create and processing emissions for numeric air quality models
Install / Use
/learn @atmoschem/EmissVREADME
EmissV
<!-- badges: start --> <!-- badges: end -->EmissV is a R-package that provides tools to create emissions for use in numeric air quality models such as WRF-Chem. The package can read inputs from global fluxes from inventories in Netcdf Format [1] or estimate the emissions using top-down approach for point/line/area sources [2].
[1] Schuch D, Ibarra-Espinosa S, Dias de Freitas E, Andrade M (2018). “EmissV: A preprocessor for WRF-Chem model.” Journal of Atmospheric Science Research, 5, doi:10.30564/jasr.v1i1.347.
[2] Schuch D, Ibarra-Espinosa S, Dias de Freitas E (2018). “EmissV: An R package to create vehicular and other emissions by Top-down methods to air quality models.” The Journal of Open Source Software, 6, doi:10.21105/joss.00662.
Installation
System dependencies
EmissV import functions from ncdf4 for reading model information, raster and sf to process grinded/geographic information and units. These packages need some aditional libraries:
To Ubuntu
The following steps are required for installation on Ubuntu:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes
sudo apt-get --yes --force-yes update -qq
# netcdf dependencies:
sudo apt-get install --yes libnetcdf-dev netcdf-bin
# units/udunits2 dependency:
sudo apt-get install --yes libudunits2-dev
# sf dependencies (without libudunits2-dev):
sudo apt-get install --yes libgdal-dev libgeos-dev libproj-dev
To Fedora
The following steps are required for installation on Fedora:
sudo dnf update
# netcdf dependencies:
sudo yum install netcdf-devel
# units/udunits2 dependency:
sudo yum install udunits2-devel
# sf dependencies (without libudunits2-dev):
sudo yum install gdal-devel proj-devel proj-epsg proj-nad geos-devel
To Windows
No additional steps for windows installation.
Detailed instructions can be found at netcdf, libudunits2-dev and sf developers page.
To conda (miniconda / anaconda)
First create a new environment called rspatial (or a better name):
conda create -n rspatial -y
conda activate rspatial
and to install some requisites:
conda install -c conda-forge r-sf -y
conda install -c conda-forge r-rgdal -y
conda install -c conda-forge r-lwgeom -y
conda install -c conda-forge r-raster -y
Package installation
To install the CRAN version:
install.packages("EmissV")
To install the development version using remotes:
require("remotes")
remotes::install_github("atmoschem/EmissV")
or to install the development version using devtools:
require("devtools")
devtools::install_github("atmoschem/EmissV")
Using EmissV with EDGAR 8.1 emissions
EmissV can be used to process emissions of atmospheric pollutants and green house gases from inventories such as EDGAR, RCP, GAINS and other datasets in NetCDF format, the GEIA-ACCENT and ECCAD emission data portal makes available some of these inventories. You can verify the supported format with:
EmissV::read()
To generate a simple emission it's a straightforward process in 4 steps:
library(EmissV)
### 1. download the EDGAR 8.1 Netcdf flux file using R or from
### https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/EDGAR/datasets
# create the temporary directory to download the data
folder <- file.path(tempdir(), "EDGARv8.1")
dir.create(folder)
# download the total emissions of NOx from EDGAR v50_AP for 2015
url <- "https://jeodpp.jrc.ec.europa.eu/ftp/jrc-opendata/EDGAR/datasets"
dataset <- "v81_FT2022_AP_new/NOx/TOTALS/flx_nc"
file <- "v8.1_FT2022_AP_NOx_2022_TOTALS_flx_nc.zip"
download.file(paste0(url,"/",dataset,"/",file), paste0(folder,"/",file))
# unzip the file
unzip(paste0(folder,"/",file),exdir = folder)
### 2. read the emissions (using the spec argument to split NOx into NO and NO2)
nox <- read(file = dir(path=folder, pattern="flx\\.nc", full.names=TRUE),
version = "EDGARv8",
spec = c(E_NO = 0.9 , # 90% of NOx is NO
E_NO2 = 0.1 )) # 10% of NOx is NO2
### 3. get the information from a WRF grid from a initial conditions file (wrfinput)
g <- gridInfo(paste(system.file("extdata", package = "EmissV"),"/wrfinput_d01",sep=""))
### 4. calculate the emissions for grid g
NO <- emission(grid = g, inventory = NOx$E_NO, pol = "NO", mm = 30.01, plot = T)
NO2 <- emission(grid = g, inventory = NOx$E_NO2,pol = "NO2",mm = 46.0055, plot = T)
The next step is to save the emission in a emission file, the next example show how to save emissions using the eixport R-package:
library(eixport)
### create a temporary folder for emissions
dir.create(file.path(tempdir(), "EMISSION"))
### create the emision file
wrf_create(wrfinput_dir = system.file("extdata", package = "EmissV"),
wrfchemi_dir = file.path(tempdir(), "EMISSION"),
domains = 1)
### get the file path of the emission file
emis_file <- list.files(path = file.path(tempdir(), "EMISSION"),
pattern = "wrfchemi_d01",
full.names = TRUE)
### save the emission
wrf_put(NO, file = emis_file, name = "E_NO", verbose = TRUE)
wrf_put(NO2, file = emis_file, name = "E_NO2", verbose = TRUE)
Check the wrf_create, wrf_put and to_wrf to more information and customize for your application.
NOTE: The emission file must be compatible with the WRF-Chem options (many arguments are the same as the namelist.input from WRF) check the eixport R-Package documentation and the WRF-Chem manual for more information.
Other R-packages are available to write netcdf such as ncdf4, RNetCDF, tidync are available on CRAN. Other languages such as NCL leanguage and the Python package wrf-python, and preprocessor anthro_emiss are aternative to write NetCDF files.
Using EmissV to estimate vehicular emissions
In EmissV the vehicular emissions are estimated by a top-down approach, i.e. the emissions are calculated using the statistical description of the fleet at avaliable level (National, Estadual, City, etc).The following steps show an example workflow for calculating vehicular emissions, these emissions are initially temporally and spatially disaggregated, and then distributed spatially and temporally.
I. Total: emission of pollutants is estimated from the fleet, use and emission factors and for the interest area (cities, states, countries, etc).
library(EmissV)
fleet <- vehicles(example = T)
# using a example of vehicles (DETRAN 2016 data and SP vahicle distribution):
# Category Type Fuel Use SP ...
# Light Duty Vehicles Gasohol LDV_E25 LDV E25 41 km/d 11624342 ...
# Light Duty Vehicles Ethanol LDV_E100 LDV E100 41 km/d 874627 ...
# Light Duty Vehicles Flex LDV_F LDV FLEX 41 km/d 9845022 ...
# Diesel Trucks TRUCKS_B5 TRUCKS B5 110 km/d 710634 ...
# Diesel Urban Busses CBUS_B5 BUS B5 165 km/d 792630 ...
# Diesel Intercity Busses MBUS_B5 BUS B5 165 km/d 21865 ...
# Gasoho
