Skip to contents

Bridge between build_primary_production() output and the livestock emission functions. Maps species codes to names, converts area codes to ISO3, extracts milk and meat yields, and optionally expands herds into GLEAM cohorts.

Any extra columns present in the input (e.g., weight, diet_quality, fat_percent) are preserved and flow through to the emission functions automatically.

Usage

prepare_livestock_emissions(
  data,
  expand_cohorts = FALSE,
  system_shares = NULL,
  method_cohorts = c("milk_animals", "uniform")
)

Arguments

data

A tibble from build_primary_production() with columns item_cbs_code, unit, value, and optionally year, area_code, live_anim_code.

expand_cohorts

Logical. If TRUE, distributes herds across GLEAM cohorts and production systems via calculate_cohorts_systems(). Default FALSE.

system_shares

Optional dataframe with custom system shares. Passed to calculate_cohorts_systems().

method_cohorts

How heads are split across the cohorts of a system:

  • "milk_animals" (default): a dairy-cattle herd ("Cattle, dairy", the FAOSTAT Milk Animals count) goes wholly to the dairy system's "Adult Female" cohort; every other herd is split equally across its system's cohorts.

  • "uniform": every herd, dairy cattle included, is split equally across its system's cohorts, the behaviour before whep#1127. It books five sixths of the milking cows as bulls, heifers and calves, and is kept for sensitivity analysis.

Value

A tibble with columns species, heads, iso3 (if area_code present), and optionally milk_yield_kg_day, method_milk_yield, weight_gain_kg_day, cohort columns, plus all extra columns from the input. Milk is read for every milked species FAOSTAT reports (cattle, buffalo, sheep, goats, camels), not only for an animal's designated product, and with expand_cohorts = TRUE it sits on the milked cohort only (see calculate_cohorts_systems()).

Examples

tibble::tibble(
  item_cbs_code = 961,
  unit = "heads",
  value = 5000,
  area_code = 79L
) |>
  prepare_livestock_emissions()
#> # A tibble: 1 × 6
#>   item_cbs_code unit  heads area_code species           iso3 
#>           <dbl> <chr> <dbl>     <int> <chr>             <chr>
#> 1           961 heads  5000        79 Cattle, non-dairy DEU