## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment  = "#>",
  eval     = FALSE
)

## ----echo=FALSE, eval = TRUE, out.width="90%", fig.cap="Species currently covered in GLEAM"----
knitr::include_graphics("images/overview_AnimalSilhouette.png")

## ----installation-------------------------------------------------------------
# # Install devtools if not already available
# install.packages("devtools")
# 
# # Install the gleam package from GitHub
# devtools::install_git("https://github.com/un-fao/GLEAM.git")

## ----quick-start--------------------------------------------------------------
# library(gleam)
# library(data.table)
# 
# # ---- Load sample data from inst/extdata ----
# path <- system.file("extdata/run_gleam_examples", package = "gleam")
# 
# cohort_dt      <- fread(file.path(path, "master_chrt_lvl_no_structure_data.csv"))
# herd_dt        <- fread(file.path(path, "master_hrd_lvl_data.csv"))
# rations_dt     <- fread(file.path(path, "feed_rations_share_chrt.csv"))
# feed_params_dt <- fread(file.path(path, "feed_quality.csv"))
# feed_emis_dt   <- fread(file.path(path, "feed_emission_factors.csv"))
# mms_frac_dt    <- fread(file.path(path, "manure_management_system_fraction.csv"))
# mms_fact_dt    <- fread(file.path(path, "manure_management_system_factors.csv"))
# 
# # ---- Run the full GLEAM pipeline ----
# results <- run_gleam(
#   has_herd_structure                = FALSE,
#   cohort_level_data                 = cohort_dt,
#   herd_level_data                   = herd_dt,
#   feed_rations                      = rations_dt,
#   feed_params                       = feed_params_dt,
#   feed_emissions                    = feed_emis_dt,
#   manure_management_system_fraction = mms_frac_dt,
#   manure_management_system_factors  = mms_fact_dt,
#   simulation_duration               = 365,
#   global_warming_potential_set      = "AR6"
# )
# 
# # ---- Inspect results ----
# print(results$cohort_level_results)
# print(results$allocation_long)
# print(results$aggregation_results$results_emissions)

## ----individual-module--------------------------------------------------------
# # Assumes cohort_level_data and herd_level_data have been prepared with
# # weight and ration quality variables already merged in.
# energy_results <- run_metabolic_energy_req_module(
#   cohort_level_data = my_cohort_data,
#   herd_level_data   = my_herd_data
# )

## ----individual-functions-----------------------------------------------------
# e_maint <- calc_metabolic_energy_req_maintenance(
#   species_short              = "CTL",
#   cohort_short               = "FA",
#   live_weight_cohort_average = 450,
#   lactating_females_fraction = 0.7,
#   offtake_rate               = 0.15,
#   age_first_parturition      = 1095
# )

## ----echo=FALSE, eval = TRUE, out.width="100%", fig.cap="Livestock agrifood systems and the GLEAM system boundary"----
knitr::include_graphics("images/overview_GLEAM_SystemBoundary.png")

## ----echo=FALSE, eval = TRUE, out.width="30%", fig.cap="bmleh logo"-----------
knitr::include_graphics("images/overview_Logo_BMLEH_EN.png")

