Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

114 industrial emissions data sourcing #140

Merged
merged 53 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
59d4fd3
Create compile_industrial_point_sources.R
pawilfahrt Sep 24, 2024
d17a6b4
Update compile_industrial_point_sources.R
pawilfahrt Sep 24, 2024
1918d0f
separate county and point source emission scripts
pawilfahrt Sep 25, 2024
7b78851
Update .gitignore
pawilfahrt Sep 26, 2024
95f260e
rename, add flight import, early graphs
pawilfahrt Sep 26, 2024
741baa3
output flight ctu data
pawilfahrt Sep 27, 2024
ab7e10e
flight county data
pawilfahrt Sep 27, 2024
eddf1b3
graphs to be moved to Quarto
pawilfahrt Sep 30, 2024
59ea4dd
save RDS in correct place
pawilfahrt Sep 30, 2024
1411f07
compile industrial fuel source by fuel combustion
pawilfahrt Oct 9, 2024
d8abe9a
Merge branch 'dev-2005-baseline' into 114-industrial-emissions-data-s…
pawilfahrt Oct 9, 2024
bf49215
reformat ghg factor hub to bring in industrial sources
pawilfahrt Oct 9, 2024
7609172
ghg factor formatting
pawilfahrt Oct 11, 2024
0054cc8
finish back calculation and natural gas co2e amount
pawilfahrt Oct 11, 2024
e6d33b5
finish compiling fuel combustion emissions
pawilfahrt Oct 14, 2024
3f5af4e
save nei county data and begin industrial methods qmd
pawilfahrt Oct 15, 2024
36eab2c
add subparts to flight output
pawilfahrt Oct 16, 2024
47fab22
add facility id to flight output
pawilfahrt Oct 16, 2024
31cc614
add industrial subpart c comparison graphs
pawilfahrt Oct 16, 2024
f9b3f6f
add county name to subpart analysis
pawilfahrt Oct 17, 2024
100820d
add county name
pawilfahrt Oct 17, 2024
ced9d65
add comparison graphs for NREL
pawilfahrt Oct 17, 2024
d657fa0
Merge branch 'dev-2005-baseline' into 114-industrial-emissions-data-s…
pawilfahrt Nov 8, 2024
c03b4c7
update files and read in
pawilfahrt Nov 8, 2024
233f8f2
compile industrial emissions
pawilfahrt Nov 12, 2024
ca243e0
start mpca compilation
pawilfahrt Nov 15, 2024
2211c99
start MPCA fuel data compilation
pawilfahrt Nov 15, 2024
a8ac45c
relocate file and add fuel type conversions
pawilfahrt Nov 18, 2024
c15bb82
finish mpca fuel compilation
pawilfahrt Nov 19, 2024
4f96768
start loading MPCA data to qmd
pawilfahrt Nov 19, 2024
faffd9d
convert gas type to co2e and save both
pawilfahrt Nov 20, 2024
2139ff0
industiral emission comparison
pawilfahrt Nov 20, 2024
c25d08d
fix unit conversion error
pawilfahrt Nov 21, 2024
b4d4e57
fixed decimal error in mpca source doc
pawilfahrt Nov 21, 2024
0d2a22c
process ghgrp data
pawilfahrt Nov 22, 2024
eebdf03
start mpca and ghgrp facility matching, add naics code to mpca
pawilfahrt Nov 25, 2024
d80fbad
fuzzy match work, inventory_year as numeric
pawilfahrt Nov 25, 2024
e3e35ac
update comparison graphs
pawilfahrt Nov 25, 2024
c015422
Update .gitignore
pawilfahrt Nov 26, 2024
49a22fb
Create model_baseline_industrial_emissions.R
pawilfahrt Nov 27, 2024
6dcbf2c
update mpca ghgrp emission comparisons
pawilfahrt Nov 27, 2024
46f1790
Update model_baseline_industrial_emissions.R
pawilfahrt Nov 27, 2024
fafb72f
Merge branch 'dev-2005-baseline' into 114-industrial-emissions-data-s…
pawilfahrt Dec 2, 2024
a173c2b
Update model_baseline_industrial_emissions.R
pawilfahrt Dec 2, 2024
72e0efa
finish industrial and commercial baseline modeling
pawilfahrt Dec 3, 2024
c62a63a
Create _industrial.qmd
pawilfahrt Dec 11, 2024
fef5fcb
Update _industrial.qmd
pawilfahrt Dec 11, 2024
f9a78fc
update county compiler
pawilfahrt Dec 12, 2024
c58b6cd
add 2021, 2022 to industrial modeling dataset
pawilfahrt Dec 12, 2024
b5ac962
update sector and category colors
pawilfahrt Dec 12, 2024
c70ad3e
finish industrial qmd
pawilfahrt Dec 12, 2024
2a11dda
styler
pawilfahrt Dec 12, 2024
81f2430
Merge branch 'dev-2005-baseline' into 114-industrial-emissions-data-s…
LimerickSam Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,11 @@ _transportation/data-raw/epa/nei/SmokeFlatFile_MN_WI/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/CMAS_Data_Warehouse/

_industrial/data-raw/emissions_by_unit_and_fuel_type_c_d_aa_09_2023.xlsb
_industrial/data-raw/emissions_by_unit_and_fuel_type_c_d_aa_09_2023.xlsx
_industrial/data-raw/mn_flight.xls


_meta/data-raw/population/co-est00int-01-27.xls

_meta/data-raw/population/co-est00int-01-55.xls
Expand Down Expand Up @@ -1145,6 +1150,25 @@ _transportation/data-raw/~$_source_method_compare.xlsx

_transportation/data-raw/epa/SCCformat=CSV&sortFacet=scc%20level%20one&filename=SCCDownload-2024-0812-144242.csv

_industrial/data-raw/emissions_by_unit_and_fuel_type_c_d_aa.xlsb
_industrial/data-raw/emissions_by_unit_and_fuel_type_c_d_aa.xlsx
_industrial/data-raw/MPCA_industrial_fuel_throughput.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2010.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2011.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2012.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2013.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2014.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2015.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2016.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2017.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2018.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2019.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2020.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2021.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2022.xlsx
_industrial/data-raw/ghgrp/ghgp_data_2023.xlsx
_meta/data-raw/state-ghg-inventory.csv


_transportation/data-raw/mndot/city_route_system/

Expand All @@ -1153,5 +1177,3 @@ _transportation/data-raw/mndot/updated_VMT_County_City_Route_System/
_transportation/data-raw/mndot/updated_VMT_County_City_Route_System.zip

_agriculture/data-raw/ag-module.xlsx

/_nature/data-raw/nlcd_raw_imgs
213 changes: 213 additions & 0 deletions 00_compile_industrial_emissions.R
pawilfahrt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
##### run industrial scripts; compile county and CTU industrial emissions

source("./R/global_warming_potential.R")
ind_fuel_combustion <- readRDS("./_industrial/data/fuel_combustion_emissions_by_gas.rds")
ind_flight_emissions <- readRDS("./_industrial/data/flight_industrial_point_sources_ctu.rds")
ind_nei_emissions <- readRDS("./_industrial/data/nei_county_industrial_emissions.rds")

### first start with county level emission estimates
### The workflow is split out industrial fuel combustion into gas, oil, coal
### subtract away fuel emissions from FLIGHT and call it process
### subtract away flight from NEI and call it 'small industrial'
### If flight > NEI, call 'small industrial' 0

### need to do more research into what 'fuel gas' is
ind_fuel_combustion <- ind_fuel_combustion %>%
mutate(fuel_type = case_when(
specific_fuel_type == "Fuel Gas" ~ "Fuel Gas",
TRUE ~ general_fuel_type
))

county_fuel_combustion <- ind_fuel_combustion %>%
filter(units_emissions != "avg_activity") %>%
mutate(mt_co2e = case_when(
units_emissions == "mt_ch4" ~ values_emissions * gwp$ch4,
units_emissions == "mt_n2o" ~ values_emissions * gwp$n2o,
TRUE ~ values_emissions
)) %>%
group_by(county_name, reporting_year, fuel_type) %>%
summarize(mt_co2e = sum(mt_co2e)) %>%
mutate(
data_source = "EPA FLIGHT Subpart C Analysis",
factor_source = "EPA Emission Factor Hub",
sector = "Industrial",
category = "Fuel combustion"
) %>%
select(county_name,
inventory_year = reporting_year,
sector,
category,
source = fuel_type,
data_source,
factor_source,
mt_co2e
)

county_process_emissions <- ind_flight_emissions %>%
filter(doublecount == "No") %>%
group_by(county_name, inventory_year) %>%
summarize(mt_co2e = sum(value_emissions)) %>%
left_join(
county_fuel_combustion %>%
group_by(county_name, inventory_year) %>%
summarize(mt_co2e = sum(mt_co2e)),
by = c(
"county_name",
"inventory_year"
),
suffix = c("_total", "_fuel_combustion")
) %>%
# 2010 is absent for fuel combustion
filter(inventory_year != 2010) %>%
mutate(
mt_co2e_fuel_combustion = coalesce(mt_co2e_fuel_combustion, 0),
mt_co2e = mt_co2e_total - mt_co2e_fuel_combustion,
sector = "Industrial",
category = "Process",
source = "Process", # This could be filled in from subparts with some effort
data_source = "EPA FLIGHT",
factor_source = "EPA Emission Factor Hub"
) %>%
select(
inventory_year, county_name, data_source,
factor_source, mt_co2e, sector,
category,
source
)

# to estimate smaller industrial emissions, we'll subtract all FLIGHT
# emissions away from NEI estimates. Negative numbers will be corrected
# to zero until a better data source is identified
county_small <- ind_nei_emissions %>%
group_by(inventory_year, county_name) %>%
summarize(mt_co2e_all = as.numeric(sum(values_emissions))) %>%
left_join(ind_flight_emissions %>%
group_by(county_name, inventory_year) %>%
summarize(mt_co2e_big = sum(value_emissions))) %>%
mutate(
mt_co2e_big = coalesce(mt_co2e_big, 0),
mt_co2e = mt_co2e_all - mt_co2e_big,
mt_co2e = if_else(mt_co2e < 0, 0, mt_co2e),
sector = "Industrial",
category = "Other",
source = "Small point source",
data_source = "EPA NEI",
factor_source = "EPA NEI"
) %>%
select(
inventory_year, county_name, data_source,
factor_source, mt_co2e, sector,
category,
source
)

county_industrial_emission <- bind_rows(
county_fuel_combustion,
county_process_emissions,
county_small
) %>%
mutate(units_emissions = "Metric tons CO2e") %>%
rename(values_emissions = mt_co2e)

county_industrial_emission_meta <-
tibble::tribble(
~"Column", ~"Class", ~"Description",
"county_name", class(county_industrial_emission$county_name), "County name",
"inventory_year", class(county_industrial_emission$inventory_year), "Year of activity",
"sector", class(county_industrial_emission$sector), "Sector of emissions",
"category", class(county_industrial_emission$category), "Category of emissions",
"source", class(county_industrial_emission$source), "Specific source of emissions",
"data_source", class(county_industrial_emission$data_source), "Activity data source",
"factor_source", class(county_industrial_emission$factor_source), "Emissions factor data source",
"values_emissions", class(county_industrial_emission$values_emissions), "Numerical value of emissions data",
"units_emissions", class(county_industrial_emission$units_emissions), "Units of emissions data"
)

saveRDS(county_industrial_emission, "./_industrial/data/county_industrial_emissions.rds")
saveRDS(county_industrial_emission_meta, "./_industrial/data/county_industrial_emissions_meta.rds")


## do the same for cities, excepting the nei source


city_fuel_combustion <- ind_fuel_combustion %>%
filter(units_emissions != "avg_activity") %>%
mutate(mt_co2e = case_when(
units_emissions == "mt_ch4" ~ values_emissions * gwp$ch4,
units_emissions == "mt_n2o" ~ values_emissions * gwp$n2o,
TRUE ~ values_emissions
)) %>%
group_by(city_name, reporting_year, fuel_type) %>%
summarize(mt_co2e = sum(mt_co2e)) %>%
mutate(
data_source = "EPA FLIGHT Subpart C Analysis",
factor_source = "EPA Emission Factor Hub",
sector = "Industrial",
category = "Fuel combustion"
) %>%
select(city_name,
inventory_year = reporting_year,
sector,
category,
source = fuel_type,
data_source,
factor_source,
mt_co2e
)

city_process_emissions <- ind_flight_emissions %>%
filter(doublecount == "No") %>%
group_by(city_name, inventory_year) %>%
summarize(mt_co2e = sum(value_emissions)) %>%
left_join(
city_fuel_combustion %>%
group_by(city_name, inventory_year) %>%
summarize(mt_co2e = sum(mt_co2e)),
by = c(
"city_name",
"inventory_year"
),
suffix = c("_total", "_fuel_combustion")
) %>%
# 2010 is absent for fuel combustion
filter(inventory_year != 2010) %>%
mutate(
mt_co2e_fuel_combustion = coalesce(mt_co2e_fuel_combustion, 0),
mt_co2e = mt_co2e_total - mt_co2e_fuel_combustion,
mt_co2e = if_else(mt_co2e < 0, 0, mt_co2e),
sector = "Industrial",
category = "Process",
source = "Process", # This could be filled in from subparts with some effort
data_source = "EPA FLIGHT",
factor_source = "EPA Emission Factor Hub"
) %>%
select(
inventory_year, city_name, data_source,
factor_source, mt_co2e, sector,
category,
source
)

city_industrial_emission <- bind_rows(
city_fuel_combustion,
city_process_emissions
) %>%
mutate(units_emissions = "Metric tons CO2e") %>%
rename(values_emissions = mt_co2e)

city_industrial_emission_meta <-
tibble::tribble(
~"Column", ~"Class", ~"Description",
"city_name", class(city_industrial_emission$city_name), "County name",
"inventory_year", class(city_industrial_emission$inventory_year), "Year of activity",
"sector", class(city_industrial_emission$sector), "Sector of emissions",
"category", class(city_industrial_emission$category), "Category of emissions",
"source", class(city_industrial_emission$source), "Specific source of emissions",
"data_source", class(city_industrial_emission$data_source), "Activity data source",
"factor_source", class(city_industrial_emission$factor_source), "Emissions factor data source",
"values_emissions", class(city_industrial_emission$values_emissions), "Numerical value of emissions data",
"units_emissions", class(city_industrial_emission$units_emissions), "Units of emissions data"
)

saveRDS(city_industrial_emission, "./_industrial/data/city_industrial_emissions.rds")
saveRDS(city_industrial_emission_meta, "./_industrial/data/city_industrial_emissions_meta.rds")
52 changes: 35 additions & 17 deletions R/cprg_colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,54 @@ cprg_colors <- list(

# sector colors
sector_colors <- list(
"Transportation" = "#8e440b",
"Energy" = "#163c6a",
"Waste" = "#8d0c3b"
"Electricity" = "#1f77b4",
"Transportation" = "#191970",
"Residential" = "#9467bd",
"Commercial" = "#d62728",
"Industrial" = "slategray",
"Waste" = "#8c564b",
"Agriculture" = "#8fb910",
"Natural Systems" = "#006f3c"
)


# category
category_colors <-
list(
# GnBu
"Residential energy" = "#225ea8",
"Commercial energy" = "#41b6c4",
"Industrial energy" = "#7fcdbb",
"Liquid stationary fuels" = "#a8ddb5",

# Pu
"Residential natural gas" = "#483248",
"Residential electricity" = "#CF9FFF",
"Commercial natural gas" = "#800000",
"Commercial fuel combustion" = "#DE3163",
"Commercial electricity" = "#FAA0A0",

# Gray
"Industrial electricity" = "#E5E4E2",
"Industrial natural gas" = "#36454F",
"Industrial processes" = "#B2BEB5",
"Industrial fuel combustion" = "#818589",
"Refinery processes" = "#708090",

# YlOrBr
"Passenger vehicles" = "#993404",
"Buses" = "#E9967A",
"Trucks" = "#fe9929",
"Passenger vehicles" = "#0047AB",
"Buses" = "#6F8FAF",
"Trucks" = "#6495ED",
"Aviation" = "#191970",

# PuRd
"Solid waste" = "#ce1256",
"Wastewater" = "#c994c7",
# Rd
"Solid waste" = "#8B4513",
"Wastewater" = "#CD853F",

# Green
"Cropland" = "#c7e960",
"Livestock" = "#8fb910",

# Gn
"Sequestration" = "#006f3c",
"Stock" = "#27b376"
"Urban greenery" = "#006f3c",
"Natural systems" = "#27b376"
)


# source
source_colors <- list(
# transportation levels
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading