Skip to content

Commit

Permalink
update for cran
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaobazzo committed Oct 10, 2024
1 parent ecb871d commit 1455966
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.1.0
Date: 2022-11-11 18:12:35 UTC
SHA: 2465083c3e4d5a2b96d433ec25c5c699b7d77c28
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ VignetteBuilder:
knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
LazyData: true
4 changes: 2 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ First submission to CRAN

## Test environments

- Local Ubuntu 20.04 installation (R 4.2.2)
- Local Ubuntu 20.04 installation (R 4.4.1)
- GitHub Actions:
- Windows (oldrel)
- Windows (release, oldrel, devel)
- MacOS (release, oldrel)
- Ubuntu 20.04 (devel, release, oldrel)
- r-hub:
Expand Down
94 changes: 94 additions & 0 deletions tests/test_joao/insert_wear.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
rm(list=ls())
library(devtools)
devtools::document()
devtools::load_all()
devtools::test()


# tyre -----
emi_list_wear <- emi_europe_emep_wear(dist = units::set_units(rep(1),"km"),
speed = units::set_units(30,"km/h"),
pollutant = c("PM10","TSP","PM2.5"),
veh_type = c("Ubus Std 15 - 18 t","Ubus Artic >18 t"),
fleet_composition = c(0.5,0.5),
load = 0.5,
process = c("brake","tyre","road"),
as_list = TRUE)
emi_list_wear
emi_list <- emi_list_wear
#emi_list <- emi_list_wear$emi
source("R/emis_to_dt.R")
names(emi_list_wear)
wear_dt <- emis_to_dt(emi_list = emi_list_wear
,segment_vars = c("speed","dist")
,veh_vars = c("veh_type")
,process_vars = "process")
wear_dt
wear_dt[,sum(as.numeric(emi)),by = .(pollutant,veh_type,process)]
source("R/emis_summary.R")
emi_sum_wear <- emis_summary(emi_list = emi_list_wear
,by = "pollutant"
,veh_vars = c("veh_type","fleet_composition"))
emi_sum_wear
emi_sum_wear <- emis_summary(emi_list = emi_list_wear
,by = "vehicle"
,veh_vars = c("veh_type"))
emi_sum_wear

# hot_exaust------------
source("R/ef_europe_emep.R")
emi_he_list <- ef_europe_emep(euro = c("V","V"),
speed = units::set_units(1:100,"km/h"),
pollutant = c("PM10"),
veh_type = c("Ubus Std 15 - 18 t","Ubus Artic >18 t"),
load = 0.5,
as_list = TRUE)
names(emi_he_list)
head(emi_he_list$EF,1)
source("R/emis_summary.R")
emi_sum <- emis_summary(emi_list = emi_he_list
,by = "pollutant"
,veh_vars = c("veh_type","fleet_composition")
,process_vars = "process")
emi_sum_wear
#emi_list = emi_he_list
#segment_vars = c("speed")
#veh_vars = c("veh_type","euro")
#emi_vars = "EF"
#pol_vars = "pollutant"
#process_vars = "process"
source("R/emis_to_dt.R")
hex_dt <- emis_to_dt(emi_list = emi_he_list
,segment_vars = c("speed")
,veh_vars = c("veh_type","euro")
,emi_vars = "EF"
,pol_vars = "pollutant"
,process_vars = "process"
)
hex_dt
# merge emissions-----


lcf_bw <- 1.00 + 0.79 * load
# emission factor
ef_tsp_pc_bw <- units::set_units(0.0075,'g/km')
ef_tsp_bus_bw <- 3.13 * lcf_bw * ef_tsp_pc_bw
#ef_tsp_bus_bw <- units::set_units(ef_tsp_bus_bw,'g/km')

# speed corrections
speed_cor_bw <- speed_cor_bw_f(speed)
# emission
a <- dist * speed_cor_bw
a
b <- a * ef_tsp_bus_bw
b * mass_bw
a <- (dist * as.matrix(speed_cor_bw) )
b <- ef_tsp_bus_bw * mass_bw
for(i in 1:ncol(b)) b[]
dim(a)
dim(b)
a %*% b
a %*% t(b)
b %*% t(a)
b %*% a
tmp_emi <- (ef_tsp_bus_bw %*% * mass_bw)
8 changes: 3 additions & 5 deletions vignettes/gtfs2emis_non_exhaust_ef.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ $$
TE_i = dist \times EF_{tsp}(j) \times mf_s(i) \times SC(speed)
$$ where:
- $TE(i)$ = total emissions of pollutant i (g),
- $TE(i)$ = total emissions of pollutant $i$ (g),
- $dist$ = distance driven by each vehicle (km),
- $EF_{tsp}(j)$ = TSP mass emission factor for vehicles of category j
(g/km),
- $mf_s(i)$ = mass fraction of TSP that can be attributed to particle
size class i,
- $EF_{tsp}(j)$ = TSP (Total Suspended Particle) mass emission factor for vehicles of category $j$ (g/km),
- $mf_s(i)$ = mass fraction of TSP that can be attributed to pollutant $i$,
- $SC(speed)$ = correction factor for a mean vehicle travelling at a
given speed (-).
Expand Down

0 comments on commit 1455966

Please sign in to comment.