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

126 rebuild wastewater emissions #154

Merged
merged 25 commits into from
Jan 23, 2025

Conversation

ksmiff33
Copy link
Collaborator

Checklist

Please complete this checklist as a courtesy to the PR reviewer.

Code and styling

  • All of the files/scripts I added are in the right place and named appropriately. See the README for details.
  • I have not used setwd()
  • I have used file.path(here::here(), "file_name")) to source any scripts or read in data
  • I have not added any large datasets, unless absolutely necessary (explain)
  • I have commented my code, particularly in hard to understand areas
  • I have added additional package dependencies as necessary with renv::install()
  • I have run styler::style_dir(".", recursive = TRUE, filetype = c("R", "qmd"))
  • Plots
    • If plotly, use source = "chunk-name" in plot_ly()
    • Use formatting with councilR::plotly_layout()?
  • Chunk formatting
    • All chunks named
    • All figure or table chunks have caption
    • out.width: "95%". If a specific height is needed, use pixels. and/or out.height: "500px"

Document editing

  • I have ensured that modified documents knit successfully from render_for_publication.R
  • I have fixed any missing citations, cross references, hyperlinks
  • I have reviewed my contributions for typos and misspellings.

GitHub and project management

  • I have identified and assigned at least one Reviewer (Liz, Sam, Laine) to this PR
  • I have assigned myself to this PR
  • I have updated the status in the GitHub Project

Follows a similar organizational convention to the agriculture sector scripts. In short, the relevant scripts live in _waste/data-raw/wastewater/, exported RDS files go to _waste/data/.

Start by opening the script "00_compile_wastewater_emissions.R".
This sources 5 other scripts, each with a 01, 02, or 03 prefix. These must be run sequentially. The good thing is that you can just source down the entire "00_compile_wastewater_emissions.R" script and it should execute everything in the correct order.

The two "01" scripts return lookup tables from the EPA State Inventory Tool Wastewater Module (as well as annual protein consumption per capita estimates).

The remaining scripts are built so that when you source them, a wrapper function gets added to the environment. Each wrapper function is unique but fundamentally does the same thing: scales ghg emissions per unit person. So for example, the script "02_compile_ww_municipal_ch4.R" returns a function "calculate_mww_ch4_emissions()" which estimates methane emissions from municipal wastewater on a per capita basis.

Running all 3 functions will give a complete inventory of ghg emissions from n2o and ch4 across various wastewater subsectors.

Ancillary data that is absolutely essential here is contained within the "~/_waste/data-raw/wastewater/epa/" directory. Make sure you don't delete the "epa" folder.

Finally, there's a little plotting code at the end of the "00_compile_wastewater_emissions.R" script, just to check how everything looks.

…ased off the EPA State Inventory Tool - Wastewater module

This script hard codes annual rates of protein consumption by humans (see Inventory of U.S. Greenhouse Gas Emissions and Sinks (U.S. EPA 2023))
…EPA State Inventory Tool. This routine runs all subroutines and exports rds files by county, year, and emission source (e.g. municipal wastewater CH4, municipal wastewater n20 direct and effluent)
…ng. Found in Table 7-34 of the EPA's Greenhouse Gas Emissions and Sinks 2023 report.
…s oxide emissions from municipal wastewater.
…ous oxide emissions from municipal wastewater.
@ksmiff33 ksmiff33 self-assigned this Jan 17, 2025
Copy link
Collaborator

@pawilfahrt pawilfahrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely coded. Big improvement over the previous iteration. Note a few comments I made and resolved. We do need to rerun the 00_compile script with CTU data as well. I'll add an issue

@pawilfahrt pawilfahrt merged commit aae5ab1 into dev-2005-baseline Jan 23, 2025
@pawilfahrt pawilfahrt deleted the 126-rebuild-wastewater-emissions branch January 23, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants