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

Subsector comparison to MPCA state inventory #86

Open
wants to merge 172 commits into
base: dev-2005-baseline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
172 commits
Select commit Hold shift + click to select a range
9a3ffed
Create sectorWeights2005.R
LimerickSam Aug 8, 2024
95e2d94
Transcribed necessary mwh numbers from 2005 library utility data report
LimerickSam Aug 8, 2024
0df4931
Break out farm and industrial, expound units as separate field
LimerickSam Aug 8, 2024
9e9ab78
bring in cprg_ctu and reformat filter logic to enable pulling emissio…
LimerickSam Aug 8, 2024
7ec2d92
NREL SLOPE data for cities in CPRG area brought in
LimerickSam Aug 8, 2024
076d1b9
add _county and _inv_county to variables to distinguish from forthcom…
LimerickSam Aug 8, 2024
708743e
Write out CPRG-filtered NREL SLOPE city- and county-level files
LimerickSam Aug 9, 2024
fd80b95
clean up names and geometry from CPRG CTU
LimerickSam Aug 9, 2024
41a368b
Delete tabulapdf pseudocode -- I selected manual data entry approach
LimerickSam Aug 9, 2024
10209e3
gitignore modeling/forecasting reference docs, add additional pseudoc…
LimerickSam Sep 16, 2024
01de865
filter nrel city forecast snags to MNWI
LimerickSam Sep 16, 2024
2f11eba
Fix join logic between cprg_ctu reference file and NREL SLOPE city da…
LimerickSam Sep 17, 2024
14763b4
Join NREL city data to county data to facilitate calculation of propo…
LimerickSam Sep 18, 2024
33450be
Add cityPropOfCounty filelds, write additional pseudocode for backfil…
LimerickSam Sep 18, 2024
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
8159aef
Merge branch 'dev-2005-baseline' into 108-2005-sector-breakdowns----n…
LimerickSam Oct 17, 2024
3caa374
draft city level QA + merge commit upstream changes from dev-2005 (e.…
LimerickSam Oct 17, 2024
b45f5a9
Rename 2005/2021 activity files for clarity and alignment
LimerickSam Oct 17, 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
f541984
Accurate rename of 2021 activity file + fix naming from upstream files
LimerickSam Oct 24, 2024
3218fd0
fix namings for joins to upstream files
LimerickSam Oct 24, 2024
eab1ffb
Rename output of standalone elec activity/emissions analysis
LimerickSam Oct 24, 2024
385affd
Update code references to upstream cprg_ctu file naming conventions
LimerickSam Oct 28, 2024
dfbf737
Merge branch 'dev-2005-baseline' into 108-2005-sector-breakdowns----n…
LimerickSam Oct 28, 2024
73c6e65
Merge mega transportation push and re-update gitignore
LimerickSam Oct 28, 2024
6a16963
Update .gitignore
pawilfahrt Oct 29, 2024
090d716
Merge branch 'dev-2005-baseline' into 85-subsector-comparison-to-mpca…
pawilfahrt Oct 29, 2024
8382c75
Merge branch 'dev-2005-baseline' into 108-2005-sector-breakdowns----n…
LimerickSam Oct 30, 2024
80542ac
Delete unnecessary exports
LimerickSam Oct 30, 2024
654db7b
contd
LimerickSam Oct 30, 2024
e733851
filter to just 7-county area
LimerickSam Oct 30, 2024
318e81b
join newly developed ctu reference table with ctu proportion of count…
LimerickSam Oct 30, 2024
6c7a253
clean up unnecessary columns
LimerickSam Oct 30, 2024
f325126
Create state_demographer_population.R
pawilfahrt Oct 30, 2024
0a29e0b
update state population with demography estimates
pawilfahrt Oct 31, 2024
a572160
begin compiling state GCAM output
pawilfahrt Oct 31, 2024
9afa723
remove unneeded csvs
pawilfahrt Nov 1, 2024
bb9a651
Enumerate sectors in ctu_population data to enable clean joining and …
LimerickSam Nov 1, 2024
2a0709d
save initial projection breakdowns
pawilfahrt Nov 1, 2024
c197efe
Merge branch '81-agriculture-emissions-2005' into 85-subsector-compar…
pawilfahrt Nov 1, 2024
6a49e1d
Create _state_gcam_modeling.qmd
pawilfahrt Nov 1, 2024
a3cca38
Fix enumeration of natural gas to match NREL data for correct join
LimerickSam Nov 5, 2024
73bd249
add aviation emissions to county compiler
pawilfahrt Nov 5, 2024
b06c4b6
Fix 'loose end' columns after successful join, ensure 1 consistent ge…
LimerickSam Nov 5, 2024
359998c
fix ag source labels
pawilfahrt Nov 5, 2024
1a6013f
mpca-mc subsector alignment
pawilfahrt Nov 5, 2024
676b4d3
load in data for quarto
pawilfahrt Nov 5, 2024
4605294
Create nrel_activity.RDS with city, city downscaled, and county proje…
LimerickSam Nov 6, 2024
dcf8bcb
small update
pawilfahrt Nov 6, 2024
e17ca4f
Update _state_gcam_modeling.qmd
pawilfahrt Nov 7, 2024
c953f27
Merge branch 'dev-2005-baseline' into 85-subsector-comparison-to-mpca…
pawilfahrt Nov 7, 2024
68be023
rerun 2005 electricity scripts
pawilfahrt Nov 7, 2024
80ec69f
update county compiler AGAIN
pawilfahrt Nov 8, 2024
2aec9cc
fix naming downstream of cprg_county in minnesota_electricUtilities.R
LimerickSam Nov 8, 2024
2a528e7
Fix naming errors
LimerickSam Nov 8, 2024
2d57eb3
first draft of downscale graphs
pawilfahrt Nov 8, 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
be2cecc
Update gitignore
LimerickSam Nov 12, 2024
233f8f2
compile industrial emissions
pawilfahrt Nov 12, 2024
2cf84da
Merge branch '81-agriculture-emissions-2005' into temporary-ctu-graphs
pawilfahrt Nov 12, 2024
ee41d56
Merge branch '85-subsector-comparison-to-mpca-state-inventory' into t…
pawilfahrt Nov 13, 2024
7cedf5a
update county compiler
pawilfahrt Nov 13, 2024
c597717
fix wastewater
pawilfahrt Nov 13, 2024
f7c64cb
adapt county compilation script to ctu compilation
pawilfahrt Nov 13, 2024
fb15e3b
update categories
pawilfahrt Nov 13, 2024
91f9776
begin graphing
pawilfahrt Nov 13, 2024
ecfeb82
starting graph
pawilfahrt Nov 14, 2024
ffcf924
New rds files for natural systems land cover based on nlcd (aim is to…
ksmiff33 Nov 14, 2024
20dbcde
Updated with geometry and interpolated/extrapolated area values
ksmiff33 Nov 14, 2024
6f2f786
New RDS files for natural systems baseline inventory
ksmiff33 Nov 14, 2024
0bf0b4f
New CTU level estimates of stock potential and sequestration rate
ksmiff33 Nov 14, 2024
3233dc8
updated ctu RDS file for land cover
ksmiff33 Nov 14, 2024
6528fdc
New script reads land cover area estimates from nlcd and first fills …
ksmiff33 Nov 14, 2024
4fd5da5
Takes NLCD images from 2001 to 2021 and estimates land cover for each…
ksmiff33 Nov 14, 2024
73e95df
Merge remote-tracking branch 'origin/natural-systems-wrap-up-2' into …
pawilfahrt Nov 14, 2024
0238d7b
graph work
pawilfahrt Nov 14, 2024
0dfbad3
Merge remote-tracking branch 'origin/107-solid-waste-methodology-upda…
pawilfahrt Nov 14, 2024
58dcb7f
finish graphing for meeting
pawilfahrt Nov 14, 2024
ca243e0
start mpca compilation
pawilfahrt Nov 15, 2024
2211c99
start MPCA fuel data compilation
pawilfahrt Nov 15, 2024
61afbec
added some per capita subsector graphs
pawilfahrt Nov 18, 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
39656c0
Draft function for year-utility folder structure
LimerickSam Nov 21, 2024
0120358
Read in list of utility-year combos
LimerickSam Nov 21, 2024
6e2eeb1
Test process_file, filter out county rows with no record of activity
LimerickSam Nov 21, 2024
e0be5cf
Delete old code after verification new approach works, update comment…
LimerickSam Nov 21, 2024
3255072
Add time series of eGRID data back to 2005
LimerickSam Nov 21, 2024
b4d4e57
fixed decimal error in mpca source doc
pawilfahrt Nov 21, 2024
0d2a22c
process ghgrp data
pawilfahrt Nov 22, 2024
d67fef1
Add time series eGRID data to epa_ghg_factor_hub.RDS
LimerickSam Nov 25, 2024
41b3c1d
Update to read in EFs from shared .RDS
LimerickSam Nov 25, 2024
54e196c
Add 2021 to varnames to clarify which year these constants represent
LimerickSam Nov 25, 2024
70cd04c
Interpolate data for interstitial eGRID years where data was not prov…
LimerickSam Nov 25, 2024
eebdf03
start mpca and ghgrp facility matching, add naics code to mpca
pawilfahrt Nov 25, 2024
c9bb9cd
Bring in time series eGRID, join to activity, calculate year-utility-…
LimerickSam Nov 25, 2024
d80fbad
fuzzy match work, inventory_year as numeric
pawilfahrt Nov 25, 2024
692b388
Update county-level aggregation to include year, and rename output .RDS
LimerickSam Nov 25, 2024
10d40fe
Rename .R to clarify what data it processes
LimerickSam Nov 25, 2024
2e3ae51
Create minnesota_xcelCommunityReports_electricity.R
LimerickSam Nov 25, 2024
e3e35ac
update comparison graphs
pawilfahrt Nov 25, 2024
8d42688
Write code that parses Xcel Community Reports to create nested list a…
LimerickSam Nov 26, 2024
c015422
Update .gitignore
pawilfahrt Nov 26, 2024
554f6f8
Draft of function to dynamically/flexibly obtain data about city-sect…
LimerickSam Nov 26, 2024
f9afd4d
Update function to pull in city data from reports, validate that nece…
LimerickSam Nov 27, 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
f47f933
Rebuild of C sequestration rates
ksmiff33 Dec 2, 2024
f3cbcd6
Rebuilt this using new script that relies on saved NLCD images (movin…
ksmiff33 Dec 2, 2024
eecdec1
Rebuilt this using new script that relies on saved NLCD images (movin…
ksmiff33 Dec 2, 2024
7b256de
New estimates of land cover at the CTU level
ksmiff33 Dec 2, 2024
b420ae4
New file runs all of the NLCD land cover C sequestration routines.
ksmiff33 Dec 2, 2024
e17880f
Renamed to match our ordering scheme.
ksmiff33 Dec 2, 2024
2bb3606
As of Oct 2024, NLCD files have been updated which broke our code. Lu…
ksmiff33 Dec 2, 2024
5cdc96c
Modified this script to run at the county and CTU scale.
ksmiff33 Dec 2, 2024
767e325
Renamed to match our new file organization scheme.
ksmiff33 Dec 2, 2024
2ec7bf6
Renamed to match our new file organization scheme.
ksmiff33 Dec 2, 2024
29668c0
CTU scale sequestration estimates.
ksmiff33 Dec 2, 2024
fafb72f
Merge branch 'dev-2005-baseline' into 114-industrial-emissions-data-s…
pawilfahrt Dec 2, 2024
f65ea09
Delete test case, snag file info list
LimerickSam Dec 2, 2024
7fe06c6
fix draft test, remove total row from data retrieved by helper functi…
LimerickSam Dec 2, 2024
a173c2b
Update model_baseline_industrial_emissions.R
pawilfahrt Dec 2, 2024
a3b2ca1
Update nrel_slope_energy references to eGRID factors with _2021
LimerickSam Dec 3, 2024
f4214c5
Update data processing function to clean up data and add constants
LimerickSam Dec 3, 2024
a32ee44
Break out file list into two sections based on internal consistent fi…
LimerickSam Dec 3, 2024
cacfd36
Debug -- issue identified is that code breaks when two instances of "…
LimerickSam Dec 3, 2024
d7dd732
Fix typos i column name reference and run file processing function.
LimerickSam Dec 3, 2024
df9af12
Adjust logic to reuse process_file() function for two year ranges, ad…
LimerickSam Dec 3, 2024
72e0efa
finish industrial and commercial baseline modeling
pawilfahrt Dec 3, 2024
c44e18c
Merge branch 'dev-2005-baseline' into temporary-ctu-graphs
pawilfahrt Dec 4, 2024
576391f
Merge remote-tracking branch 'origin/rebuild-natural-systems-3' into …
pawilfahrt Dec 4, 2024
5283a24
Merge branch '114-industrial-emissions-data-sourcing' into temporary-…
pawilfahrt Dec 4, 2024
430ce79
Update compile_ctu_emissions.R
pawilfahrt Dec 4, 2024
e93164f
Row bind outcomes of data processing and bring in CPRG geographies
LimerickSam Dec 5, 2024
94826b6
input initial sector mapping from Xcel activity data
LimerickSam Dec 5, 2024
7e0dd98
Update ctu_emissions.RDS
pawilfahrt Dec 5, 2024
e2bd3be
Merge remote-tracking branch 'origin/108-2005-sector-breakdowns----ng…
pawilfahrt Dec 5, 2024
4891410
recast ctu emissions with new nrel estimates
pawilfahrt Dec 5, 2024
580ec0c
new color palette
pawilfahrt Dec 5, 2024
26c3fb2
add in 2021, 2022 to industrial
pawilfahrt Dec 6, 2024
28bd89a
create new ctu graphs
pawilfahrt Dec 6, 2024
824916f
redo graphs for climate summit
pawilfahrt Dec 7, 2024
a960bd0
finish graphs for climate summit
pawilfahrt Dec 9, 2024
b365953
add faceted sector option
pawilfahrt Dec 19, 2024
ffe13de
update subsector matching
pawilfahrt Jan 11, 2025
53900ce
add ggplot version of gcam downscale and minor edits
pawilfahrt Jan 11, 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
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,30 @@ _transportation/data-raw/~$_source_method_compare.xlsx
_transportation/data-raw/epa/SCCformat=CSV&sortFacet=scc%20level%20one&filename=SCCDownload-2024-0812-144242.csv


_meta/data-raw/mpca_ghg_inventory.csv
_meta/data-raw/Minnesota GCAM Modeling Data.xlsx

_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/

_transportation/data-raw/mndot/updated_VMT_County_City_Route_System/
Expand All @@ -1154,3 +1178,28 @@ _transportation/data-raw/mndot/updated_VMT_County_City_Route_System.zip

_agriculture/data-raw/ag-module.xlsx




_energy/data-raw/nrel_slope/MNWI

_energy/data-raw/dataExplorer.twb

*.twbr

_energy/data-raw/modelingDocs

_energy/data-raw/nrel_slope

_energy/data-raw/USDA_ERS_AgriculturalResourceManagementSurvey

_energy/data-raw/XcelCommunityReports

_energy/data-raw/mn_elec_utility_reporting_state

_energy\data-raw\XcelCommunityReports\electricity_all_years_city.csv

_energy/data-raw/GRE_individualReports

_energy/data-raw/xcel_community_reports

185 changes: 185 additions & 0 deletions 00_compile_industrial_emissions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
##### 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")
62 changes: 40 additions & 22 deletions R/cprg_colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,52 @@ cprg_colors <- list(
)

# sector colors
sector_colors <- list(
"Transportation" = "#8e440b",
"Energy" = "#163c6a",
"Waste" = "#8d0c3b"
)
sector_colors <- list("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",

# PuRd
"Solid waste" = "#ce1256",
"Wastewater" = "#c994c7",

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

# Rd
"Solid waste" = "#8B4513",
"Wastewater" = "#CD853F",

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

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


Expand Down
Loading