#' Estimation of emissions resulting in a 3D EmissionsArray
#'
#' @description \code{emis3d} emissions
#'
#' @param veh data.frame or matrix similar to object class "Vehicles"
#' @param lkm Numeric, with length equal to number of rows of veh
#' @param ef EmissionFactor with mode double, with length equal to number of columns of veh,
#' @param profile data.frame with rows as 24 hours and columnas as each dayfor extrapolating traffic.
#' @useDynLib forvein, .registration = TRUE
#' @export
#' @examples \dontrun{
#' #do not run
#' library(vein)
#' data(net)
#' data(pc_profile)
#' data(fkm)
#' PC_G <- c(33491,22340,24818,31808,46458,28574,24856,28972,37818,49050,87923,
#' 133833,138441,142682,171029,151048,115228,98664,126444,101027,
#' 84771,55864,36306,21079,20138,17439, 7854,2215,656,1262,476,512,
#' 1181, 4991, 3711, 5653, 7039, 5839, 4257,3824, 3068)
#' pc1 <- my_age(x = net$ldv, y = PC_G, name = "PC", agemax = 41)
#' lef <- ef_cetesb("CO", "PC_G", agemax = 41)
#' system.time(E_CO <- emis(veh = pc1,
#' lkm = net$lkm,
#' ef = lef,
#' profile = pc_profile))
#' system.time( E_COs <- emis(veh = pc1,
#' lkm = net$lkm,
#' ef = lef,
#' profile = pc_profile,
#' simplify = T) )
#' system.time( df <- emis4d(veh = pc1,
#' lkm = net$lkm,
#' ef = lef,
#' profile = pc_profile) )
#' system.time( df <- emis3d(veh = pc1,
#' lkm = net$lkm,
#' ef = lef,
#' profile = pc_profile) )
#' veh <- rep(1, 4)
#' lkm = rep(1, 2)
#' ef = c(1, 2)
#' profile = rep(1, 2)
#' emis3d(veh = veh, lkm = lkm, ef = ef, profile = profile)
#' }
emis4d <- function(veh,
lkm,
ef,
profile) {
veh <- as.matrix(veh)
profile <- as.matrix(profile)
lkm <- as.numeric(lkm)
ef <- as.numeric(ef)
nrowv <- as.integer(nrow(veh))
ncolv <- as.integer(ncol(veh))
proh <- as.integer(nrow(profile))
prod <- as.integer(ncol(profile))
a <- .Fortran("emis4df",
nrowv = nrowv,
ncolv = ncolv,
proh = proh,
prod = prod,
veh = veh,
lkm = lkm,
ef = ef,
pro = profile,
emis = numeric(nrowv*ncolv*proh*prod))$emis
e <- array(a, dim = c(nrowv, ncolv,proh, prod))
return(e)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.