Skip to content

Commit

Permalink
Merge pull request #92 from Metropolitan-Council/nrel-slope-emissions
Browse files Browse the repository at this point in the history
NREL SLOPE emissions and scenario data import
  • Loading branch information
ksmiff33 authored Jun 28, 2024
2 parents 0c5c476 + 0fdbf4a commit e3245bf
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,13 @@ _nature/data-raw/land_cover_stock.csv

site_libs/
_nature/_natural_systems_files/*

_meta/data-raw/nrel_slope_emissions/scenario_planner/

_meta/data-raw/nrel_slope_emissions/

_meta/data-raw/nrel_slope/scenario_planner/

_meta/data-raw/nrel_slope/emissions/

_meta/data-raw/nrel_slope/scenario_planner.zip
2 changes: 1 addition & 1 deletion _energy/data-raw/_run_energy.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ source("_energy/data-raw/wisconsin_natGas_ActivityAndEmissions.R")
source("_energy/data-raw/processed_mn_electricUtil_activityData.R")
source("_energy/data-raw/processed_wi_electricUtil_activityData.R")

source("_energy/data-raw/nrel_slope.R")
source("_energy/data-raw/nrel_slope_energy.R")

# Done!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source("R/_load_pkgs.R")
source("_energy/data-raw/_energy_emissions_factors.R")
source("R/plot_county_emissions.R")
cprg_county <- readRDS("_meta/data/cprg_county.RDS")
# NREL SLOPE data download, cleaning, and light viz
# NREL SLOPE energy consumption and expenditure data download, cleaning, and viz

# 1 Mmbtu is 0.293071 MWH
mmbtu_to_mwh <- 0.293071
Expand Down
46 changes: 46 additions & 0 deletions _meta/data-raw/nrel_slope_emissions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Read in 2020 city-level emissions data from NREL SLOPE tool
source("R/_load_pkgs.R")
cprg_county <- readRDS("_meta/data/cprg_county.RDS")
cprg_city <- readRDS("_meta/data/cprg_ctu.RDS")
# https://maps.nrel.gov/slope/
# Zotero key @murphyStateLocalPlanning2024

# City-level GHG emissions for the year 2020 are estimated by sector and energy
# type and reported in units of carbon dioxide equivalent (CO₂e) based on the
# 100-year time horizon global warming potential of other gases relative to (CO₂).

# Estimates leveraged multiple detailed, open-source, sector-specific models and
# datasets, which estimate current (and recent) energy consumption at county-level
# resolution, including ResStock, ComStock, the 2018 Industrial Energy Databook,
# the 2020 National Emissions Inventory, and the City and County Energy Profiles.


# download city level emissions -----
download.file("https://gds-files.nrel.gov/slope/ghg_emissions_baseline.zip",
destfile = "_meta/data-raw/nrel_slope/emissions/ghg_emissions_baseline.zip"
)
# unzip
unzip("_meta/data-raw/nrel_slope/emissions/ghg_emissions_baseline.zip",
exdir = "_meta/data-raw/nrel_slope/emissions/"
)

# read in CSV
raw_city_emissions <- read.csv("_meta/data-raw/nrel_slope/emissions/ghg_emissions_baseline_us_places_2020.csv") %>%
clean_names()

# filtering and cleaning -----
city_emissions <- raw_city_emissions %>%
mutate(
# extract state name
state_name = stringr::str_sub(city_name, start = -2, end = -1),
# clean city name
city = stringr::str_remove_all(city_name, " city, MN") %>%
stringr::str_remove(" city, WI") %>%
stringr::str_remove(" village, WI")
) %>%
# filter to our states, our cities
filter(state_name %in% c("MN", "WI"),
city %in% cprg_city$CTU_NAME)


city_emissions
99 changes: 99 additions & 0 deletions _meta/data-raw/nrel_slope_scenario.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# data from NREL SLOPE emissions scenario planner
# Reference scenario downloaded only - no interventions
# CO2 emissions only.
# https://maps.nrel.gov/slope/
# Zotero key @schleiferSLOPEScenarioPlanner2023

# This scenario evaluates the effects of business-as-usual projections for the
# evolution of electricity supply and energy demand sectors, incorporating the
# potential impacts of the Inflation Reduction Act. The electricity generation
# mix evolves over time based on existing policies and default market and
# technology assumptions. In this scenario, customer adoption of electric vehicles
# and heat pumps expands significantly over time due to a combination of technology
# cost and performance improvements, as well as incentives from the Inflation Reduction Act.
# The electrification of buildings modeling includes new construction and
# beneficial retrofit applications, while the electrification of vehicles
# modeling assumes that vehicles are replaced at the end of their useful lives.

# 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")
}

# read in state level data -----
nrel_reference_state <-
bind_rows(
read.csv("_meta/data-raw/nrel_slope/scenario_planner/minnesota_reference/a53f3fe1e47c31850239f7b18130bb2b10d6fcbfa78789cc3f04d391-CO2-emissions-state.csv") %>%
clean_names() %>%
mutate(state = "MN"),
read.csv("_meta/data-raw/nrel_slope/scenario_planner/wisconsin_reference/3613af67df1f93b92f59917564f5ac243295e4305ffc066fe88a492c-CO2-emissions-state.csv") %>%
clean_names() %>%
mutate(state = "WI")
)

# function to read in and standard cleaning for county level data -----
# the tables within each county folder do not have a county name column
# so we need to add it manually
read_nrel_scenario <- function(file_path, state, county) {
read.csv(file_path) %>%
clean_names() %>%
mutate(
state = state,
county = county
)
}

# read in and bind together all county tables
nrel_reference_county <- bind_rows(
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/anoka_reference/c03e2f7f40cf72b29fdb11fe595cc6851bf4ed23c592b02d0014c6db-CO2-emissions-county.csv",
state = "MN",
county = "Anoka"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/carver_reference/bec31af0df88e9aee2dc23c8c2824bcafc0853354ff2ff47d3d4c543-CO2-emissions-county.csv",
state = "MN",
county = "Carver"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/chisago_reference/39b909e572184b8a8531342c8a5315589d75204019182c61b0dcc745-CO2-emissions-county.csv",
state = "MN",
county = "Chisago"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/dakota_reference/8a5f4c944361f69342e894c13702c1b743f6e3fc9946dd0f36c9d2b4-CO2-emissions-county.csv",
state = "MN",
county = "Dakota"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/hennepin_reference/d037c812b9dd6dc0d9b42c6bbb97213172391853a9ac4e83ec5c3628_county.csv",
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"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/pierce_reference/a4794ae3e72bcab0cd614f877d587092b9f5944e137d9574704875b4-CO2-emissions-county.csv",
state = "WI",
county = "Pierce"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/scott_reference/14e98aa5e7ac6c0c9914193b44c825c680a042941e86ac4697c5b183-CO2-emissions-county.csv",
state = "MN",
county = "Scott"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/sherburne_reference/3fac4bb99b09007be8365f62fb7853db53487c6d8ada61287368e059-CO2-emissions-county.csv",
state = "MN",
county = "Sherburne"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/st_croix_reference/335ef3b33af8dbcd9d62044979ca32a959ebca1d7965689de8ac3edc-CO2-emissions-county.csv",
state = "WI",
county = "St. Croix"
),
read_nrel_scenario("_meta/data-raw/nrel_slope/scenario_planner/washington_reference/00ce19fbf4747a8696d1bc68b7590a9a702c270364883d01901ed16b-CO2-emissions-county.csv",
state = "MN",
county = "Washington"
),
)


length(unique(nrel_reference_county$county))
Loading

0 comments on commit e3245bf

Please sign in to comment.