From 1455966232bc1e4b2b67fed39364716fa70ff074 Mon Sep 17 00:00:00 2001 From: JoaoBazzo Date: Thu, 10 Oct 2024 14:20:16 -0400 Subject: [PATCH] update for cran --- CRAN-SUBMISSION | 3 + DESCRIPTION | 2 +- cran-comments.md | 4 +- tests/test_joao/insert_wear.R | 94 ++++++++++++++++++++++++++ vignettes/gtfs2emis_non_exhaust_ef.Rmd | 8 +-- 5 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 CRAN-SUBMISSION create mode 100644 tests/test_joao/insert_wear.R diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..e1e3fe1 --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 0.1.0 +Date: 2022-11-11 18:12:35 UTC +SHA: 2465083c3e4d5a2b96d433ec25c5c699b7d77c28 diff --git a/DESCRIPTION b/DESCRIPTION index 613c896..70bf8ed 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,5 +53,5 @@ VignetteBuilder: knitr Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 LazyData: true diff --git a/cran-comments.md b/cran-comments.md index bb03ffb..1586915 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -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: diff --git a/tests/test_joao/insert_wear.R b/tests/test_joao/insert_wear.R new file mode 100644 index 0000000..85aeb0e --- /dev/null +++ b/tests/test_joao/insert_wear.R @@ -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) \ No newline at end of file diff --git a/vignettes/gtfs2emis_non_exhaust_ef.Rmd b/vignettes/gtfs2emis_non_exhaust_ef.Rmd index 4adc392..7aaf138 100644 --- a/vignettes/gtfs2emis_non_exhaust_ef.Rmd +++ b/vignettes/gtfs2emis_non_exhaust_ef.Rmd @@ -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 (-).