Skip to contents

Depending on how the period is defined and if the data are annualized or not, calculate the Emission Level for a reference or monitoring period for each simulation.

Usage

fct_combine_mcs_ER(.sim_ref, .sim_mon, .ad_annual)

Arguments

.sim_ref

simulation aggregated to reference period, output from fct_combine_mcs_P()

.sim_mon

simulation aggregated to monitoring period(s), output from fct_combine_mcs_P()

.ad_annual

TRUE or FALSE, is the activity data annualized or not.

Value

A tibble with simulations at the final estimate per type of period.

Examples

library(readxl)
library(dplyr)
library(mocaredd)

path <- system.file("extdata/example1-4pools.xlsx", package = "mocaredd")

cs <- read_xlsx(path = path, sheet = "c_stocks", na = "NA")
ad <- read_xlsx(path = path, sheet = "AD_lu_transitions", na = "NA")
usr <- read_xlsx(path = path, sheet = "user_inputs", na = "NA")
time <- read_xlsx(path = path, sheet = "time_periods", na = "NA")

time_clean <- time |> dplyr::mutate(nb_years = year_end - year_start + 1)

sim_trans <- fct_combine_mcs_E(.ad = ad, .cs = cs, .usr = usr)
#> Error in pmap(combi, function(period, lu) {    c_sub <- filter(.cs, .data$c_period == period, .data$c_lu_id ==         lu)    c_check <- fct_check_pool(.c_sub = c_sub, .c_unit = .usr$c_unit,         .c_fraction = .usr$c_fraction)}): could not find function "pmap"

sim_REF <- fct_combine_mcs_P(
  .data = sim_trans,
  .time = time_clean,
  .period_type = "REF",
  .ad_annual = usr$ad_annual
)
#> Error in purrr::map(unique(time_ref$period_type), function(x) {    dplyr::summarise(dplyr::group_by(dplyr::filter(dplyr::left_join(.data,         time_ref, by = c(time_period = "period_no")), .data$period_type ==         x), .data$sim_no, .data$period_type), E_sim = round(sum(.data$E_sim *         .data$nb_years)/length_ref, 0), .groups = "drop")}):  In index: 1.
#> Caused by error:
#> ! object 'sim_trans' not found

sim_MON <- fct_combine_mcs_P(
  .data = sim_trans,
  .time = time_clean,
  .period_type = "MON",
  .ad_annual = usr$ad_annual
)
#> Error in purrr::map(unique(time_ref$period_type), function(x) {    dplyr::summarise(dplyr::group_by(dplyr::filter(dplyr::left_join(.data,         time_ref, by = c(time_period = "period_no")), .data$period_type ==         x), .data$sim_no, .data$period_type), E_sim = round(sum(.data$E_sim *         .data$nb_years)/length_ref, 0), .groups = "drop")}):  In index: 1.
#> Caused by error:
#> ! object 'sim_trans' not found

## !!! SIM MON and ER to be done