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

Transportation emissions, 2002 - 2022 using territorial framework #104

Merged
merged 346 commits into from
Oct 24, 2024

Conversation

eroten
Copy link
Collaborator

@eroten eroten commented Jul 9, 2024

Major changes throughout transportation sector.

  • Transportation emissions
    • New complete emissions dataset from 2002 - 2022 from various EPA sources.
    • compile_county_emissions.R script is updated and tested
    • All data are compiled from SMOKE FF10 downloads.
    • EPA data downloads are logged and documented in _transportation/data-raw/epa/epa_downloads.xlsx and described in README_epa_downloads.html.
    • EPA NEI
      • NEI 2020 is used in the final inventory.
      • Scripts for pulling summary tables from EnviroFacts, reading in on-road regional summary tables, and reading in SMOKE FF10 data are included.
      • EnviroFacts API version pulls multiple sectors, counties, overall more data.
    • EQUATES
      • EQUATES contains on-road vehicle emissions from 2002 to 2019 with consistent vehicle and fuel types. All data were sourced from the CMAS Data Warehouse. No interpolation is necessary (closes EPA emissions - EQUATES intermediary years #120)
    • Air Emissions Modeling
      • Air emissions modeling data come from individual modeling platform releases. These are used for years 2021 and 2022 at this time.
    • Non-road data processing has begun, but is not finalized.
    • Essential datasets and documents used for validation and documentation are included.

Documentation

  • Transportation documentation is now separated out into the discussed results, methods/data sources/validation framework
  • Placeholders are used to mark where future validation/verification will take place in documentation
  • README_epa_downloads.Rmd and subsequent HTML file, along with epa_downloads.xlsx document downloads from the EPA FTP site and the CMAS Data Warehouse.
  • One email thread _transportation/data-raw/epa/Re: Seeking guidance on consistent sccs.pdf is saved for future use regarding source classification codes.
  • For now, old documentation Quarto documents have been moved to _transportation/deprecated for easy access. Much of the code will be useful for future documentation.

Datasets and scripts
- _meta/epa_us_ghgi.R reads in the 2021 edition of the Inventory of U.S. Greenhouse Gas Emissions and Sinks by State: 1990-2021 (EPA GHGI).

  • Transportation data/methods now lives in _transportation/data_methods_transportation.qmd
  • _transportation/_transportation_RDG.R compiled basic emissions data for the first deadline of the Regional Development Guide. See Ensure transportation emissions up to date in RDG #124
  • _transportation_compile.R takes the very large compiled EPA dataset and summarizes it down to the emissions_year, data_source, geoid, county_name, vehicle_weight_label, and vehicle_fuel_label. This is also where non-road and aviation data will be brought in.
  • Many transportation scripts, see _script_descriptions.csv for more detail.

New functions

  • read_smoke_ff10 reads in a SMOKE FF10 file from a given location, filters the data to only include MN and WI counties and certain pollutants, and saves the resulting data in a specified output location. Records metadata and original file names for better documentation. Lives in _transportation/data-raw/_read_smoke_ff10.R
  • listify() takes in a vector and creates a formatted sentence fragment with commas and an "and" preceding the last item in the vector. Taken from a neat blog post. This lives in R/_quarto_helpers.R
  • round_emissions_metric_tons_co2e() takes in a numeric vector and returns a nicely formatted sentence stating CO2e emissions in million or thousand metric tons, depending on value. Lives in R/_plotting_helpers()

Other

  • Reference to IPCC AR5 corrected to IPCC AR6 in supplementary_data.qmd
  • Cleaned up references to, file names, data storage locations for the Inventory of U.S. Greenhouse Gas Emissions and Sinks by State: 1990-2021 (EPA GHGI). Some data processing lived in _transportation/ and waste, but now everything lives in _meta/.
  • General clean-up of unused scripts
  • Bibliography up to date via Zotero.
  • .gitignore up to date
  • Styling changes throughout
  • download_read_table() now checks for an existing file in the given exdir before downloading from internet location. New parameter force_download bypasses this condition, so you can still make a fresh download if desired.
  • Transportation colors updated in cprg_colors.R
  • Additional testing for compiled county emissions dataset
  • plotting functions throw a warning if you attempt to plot more than one year on a single Emissions/County plot
  • source classification codes for transportation only compiled in _transportation/data-raw/epa_source_classification_codes.R. See EPA source classification codes #109

Future considerations

  • We can integrate Quarto variables across all Quarto documents to specify what our "current year" emissions year is. This way, all sectors will use the same year designation ("2021", "2022") to filter the existing plots and datasets.

Like with previous PRs on dev-2005-baseline, the entire Quarto document doesn't knit neatly, but all chunks in the transportation sections run without errors.

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 - Some of the EPA datasets are very large, but have been compressed down. Intermediary .RDS data are available on MS Teams/OneDrive
  • 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 to this PR
  • I have assigned myself to this PR
  • I have updated the status in the GitHub Project

@eroten eroten added the transportation Transportation label Jul 9, 2024
@eroten eroten self-assigned this Jul 9, 2024
@eroten eroten force-pushed the 91-transportation-methodology-explainer branch from fa411ca to 6eda737 Compare July 10, 2024 04:21
@eroten eroten changed the title Transportation emissions, 2005 - 2022 using territorial framework Transportation emissions, 2002 - 2022 using territorial framework Sep 18, 2024
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.

Whew! Amazing work Liz. There are some smallish changes with a few comments that should be quick approves or reverts.

The one exception is that directly reading files from urls continues to cause problems on my machine. Since this can be worked around by downloading and then directing to a file folder (less elegant but functional) I think it's okay to proceed and troubleshoot elsewhere at a later date.

@eroten
Copy link
Collaborator Author

eroten commented Oct 24, 2024

Thank you for your comments, @pawilfahrt! I'm glad we added the path sanitizer and that things flow all together.

@eroten eroten requested a review from pawilfahrt October 24, 2024 18:28
@eroten eroten merged commit 9c3f3da into dev-2005-baseline Oct 24, 2024
@eroten eroten deleted the 91-transportation-methodology-explainer branch October 24, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transportation Transportation
Projects
None yet
2 participants