Can we get any country emission from this package #98
Replies: 4 comments 1 reply
-
Hi @Invincibles-group # for checking how gtfs2emis storage data on MOVES
> library(gtfs2emis)
> data("ef_usa_moves_db")
> head(ef_usa_moves_db)
fuel_type reference_year model_year pollutant lower_speed_interval upper_speed_interval
1: CNG 2015 1989 CH4 0.0 [km/h] 4.0 [km/h]
2: CNG 2015 1989 CH4 4.0 [km/h] 12.1 [km/h]
3: CNG 2015 1989 CH4 12.1 [km/h] 20.1 [km/h]
4: CNG 2015 1989 CH4 20.1 [km/h] 28.2 [km/h]
5: CNG 2015 1989 CH4 28.2 [km/h] 36.2 [km/h]
6: CNG 2015 1989 CH4 36.2 [km/h] 44.3 [km/h]
ef source_type id_speed
1: 69.12351 [g/km] Transit Bus 1
2: 41.04421 [g/km] Transit Bus 2
3: 28.99163 [g/km] Transit Bus 3
4: 24.88722 [g/km] Transit Bus 4
5: 21.28728 [g/km] Transit Bus 5
6: 18.18489 [g/km] Transit Bus 6
# Running the transport model
# read GTFS
gtfs_file <- system.file("extdata/bra_cur_gtfs.zip", package = "gtfs2emis")
gtfs <- gtfstools::read_gtfs(gtfs_file)
# keep a single trip_id to speed up this example
gtfs_small <- gtfstools::filter_by_trip_id(gtfs, trip_id ="4451136")
# run transport model
tp_model <- transport_model(gtfs_data = gtfs_small,
min_speed = 2,
max_speed = 80,
new_speed = 20,
spatial_resolution = 100,
parallel = FALSE)
# Fleet
# Example using US MOVES emission model and fleet
fleet_data_ef_moves <- data.frame( model_year = 2010:2019
, fuel = "D"
, reference_year = 2020
, fleet_composition = rep(0.1,10))
# Example using US MOVES emission model and fleet
emi_moves <- emission_model(tp_model = tp_model
, ef_model = "ef_usa_moves"
, fleet_data = fleet_data_ef_moves
, pollutant = c("CO","PM10","CO2","CH4","NOx")
, reference_year = 2020)
If you still have issues, you can upload here few lines of you Toronto fleet data in .txt or .csv format, so I can reproduce it. |
Beta Was this translation helpful? Give feedback.
-
library(data.table)
library(gtfs2emis)
library(janitor) # clean names
# 1) read fleet-----
# Adjust fleet data
tor_fleet <- data.table::fread("tor_fleet.csv",sep = ";")
names(tor_fleet) <- janitor::make_clean_names(names(tor_fleet))
# 2) Adjust fleet data-----
# manually adjust the model_year data
unique(tor_fleet$built)
tor_fleet[,model_year := built]
tor_fleet[built == "2007-8",model_year := "2007"]
tor_fleet[built == "2007-9",model_year := "2007"]
tor_fleet[built == "2018-9",model_year := "2018"]
tor_fleet[built == "2009-12",model_year := "2009"]
tor_fleet[built == "2011-12",model_year := "2011"]
tor_fleet[built == "2015-16",model_year := "2015"]
tor_fleet[built == "2016-17",model_year := "2016"]
tor_fleet[built == "2017-20",model_year := "2017"]
tor_fleet[built == "2013-14",model_year := "2013"]
tor_fleet[,model_year := as.numeric(model_year)]
# checking `data(ef_usa_moves_db)` there
# is not emission factor for pollutants in the
# year of 1982. For this exercise, I'm removing this
# vehicle
tor_fleet <- tor_fleet[model_year != 1982,]
# manually adjust the fuel type
unique(tor_fleet$propulsion)
tor_fleet[,fuel := propulsion]
tor_fleet[propulsion == "Diesel",fuel := "D"]
tor_fleet[propulsion == "Gasoline",fuel := "G"]
# depending on the emission process you are
# looking to estimate, there is no available emission factor
# for Hybrid or Electric vehicle. I am removing
# these vehicles to simplify the analysis.
tor_fleet <- tor_fleet[fuel %in% c("D","G"),]
# In addition, depending on the emission factor method
# you are interested, there are not available data
# for small urban buses (e.g. vehicles of lengths of 6 - 8 m)
# So, for this example, I'm considering that all vehicles
# has standard sizes.
tor_fleet[,veh_type := "BUS_URBAN_D"]
# Now, we sum the total vehicle by model_year, vehicle type and fuel
tor_fleet <- tor_fleet[,list("number_in_service" = sum(number_in_service))
, by = .(model_year,veh_type,fuel)]
# we estimate the fleet composition (proportion by year)
tor_fleet[,fleet_composition := number_in_service/sum(number_in_service)]
# it should sum 1.0 for most of the cases
sum(tor_fleet$fleet_composition) # 1
# 3) read GTFS -----
# read GTFS
gtfs_file <- system.file("extdata/bra_cur_gtfs.zip", package = "gtfs2emis")
gtfs <- gtfstools::read_gtfs(gtfs_file)
# keep a single trip_id to speed up this example
gtfs_small <- gtfstools::filter_by_trip_id(gtfs, trip_id ="4451136")
# run transport model
tp_model <- transport_model(gtfs_data = gtfs_small,
min_speed = 2,
max_speed = 80,
new_speed = 20,
spatial_resolution = 100,
parallel = FALSE)
fleet_data_ef_moves <- data.frame( veh_type = "BUS_URBAN_D"
, model_year = 2010:2019
, fuel = "D"
, reference_year = 2020
, fleet_composition = rep(0.1,10))
# Example using US MOVES emission model and fleet
emi_moves <- emission_model(tp_model = tp_model
, ef_model = "ef_usa_moves"
, fleet_data = tor_fleet
, reference_year = 2020
, pollutant = c("CO2","PM10","VOC","CO","NOx"))
# Aggregate total emissions by 'pollutant'
emis_summary(emi_moves,veh_vars = "model_year")
# by vehicle type
emis_summary(emi_moves,veh_vars = "model_year", by = "vehicle")
emis_summary(emi_moves,veh_vars = c("model_year","fuel"), by = "vehicle")
emis_summary(emi_moves,veh_vars = "model_year", by = "time")
[tor_fleet.csv](https://github.com/ipeaGIT/gtfs2emis/files/10874929/tor_fleet.csv)
|
Beta Was this translation helpful? Give feedback.
-
Hi @Invincibles-group. I'm closing the discussion here, but if there's an issue reproducing the results you can reopen it. |
Beta Was this translation helpful? Give feedback.
-
How will I get the emission data if I pass the gtfs data for Toronto City and fleet information?
Parameters for the emission model() function include ef usa moves, ef usa emfac, ef europe emep, ef brazil cetesb, and ef brazil scaled euro (scale ef brazil cetesb() based on ef scaled euro()).
I get the following error when I use any of the options: Error: The assertion'veh type' failed: 'Vehicle','Model','in.service','Garage','Built','Seats','Length','Propulsion','Manufacturer', but not'veh type'.
By this error message I have understood like if I pass the ef_usa_moves to the ef_model parameter to the toronto fleet data it is throwing error as it expect the fleet data for the Toronto should be same as ef_usa_moves. But in my case the Toronto fleet data is different when compared USA fleet data.
**```{r}
emi_list <- emission_model(tp_model = tp_model
, ef_model = "ef_usa_moves"
, fleet_data = fleet_df
, pollutant = c("NOx","PM10")
)
Beta Was this translation helpful? Give feedback.
All reactions