Skip to content

Commit

Permalink
Merge pull request #93 from Metropolitan-Council/gwp-ar6
Browse files Browse the repository at this point in the history
Update GWP values to AR6, add county population data back to 2005 (v1.1.1)
  • Loading branch information
pawilfahrt authored Jul 2, 2024
2 parents e3245bf + 6278338 commit c7da7e3
Show file tree
Hide file tree
Showing 119 changed files with 1,141 additions and 777 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*_cache
.DS_Store

**/desktop.ini

_transportation/report_transportation_files/figure-html/
_waste/data-raw/score_summary.csv
_waste/data-raw/ghg-emission-factors-hub-2021.xlsx
Expand Down Expand Up @@ -327,6 +329,18 @@ _nature/data-raw/land_cover_stock.csv
site_libs/
_nature/_natural_systems_files/*

_energy/data-raw/nhgis_blk2000_blk2010_MN/

_energy/data-raw/nhgis_blk2000_blk2010_WI/

_energy/data-raw/EIA861

_energy/data-raw/libraryDocs_2005

_meta/data-raw/nrel_slope/scenario_planner/

_meta/data-raw/nrel_slope/scenario_planner.zip

_meta/data-raw/nrel_slope_emissions/scenario_planner/

_meta/data-raw/nrel_slope_emissions/
Expand All @@ -336,3 +350,7 @@ _meta/data-raw/nrel_slope/scenario_planner/
_meta/data-raw/nrel_slope/emissions/

_meta/data-raw/nrel_slope/scenario_planner.zip

_transportation/data-raw/ghg_protocol/Emission_Factors_for_Cross_Sector_Tools_V2.0_0.xlsx

_transportation/data-raw/ghg_protocol/ghg-uncertainty.xlsx
31 changes: 23 additions & 8 deletions R/global_warming_potential.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# global warming potential
# 100-year, accurate to AR5
# * Following revised reporting requirements under the UNFCCC, this tool presents CO2 equivalent values based on the IPCC Fifth Assessment Report (AR5) GWP values.
# see Box 3.2, Table 1
# Zotero: ipccClimateChange2014
# 100-year, accurate to AR6
# * Following revised reporting requirements under the UNFCCC, this tool presents CO2 equivalent values based on the IPCC Sixth Assessment Report (AR6) GWP values.
# see Table 7.SM.7 in the Supplementary Materials for Chp.7 of the Climate Change 2021: The Physical Science Basis report prepared by Working Group I for the AR6 -- https://www.ipcc.ch/report/ar6/wg1/downloads/report/IPCC_AR6_WGI_Chapter07_SM.pdf -- for full data table of GWPs
# Zotero: ipccAR62021
gwp <-
list(
"co2" = 1,
"ch4" = 28,
"n2o" = 265,
"cf4" = 6630,
"HFC-152a" = 138
"ch4" = 27.9,
"n2o" = 273,
"cf4" = 7380,
"HFC-152a" = 164
)


# OLD VALUES do not use ------
# 100-year, accurate to AR5
# * Following revised reporting requirements under the UNFCCC, this tool presents CO2 equivalent values based on the IPCC Fifth Assessment Report (AR5) GWP values.
# see Box 3.2, Table 1
# Zotero: ipccClimateChange2014
# gwp <-
# list(
# "co2" = 1,
# "ch4" = 28,
# "n2o" = 265,
# "cf4" = 6630,
# "HFC-152a" = 138
# )
110 changes: 110 additions & 0 deletions _energy/data-raw/MNWI_2005_CensusCrosswalk_UtilityAllocation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
source("R/_load_pkgs.R")
source("_meta/data-raw/cprg_geography.R")
library(tidycensus)
options(tidycensus.cache = TRUE)


# Fetch data for the 2000 decennial census for Wisconsin and Minnesota
population_data_2000 <- get_decennial(
geography = "block",
variables = "P001001", # Total population
state = c("WI", "MN"),
year = 2000,
geometry = TRUE, # Include geometry for spatial operations
output = "wide" # Outputs data in a 'wide' format, each variable as a separate column
)

# Fetch data for the 2010 decennial census for Wisconsin and Minnesota
population_data_2010 <- get_decennial(
geography = "block",
variables = "P001001", # Total population
state = c("WI", "MN"),
year = 2010,
geometry = TRUE, # Include geometry for spatial operations
output = "wide" # Outputs data in a 'wide' format, each variable as a separate column
)


# Calculating geographic crosswalks from 2000 blocks to 2010 blocks
# 1) Obtain data of interest for 2000 blocks (see population_data_2000 above) and download crosswalk
crosswalkMN <- read_csv(here("_energy", "data-raw", "nhgis_blk2000_blk2010_MN", "nhgis_blk2000_blk2010_ge_27.csv"))
crosswalkWI <- read_csv(here("_energy", "data-raw", "nhgis_blk2000_blk2010_WI", "nhgis_blk2000_blk2010_ge_55.csv"))
CombinedCrosswalk <- rbind(crosswalkMN, crosswalkWI) %>%
mutate(
GEOID00 = as.character(GEOID00),
GEOID10 = as.character(GEOID10)
)

# 2) Join the 2000-block-to-2010-block crosswalk to the 2000 block data of interest
crosswalkPop_2000_to_2010 <- population_data_2000 %>%
left_join(CombinedCrosswalk,
by = join_by(GEOID == GEOID00)
) %>%
# 3) Multiply the 2000 block counts by the crosswalk's interpolation weights, producing estimated counts for all 2000-2010 block intersections, or "atoms"
mutate(
pop2000_inAtom = P001001 * WEIGHT
) %>%
# 4) Sum these atom counts for each 2010 block, join to 2010 data of interest (population_data_2010)
group_by(GEOID10) %>%
summarise(
popIn2000_on2010blocks = sum(pop2000_inAtom)
)

crosswalkPop_2000_to_2010_centroids <- st_centroid(crosswalkPop_2000_to_2010) %>%
mutate(
GEOID10 = as.character(GEOID10)
) %>%
mutate(
state = case_when(
substr(as.character(GEOID10), 1, 2) == "27" ~ "MN",
substr(as.character(GEOID10), 1, 2) == "55" ~ "WI",
TRUE ~ NA_character_
)
)


GEOID10_2000_2005_2010_population_MNWI <- crosswalkPop_2000_to_2010_centroids %>%
left_join(st_drop_geometry(population_data_2010),
by = join_by(GEOID10 == GEOID)
) %>%
rename(
totalPop2010 = P001001,
totalPop2000 = popIn2000_on2010blocks
) %>%
mutate(
totalPop2005_interpolated = ((totalPop2000 + totalPop2010) / 2)
)

GEOID10_2005_population_MNWI <- GEOID10_2000_2005_2010_population_MNWI %>%
select(-totalPop2000, -NAME, -totalPop2010)

est_state_pop_2005 <- st_drop_geometry(GEOID10_2005_population_MNWI) %>%
group_by(state) %>%
summarize(
state_population = sum(totalPop2005_interpolated)
)


# rejoin back to cprg_county to hold onto necessary reference data
cprg_county_population2005_export <- cprg_county %>%
left_join((st_drop_geometry(intercensal_pop_2005_MNWI)),
by = join_by(NAMELSAD == county_name)
) %>%
mutate(
year = 2005,
county_population = round(population_2005_censusInterp)
) %>%
group_by(STATE) %>%
mutate(
state_population = sum(county_population)
) %>%
ungroup() %>%
mutate(
county_proportion_of_state_pop = county_population / state_population,
population_data_source = "Interpolation of data from Summmary File 1, 2000/2010 Decennial Census based on 2000-2010 Geographic Crosswalk from IPUMS NHGIS, University of Minnesota"
) %>%
select(-population_2005_censusInterp)


# write_sf(crosswalkPop_2000_to_2010,here("_energy", "data-raw", "geoCrosswalk","crosswalkPop_2000_to_2010_blocks_MNWI.shp"))
# write_sf(GEOID10_2000_2005_2010_population_MNWI,here("_energy", "data-raw", "geoCrosswalk","GEOID10_2000_2005_2010_population_MNWI.shp"))
1 change: 1 addition & 0 deletions _energy/data-raw/_run_energy.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ electric_natgas_nrel_proportioned <- electric_raw %>%
) %>%
mutate(category = str_to_sentence(category))

waldo::compare(electric_natgas_nrel_proportioned, readRDS("_energy/data/electric_natgas_nrel_proportioned.RDS"))
saveRDS(electric_natgas_nrel_proportioned, "_energy/data/electric_natgas_nrel_proportioned.RDS")
5 changes: 3 additions & 2 deletions _energy/data-raw/kerosene-estimate-2021.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ wi_kero_use <- as.numeric(eia2020[6, 12])
# print(n = 10000)

# get number of households in each county using propane
mn_kero_hh <- get_acs(
mn_kero_hh <- tidycensus::get_acs(
geography = "county",
variables = "B25040_005",
state = "MN",
Expand All @@ -73,7 +73,7 @@ mn_kero_hh <- get_acs(
)

# repeat for WI
wi_kero_hh <- get_acs(
wi_kero_hh <- tidycensus::get_acs(
geography = "county",
variables = "B25040_005",
state = "WI",
Expand All @@ -94,4 +94,5 @@ kero_county
total_regional_kerosene_emissions <- sum(kero_county$CO2e) # total regional emissions of the 11 county area
total_regional_kerosene_emissions

waldo::compare(kero_county, readRDS("_energy/data-raw/kerosene_use_county.RDS"))
saveRDS(kero_county, "_energy/data-raw/kerosene_use_county.RDS")
Binary file modified _energy/data-raw/kerosene_use_county.RDS
Binary file not shown.
Binary file modified _energy/data-raw/nrel_slope/nrel_emissions.RDS
Binary file not shown.
Binary file modified _energy/data-raw/nrel_slope/nrel_slope_proportions.RDS
Binary file not shown.
5 changes: 3 additions & 2 deletions _energy/data-raw/propane-estimate-2021.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ wi_prop_use <- eia2020[64, 15] # 66.5
# print(n = 10000)

# get number of households in each county using propane
mn_prop_hh <- get_acs(
mn_prop_hh <- tidycensus::get_acs(
geography = "county",
variables = "B25040_003",
state = "MN",
Expand All @@ -69,7 +69,7 @@ mn_prop_hh <- get_acs(
)

# repeat for WI
wi_prop_hh <- get_acs(
wi_prop_hh <- tidycensus::get_acs(
geography = "county",
variables = "B25040_003",
state = "WI",
Expand All @@ -93,4 +93,5 @@ total_regional_propane_emissions <- sum(prop_county$CO2e) # total regional emiss


total_regional_propane_emissions
waldo::compare(prop_county, readRDS("_energy/data-raw/propane_use_county.RDS"))
saveRDS(prop_county, "_energy/data-raw/propane_use_county.RDS")
Binary file modified _energy/data-raw/propane_use_county.RDS
Binary file not shown.
Binary file modified _energy/data/MN_elecUtils.RDS
Binary file not shown.
Binary file modified _energy/data/MN_electricity_inScope_utilityCountyPairs.RDS
Binary file not shown.
Binary file modified _energy/data/MN_fed_natGasUtils.RDS
Binary file not shown.
Binary file modified _energy/data/MN_natGas_inScope_utilityCountyPairs.RDS
Binary file not shown.
Binary file modified _energy/data/WI_elecUtils_allTypes.RDS
Binary file not shown.
Binary file modified _energy/data/WI_electricity_inScope_utilityCountyPairs.RDS
Binary file not shown.
Binary file modified _energy/data/WI_inScope_elecUtils_fullServTerr.RDS
Binary file not shown.
Binary file modified _energy/data/WI_natGasUtils.RDS
Binary file not shown.
Binary file modified _energy/data/WI_natGas_inScope_utilityCountyPairs.RDS
Binary file not shown.
Binary file modified _energy/data/distinct_electricity_util_type_MN.RDS
Binary file not shown.
Binary file modified _energy/data/distinct_electricity_util_type_WI.RDS
Binary file not shown.
Binary file modified _energy/data/distinct_natGas_util_WI.RDS
Binary file not shown.
Binary file modified _energy/data/distinct_natGas_util_type_MN.RDS
Binary file not shown.
Binary file modified _energy/data/electric_natgas_nrel_proportioned.RDS
Binary file not shown.
Binary file modified _energy/data/fuel_use.RDS
Binary file not shown.
Binary file modified _energy/data/fuel_use_meta.RDS
Binary file not shown.
Binary file modified _energy/data/minnesota_QA_versusEIAStateProfile.RDS
Binary file not shown.
Binary file modified _energy/data/minnesota_county_ElecEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/minnesota_county_GasEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/minnesota_elecUtils_ActivityAndEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/minnesota_gasUtils_ActivityAndEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/wisconsin_QA_versusEIAStateProfile.RDS
Binary file not shown.
Binary file modified _energy/data/wisconsin_county_ElecEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/wisconsin_county_GasEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/wisconsin_elecUtils_ActivityAndEmissions.RDS
Binary file not shown.
Binary file modified _energy/data/wisconsin_gasUtils_ActivityAndEmissions.RDS
Binary file not shown.
59 changes: 56 additions & 3 deletions _meta/data-raw/cprg_county_proportions.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,69 @@ decennial_proportions <- tidycensus::get_decennial("county",
population_data_source
)

# intercensal population estimates provided by US Census for 2005 at county level
# downloaded from https://www.census.gov/data/tables/time-series/demo/popest/intercensal-2000-2010-counties.html and cleaned to read/save as CSV

intercensal_pop_2005_MN <- read_csv(here("_energy", "data-raw", "nhgis_blk2000_blk2010_MN", "co-est00int-01-27.csv")) %>%
mutate(
county_name = sub("^\\.", "", county_name),
state = "MN"
)
intercensal_pop_2005_WI <- read_csv(here("_energy", "data-raw", "nhgis_blk2000_blk2010_WI", "co-est00int-01-55.csv")) %>%
mutate(
county_name = sub("^\\.", "", county_name),
state = "WI"
)

# calculate total state populations in 2005 and add back as constant column
# MN
total_pop_MN <- intercensal_pop_2005_MN %>%
summarise(state_population = sum(`2005`, na.rm = TRUE))

intercensal_pop_2005_MN <- intercensal_pop_2005_MN %>%
mutate(
year = 2005,
state_population = total_pop_MN$state_population
) %>%
rename(
county_population = `2005`
)

# WI
total_pop_WI <- intercensal_pop_2005_WI %>%
summarise(state_population = sum(`2005`, na.rm = TRUE))

intercensal_pop_2005_WI <- intercensal_pop_2005_WI %>%
mutate(
year = 2005,
state_population = total_pop_WI$state_population
) %>%
rename(
county_population = `2005`
)

intercensal_pop_2005_MNWI <- rbind(intercensal_pop_2005_MN, intercensal_pop_2005_WI) %>%
mutate(
year = as.character(year),
county_proportion_of_state_pop = county_population / state_population,
population_data_source = "US Census County Intercensal Tables: 2000-2010 (2005)"
)

cprg_county_population2005 <- cprg_county %>%
left_join((intercensal_pop_2005_MNWI),
by = join_by(NAMELSAD == county_name, STATE_ABB == state)
) %>%
st_drop_geometry() %>%
select(-NAMELSAD)

cprg_county_proportions <-
bind_rows(
acs_proportions,
decennial_proportions
decennial_proportions,
cprg_county_population2005
)




cprg_county_proportions_meta <- bind_rows(
cprg_county_meta,
tribble(
Expand Down
1 change: 0 additions & 1 deletion _meta/data-raw/epa_nei.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# get data from the 2020 national emissions inventory
# graphic model here: https://www.epa.gov/enviro/nei-model
source("R/_load_pkgs.R")
source("R/global_warming_potential.R")
library(httr2)
cprg_county <- readRDS("_meta/data/cprg_county.RDS")

Expand Down
6 changes: 4 additions & 2 deletions _meta/data-raw/nrel_slope_emissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ city_emissions <- raw_city_emissions %>%
stringr::str_remove(" village, WI")
) %>%
# filter to our states, our cities
filter(state_name %in% c("MN", "WI"),
city %in% cprg_city$CTU_NAME)
filter(
state_name %in% c("MN", "WI"),
city %in% cprg_city$CTU_NAME
)


city_emissions
10 changes: 5 additions & 5 deletions _meta/data-raw/nrel_slope_scenario.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# The scenario planning tool is interactive, so we can't download directly
# from a single link
# I downloaded each state and county manually and added each to our MS Team site
#
#
source("R/_load_pkgs.R")
if (!file.exists("_meta/data-raw/nrel_slope/scenario_planner/anoka_reference/c03e2f7f40cf72b29fdb11fe595cc6851bf4ed23c592b02d0014c6db-CO2-emissions-county.csv")) {
cli::cli_abort("You need to download the raw data from MS Teams. Contact a project lead if you need help")
Expand Down Expand Up @@ -66,12 +66,12 @@ nrel_reference_county <- bind_rows(
county = "Dakota"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/hennepin_reference/d037c812b9dd6dc0d9b42c6bbb97213172391853a9ac4e83ec5c3628_county.csv",
state = "MN",
county = "Hennepin"
state = "MN",
county = "Hennepin"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/ramsey_reference/4e0b8987e8d3b66893a4e348f049eed5af27c7d000b4e7c1f28cb2eb-CO2-emissions-county.csv",
state = "MN",
county = "Ramsey"
state = "MN",
county = "Ramsey"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/pierce_reference/a4794ae3e72bcab0cd614f877d587092b9f5944e137d9574704875b4-CO2-emissions-county.csv",
state = "WI",
Expand Down
Loading

0 comments on commit c7da7e3

Please sign in to comment.