Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
08745be
Fossil heating shapes and labels
mcpigman Nov 25, 2025
31508f5
Update upgrade numbers to ComStock 2025.1
mcpigman Nov 25, 2025
72e9756
More detailed fossil shapes
mcpigman Dec 2, 2025
e977306
res fossil hourly mults
mcpigman Dec 2, 2025
e4e5b3b
res hourly calculation with fuel
mcpigman Dec 2, 2025
1b0cdb5
Add fuel to res annual disaggregation
mcpigman Dec 3, 2025
6ded2af
cleaner method for res hourly disagg with fuel
mcpigman Dec 3, 2025
122f5ee
Update ComStock table names
mcpigman Dec 3, 2025
08cad1e
Remove reference to obsolete version column
mcpigman Dec 3, 2025
460ae4b
Remove lingering references to version
mcpigman Dec 3, 2025
effc90e
Fix misc typos
mcpigman Dec 3, 2025
aff69c0
Add fuel to com
mcpigman Dec 3, 2025
a336056
Update mappings
mcpigman Dec 4, 2025
5120b57
Misc multiplier fixes
mcpigman Dec 5, 2025
4c29df2
Typo
mcpigman Dec 5, 2025
2c6632e
Troubleshooting
mcpigman Dec 15, 2025
e3a6130
Define res hourly multipliers by weather file * longitude (instead of…
mcpigman Dec 16, 2025
f5da9e7
res misc flat doesn't make sense given the calibration methodology
mcpigman Dec 16, 2025
5819045
Normalize res hvac hourly shares separately (weather files cross states)
mcpigman Dec 16, 2025
5101e44
Add fossil shape
mcpigman Dec 17, 2025
6568412
Assign delivered heat group_ann to res bio heat
mcpigman Dec 17, 2025
f397012
Use new com group_ann mapping
mcpigman Dec 17, 2025
5aca1a6
Before changing map_eu table names
mcpigman Dec 17, 2025
6a50479
Renaming mapping files to include 2 to avoid conflicts on Athena
mcpigman Dec 17, 2025
64cb0da
Clarify and rearrange readme
mcpigman Jan 13, 2026
f5d9d96
bss_workflow isn't clean - being used for diagnostics
mcpigman Jan 13, 2026
4389131
Table formatting
mcpigman Jan 13, 2026
2439050
Add time zone mapping
mcpigman Jan 21, 2026
2fbc1e8
Avoid duplicates from bld_id that are used in multiple states
mcpigman Jan 27, 2026
b646e5d
Speed it up!
mcpigman Jan 27, 2026
744fd7b
Clarification
mcpigman Jan 30, 2026
d42dcf9
Remove All and Fossil as fuel options
mcpigman Feb 4, 2026
2c19e9b
Update tests
mcpigman Feb 4, 2026
24e4a03
convert table names to variables
mcpigman Feb 11, 2026
1af64eb
remove bad spaces
mcpigman Feb 11, 2026
ada839a
simplify to ensure samples in all counties/weather files
mcpigman Feb 11, 2026
f163d8e
simplifying more
mcpigman Feb 12, 2026
f85d8cd
Add fossil graphs
mcpigman Mar 2, 2026
3eade0a
working fossil disaggregation
mcpigman Mar 10, 2026
700d021
Cleaning up
mcpigman Mar 13, 2026
933728c
Rename maps and references to them
mcpigman Mar 13, 2026
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
22 changes: 7 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
.DS_Store
/R/graphs
R/.Rhistory
R/.Rhistory
R/.Rhistory
R/graphs
R/.Rhistory
R/.Rhistory
R/.Rhistory
agg_results
scout_results
R/generated_csvs
R/.Rhistory

# Ignore helper and scout folders
helper/
scout/
diagnostics/**
scout_results/**
scout_tsv/**
R/generated_csvs/**
R/graphs/**
agg_results/**
~$*
512 changes: 0 additions & 512 deletions R/.Rhistory

This file was deleted.

49 changes: 0 additions & 49 deletions R/EIA comparison.R

This file was deleted.

177 changes: 166 additions & 11 deletions R/annual_graphs.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,16 @@ setall_codes <- c("aeo","ref","fossil","state","accel","brk","min_switch","dual_
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_sector_scenario", suffix_tag, ".jpeg"),
ggsave(paste0(graph_dir,"/national_annual_sector_eu_scenario_elec", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_2, units="in")

# ----- 1b) national, non-Electric -------------------------------------------
message(paste0("printing national non-electric ", suffix_tag))
df_in %>% filter(fuel!="Electric") %>%
group_by(year, sector, end_use, turnover) %>%

# ----- 1b) national, by fuel -------------------------------------------
message(paste0("printing national by fuel ", suffix_tag))
df_in %>%
group_by(year, sector, fuel, turnover) %>%
summarize(kwh = sum(state_ann_kwh)/1e9, .groups="drop") %>%
ggplot(aes(x=year,y=kwh,fill=end_use)) +
ggplot(aes(x=year,y=kwh,fill=fuel)) +
geom_area() +
facet_grid(sector ~ turnover,
labeller = labeller(turnover = to_lab, sector = sec_lab)) +
Expand All @@ -173,7 +174,7 @@ setall_codes <- c("aeo","ref","fossil","state","accel","brk","min_switch","dual_
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_sector_scenario_fossil", suffix_tag, ".jpeg"),
ggsave(paste0(graph_dir,"/national_annual_sector_scenario_all_fuels", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_2, units="in")


Expand Down Expand Up @@ -210,7 +211,7 @@ setall_codes <- c("aeo","ref","fossil","state","accel","brk","min_switch","dual_
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_", s, "_hvac", suffix_tag, ".jpeg"),
ggsave(paste0(graph_dir,"/national_annual_", s, "_hvac_elec", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h, units="in")
}

Expand All @@ -232,7 +233,7 @@ setall_codes <- c("aeo","ref","fossil","state","accel","brk","min_switch","dual_
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_", s, "_wh", suffix_tag, ".jpeg"),
ggsave(paste0(graph_dir,"/national_annual_", s, "_wh_elec", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_1, units="in")
}

Expand All @@ -256,7 +257,7 @@ setall_codes <- c("aeo","ref","fossil","state","accel","brk","min_switch","dual_
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_", s, "_non-mech", suffix_tag, ".jpeg"),
ggsave(paste0(graph_dir,"/national_annual_", s, "_non-mech_elec", suffix_tag, ".jpeg"),
device="jpeg", width=w_nonmech, height=h_1, units="in")
}

Expand Down Expand Up @@ -285,13 +286,166 @@ setall_codes <- c("aeo","ref","fossil","state","accel","brk","min_switch","dual_
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(
paste0(graph_dir,"/state_annual_", s, "_", eu_lab[u], suffix_tag, ".jpeg"),
paste0(graph_dir,"/state_annual_", s, "_", eu_lab[u], suffix_tag, "_elec.jpeg"),
device="jpeg", width=width_set, height=state_height, units="in"
)
}
}
}



# master plotting function fossil
.make_split_plots_fossil <- function(df_in, suffix_tag, mm_long_ref, state_vec, to_lab, sec_lab, eu_lab, colors_vec) {

# dynamic sizes for the set
scen_levels <- levels(df_in$turnover)
nscen <- length(scen_levels)
width_set <- (3 + nscen) * 1.8
state_height <- length(state_vec) * 1.8

# ----- 1a) national, non-Electric by end use -------------------------------------------
message(paste0("printing national non-electric enduse ", suffix_tag))
df_in %>% filter(fuel!="Electric") %>%
group_by(year, sector, end_use, turnover) %>%
summarize(kwh = sum(state_ann_kwh)/1e9, .groups="drop") %>%
ggplot(aes(x=year,y=kwh,fill=end_use)) +
geom_area() +
facet_grid(sector ~ turnover,
labeller = labeller(turnover = to_lab, sector = sec_lab)) +
scale_y_continuous("TWh", labels = comma_format(),
expand = expansion(add=0, mult=c(0,.05))) +
scale_x_continuous(name = "", expand=c(0,0), breaks = seq(2030,2050,by=10)) +
scale_fill_manual(name = "", labels = eu_lab, values = colors_vec) +
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_sector_scenario_eu_fossil", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_2, units="in")

# ----- 1b) national, non-Electric by fuel -------------------------------------------
message(paste0("printing national non-electric by fuel ", suffix_tag))
df_in %>% filter(fuel!="Electric") %>%
group_by(year, sector, fuel, turnover) %>%
summarize(kwh = sum(state_ann_kwh)/1e9, .groups="drop") %>%
ggplot(aes(x=year,y=kwh,fill=fuel)) +
geom_area() +
facet_grid(sector ~ turnover,
labeller = labeller(turnover = to_lab, sector = sec_lab)) +
scale_y_continuous("TWh", labels = comma_format(),
expand = expansion(add=0, mult=c(0,.05))) +
scale_x_continuous(name = "", expand=c(0,0), breaks = seq(2030,2050,by=10)) +
scale_fill_manual(name = "", labels = eu_lab, values = colors_vec) +
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_sector_scenario_fossil", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_2, units="in")


# ----- 1c) national, non-Electric by fuel and end use -------------------------------------------
message(paste0("printing national non-electric enduse ", suffix_tag))
df_in %>% filter(fuel!="Electric") %>%
group_by(year, sector, end_use, fuel, turnover) %>%
summarize(kwh = sum(state_ann_kwh)/1e9, .groups="drop") %>%
ggplot(aes(x=year,y=kwh,fill=fuel)) +
geom_area() +
facet_grid(sector+end_use ~ turnover,
labeller = labeller(turnover = to_lab, sector = sec_lab)) +
scale_y_continuous("TWh", labels = comma_format(),
expand = expansion(add=0, mult=c(0,.05))) +
scale_x_continuous(name = "", expand=c(0,0), breaks = seq(2030,2050,by=10)) +
scale_fill_manual(name = "", labels = eu_lab, values = colors_vec) +
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_sector_scenario_fossil_eu_fuel", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_2, units="in")

# ----- 3) national by tech type ---------------------------------------------
with_shapes <- df_in %>%
filter(fuel!="Electric") %>%
left_join(mm_long_ref,
by=c("meas",
"end_use" = "Scout_end_use",
"tech_stage",
"sector"))

with_shapes_agg <- with_shapes %>%
group_by(year, end_use, fuel, turnover, sector, description) %>%
summarize(TWh = sum(state_ann_kwh)/1e9, .groups="drop")

# 3a) HVAC (Cooling/Heating/Ventilation)
message(paste0("printing hvac fossil ", suffix_tag))
for (s in c("com","res")) {
h <- ifelse(s=="res", 5, 5)
with_shapes_agg %>%
group_by(description) %>% filter(sum(TWh) > 1) %>% ungroup() %>%
filter(end_use %in% c("Cooling (Equip.)","Heating (Equip.)","Ventilation"),
sector == s) %>%
ggplot(aes(x=year, y=TWh, fill=paste(description,fuel))) +
geom_area() +
facet_grid(end_use ~ turnover,
labeller = labeller(turnover = to_lab, end_use = eu_lab)) +
scale_y_continuous("TWh",
labels = comma_format(),
expand = expansion(add=0, mult=c(0,.05))) +
scale_x_continuous(name="", expand=c(0,0), breaks=seq(2030,2050,by=10)) +
scale_fill_manual(values = colors_vec, name = "") +
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_", s, "_hvac_fossil", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h, units="in")
}

# 3b) Water Heating
message(paste0("printing water heating fossil ", suffix_tag))
for (s in c("com","res")) {
h<-if_else(s=="res",h_2,h_3)
with_shapes_agg %>%
filter(end_use == "Water Heating", sector == s) %>%
group_by(year,fuel,turnover) %>% summarize(TWh=sum(TWh), .groups="drop") %>%
ggplot(aes(x=year, y=TWh, fill=fuel)) +
geom_area() +
facet_grid( ~ turnover, labeller = labeller(turnover = to_lab, end_use = eu_lab)) +
scale_y_continuous("TWh",
labels = comma_format(),
expand = expansion(add=0, mult=c(0,.05))) +
scale_x_continuous(name="", expand=c(0,0), breaks=seq(2030,2050,by=10)) +
scale_fill_manual(values = colors_vec, name = "") +
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_", s, "_wh_fossil", suffix_tag, ".jpeg"),
device="jpeg", width=width_set, height=h_1, units="in")
}

# 3c) Non-HVAC, non-WH
message(paste0("printing non-mech fossil ", suffix_tag))
for (s in c("com","res")) {
w_nonmech <- ifelse(s=="res", (2 + nscen) * 1.8, width_set)
with_shapes_agg %>%
group_by(description,fuel) %>% filter(sum(TWh) > 1) %>% ungroup() %>%
filter(!(end_use %in% c("Water Heating","Heating (Equip.)","Cooling (Equip.)","Ventilation")),
sector == s) %>%
ggplot(aes(x=year, y=TWh, fill=paste(description,fuel))) +
geom_area() +
facet_grid( ~ turnover, labeller = labeller(turnover = to_lab)) +
scale_y_continuous("TWh",
labels = comma_format(),
expand = expansion(add=0, mult=c(0,.05))) +
scale_x_continuous(name="", expand=c(0,0), breaks=seq(2030,2050,by=10)) +
guides(fill = guide_legend(nrow = 12)) +
scale_fill_manual(values = colors_vec, name = "") +
theme(strip.background = element_blank(),
strip.text.y = element_text(angle=-90, size=10),
strip.text.x = element_text(size=10))
ggsave(paste0(graph_dir,"/national_annual_", s, "_non-mech_fossil", suffix_tag, ".jpeg"),
device="jpeg", width=w_nonmech, height=h_1, units="in")
}


# ---- run all three sets -------------------------------------------------------
wide_S1 <- .make_factor(wide, set1_codes)
wide_S2 <- .make_factor(wide, set2_codes)
Expand All @@ -300,3 +454,4 @@ wide_all <- .make_factor(wide, setall_codes)
.make_split_plots_for(wide_S1, "_S1", mm_long, states, to, sec, eu, colors)
.make_split_plots_for(wide_S2, "_S2", mm_long, states, to, sec, eu, colors)
.make_split_plots_for(wide_all, "", mm_long, states, to, sec, eu, colors)
.make_split_plots_fossil(wide_all, "", mm_long, states, to, sec, eu, colors)
Loading