Skip to content

Instantly share code, notes, and snippets.

@dholstius
Last active November 21, 2019 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dholstius/580cd5a1fecc8e3c6d9decfef04544c0 to your computer and use it in GitHub Desktop.
Save dholstius/580cd5a1fecc8e3c6d9decfef04544c0 to your computer and use it in GitHub Desktop.
BY2015: Animal Waste Emission Factors
#
# BY2011 -> BY2015: emission factors for "animal waste" categories.
#
# Created by dholstius on 2019-11-21 for aguha.
#
# For the link between the two sets of categories, see (in Dropbox):
#
# - BY2015/Work/Crosswalks/Categories/BY2015_categories_geneaology.xlsx
#
# For more about the operations taking place in the code below, see (in R):
#
# - help("DB_area_source_emission_factors")
# - help("annualize_DB_emission_factors")
# - help("t0326") (in R)
# - DB_EMFAC_CONCORDANCE
#
library(inventory)
#'----------------------------------------------------------------------
#
# Part 1:
#
# In the BY2011 inventory, categories 1619:1627 comprise "animal waste".
# Let's retrieve their emission factors.
#'
# To understand where these data are coming from, type `DB_EMFAC_CONCORDANCE`
# (no backticks) in R. Then, have a look at the associated table. For BY2011,
# that would be `t1326` (as of the time of this writing).
#
BY2011_animal_waste_ef_data <-
BY(2011) %>%
DB_area_source_emission_factors(
verbose = TRUE) %>%
filter_categories(
1619:1627)
#
# Display these BY2011 EFs as a table, with pollutants as columns. Since these
# emission factors don't vary over time, this is a fine method.
#
# Every emission factor is assumed to carry forward to subsequent years (until
# it is superseded by a newer one).
#
# If they *did* vary over time, you'd use `annualize_DB_emission_factors()` ---
# to carry them forward --- in conjunction with `chart_annual_quantities()`.
# That sounds complicated, but there is a nice example to show you how. Just
# type `vignette("charting_annual_data")` (no backticks).
#
BY2011_animal_waste_ef_data %>%
tabulate_quantities_by(
year,
cat_id,
pol_abbr)
#'----------------------------------------------------------------------
#
# Part 2:
#
# In the BY2015 inventory, categories 2333:2349 comprise "animal waste".
# See the "geneaology" XLSX mentioned at the beginning of this script.
#
BY2015_animal_waste_ef_data <-
BY(2015) %>%
DB_area_source_emission_factors(
verbose = TRUE) %>%
filter_categories(
2333:2349)
#
# Display these BY2015 EFs in the same manner.
#
BY2015_animal_waste_ef_data %>%
tabulate_quantities_by(
year,
cat_id,
pol_abbr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment