cdmAmsIIf-methodology.RmdThis vignette demonstrates how to reproduce the AMS-II.F calculations
using cdmAmsIIf. The methodology covers agricultural energy
efficiency and fuel switching projects that reduce fossil fuel use in
processing, irrigation, or cooling systems. The core steps include
estimating baseline emissions, calculating project emissions, accounting
for leakage, and deriving net emission reductions.
library(cdmAmsIIf)
baseline <- tibble::tibble(
baseline_total_energy_mwh = c(220, 195),
baseline_fuel_energy_gj = c(320, 180),
baseline_fuel_emission_factor_tco2_per_gj = c(0.07, 0.072),
service_level_indicator = c(420, 380)
)
project <- tibble::tibble(
project_total_energy_mwh = c(150, 138),
project_fuel_energy_gj = c(210, 120),
project_fuel_emission_factor_tco2_per_gj = c(0.045, 0.05),
service_level_indicator = c(420, 380)
)
monitoring <- tibble::tibble(
project_total_energy_mwh = c(12.5, 11.2),
service_level_indicator = c(0.35, 0.32),
operating_hours = c(220, 215)
)
applicability <- assess_ams_iif_applicability(
baseline_data = baseline,
project_data = project,
monitoring_data = monitoring,
intensity_args = list(energy_col = "baseline_total_energy_mwh",
project_energy_col = "project_total_energy_mwh",
output_col = "service_level_indicator"),
fuel_switch_args = list(energy_col = "baseline_fuel_energy_gj",
emission_factor_col = "baseline_fuel_emission_factor_tco2_per_gj",
project_energy_col = "project_fuel_energy_gj",
project_emission_factor_col = "project_fuel_emission_factor_tco2_per_gj")
)
applicability## # A tibble: 3 × 2
## criterion is_met
## <chr> <lgl>
## 1 energy_intensity TRUE
## 2 fuel_switching TRUE
## 3 monitoring TRUE
set.seed(2024)
example_data <- simulate_ams_iif_dataset(n_facilities = 3, n_periods = 4)
quiet_kable(
head(example_data),
format = "html",
digits = 3
)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| facility_id | monitoring_period | year | month | day | monitoring_date | monitoring_label | baseline_electricity_mwh | baseline_fuel_energy_gj | baseline_electricity_emission_factor_tco2_per_mwh | baseline_fuel_emission_factor_tco2_per_gj | baseline_total_energy_mwh | project_electricity_mwh | project_fuel_energy_gj | project_electricity_emission_factor_tco2_per_mwh | project_fuel_emission_factor_tco2_per_gj | project_total_energy_mwh | service_level_indicator | operating_hours | leakage_emissions_tco2e |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| facility_01 | 1 | 2023 | 1 | 2 | 2023-01-02 | 2023-01 | 111.742 | 446.519 | 0.659 | 0.073 | 235.775 | 87.159 | 276.842 | 0.659 | 0.048 | 164.059 | 162.348 | 205.697 | 0.393 |
| facility_01 | 2 | 2023 | 2 | 5 | 2023-02-05 | 2023-02 | 97.867 | 507.586 | 0.629 | 0.064 | 238.863 | 76.337 | 314.703 | 0.629 | 0.042 | 163.754 | 165.923 | 228.007 | 0.392 |
| facility_01 | 3 | 2023 | 3 | 13 | 2023-03-13 | 2023-03 | 151.817 | 402.109 | 0.556 | 0.064 | 263.514 | 118.417 | 249.308 | 0.556 | 0.041 | 187.669 | 172.027 | 209.413 | 0.308 |
| facility_01 | 4 | 2023 | 4 | 28 | 2023-04-28 | 2023-04 | 160.971 | 453.356 | 0.552 | 0.065 | 286.904 | 125.558 | 281.081 | 0.552 | 0.042 | 203.636 | 171.502 | 238.673 | 0.353 |
| facility_02 | 1 | 2023 | 1 | 17 | 2023-01-17 | 2023-01 | 147.384 | 290.333 | 0.617 | 0.070 | 228.032 | 114.960 | 180.007 | 0.617 | 0.045 | 164.961 | 194.928 | 225.484 | 0.244 |
| facility_02 | 2 | 2023 | 2 | 13 | 2023-02-13 | 2023-02 | 57.488 | 410.071 | 0.536 | 0.060 | 171.397 | 44.841 | 254.244 | 0.536 | 0.039 | 115.464 | 150.018 | 219.691 | 0.297 |
The simulation includes monitoring metadata
(facility_id, year, month,
day, and monitoring_label) alongside baseline
fuel and electricity use, project conditions, service indicators, and
leakage placeholders.
baseline_emissions <- calculate_baseline_agricultural_emissions(
example_data,
group_cols = c("facility_id", "monitoring_label")
)
project_emissions <- calculate_project_agricultural_emissions(
example_data,
group_cols = c("facility_id", "monitoring_label")
)
leakage_emissions <- calculate_leakage_emissions_iif(
example_data,
group_cols = c("facility_id", "monitoring_label"),
leakage_col = "leakage_emissions_tco2e"
)
emission_reductions <- calculate_emission_reductions_iif(
baseline_emissions,
project_emissions,
leakage_emissions,
group_cols = c("facility_id", "monitoring_label")
)
quiet_kable(head(emission_reductions), format = "html", digits = 3)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| facility_id | monitoring_label | emission_reductions_tco2e |
|---|---|---|
| facility_01 | 2023-01 | 35.362 |
| facility_01 | 2023-02 | 32.676 |
| facility_01 | 2023-03 | 33.572 |
| facility_01 | 2023-04 | 36.752 |
| facility_02 | 2023-01 | 31.898 |
| facility_02 | 2023-02 | 21.253 |
period_summary <- aggregate_monitoring_periods_iif(
monitoring_data = example_data,
period_col = "monitoring_label",
group_cols = "facility_id"
)
quiet_kable(period_summary, format = "html", digits = 3)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| facility_id | monitoring_period | year | month | day | baseline_electricity_mwh | baseline_fuel_energy_gj | baseline_electricity_emission_factor_tco2_per_mwh | baseline_fuel_emission_factor_tco2_per_gj | baseline_total_energy_mwh | project_electricity_mwh | project_fuel_energy_gj | project_electricity_emission_factor_tco2_per_mwh | project_fuel_emission_factor_tco2_per_gj | project_total_energy_mwh | service_level_indicator | operating_hours | leakage_emissions_tco2e |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| facility_01 | 2023-01, 2023-02, 2023-03, 2023-04 | 8092 | 10 | 48 | 522.397 | 1809.571 | 2.396 | 0.266 | 1025.056 | 407.470 | 1121.934 | 2.396 | 0.173 | 719.118 | 671.800 | 881.791 | 1.446 |
| facility_02 | 2023-01, 2023-02, 2023-03, 2023-04 | 8092 | 10 | 65 | 457.705 | 1425.238 | 2.347 | 0.274 | 853.605 | 357.010 | 883.648 | 2.347 | 0.178 | 602.468 | 639.523 | 897.955 | 1.170 |
| facility_03 | 2023-01, 2023-02, 2023-03, 2023-04 | 8092 | 10 | 57 | 509.011 | 1480.094 | 2.241 | 0.285 | 920.148 | 397.028 | 917.658 | 2.241 | 0.185 | 651.933 | 599.562 | 823.475 | 1.273 |
estimate_emission_reductions_ams_iif(
baseline_data = example_data,
project_data = example_data,
leakage_data = example_data,
group_cols = c("facility_id", "monitoring_label"),
leakage_args = list(leakage_col = "leakage_emissions_tco2e")
)## # A tibble: 12 × 3
## facility_id monitoring_label emission_reductions_tco2e
## <chr> <chr> <dbl>
## 1 facility_01 2023-01 35.4
## 2 facility_01 2023-02 32.7
## 3 facility_01 2023-03 33.6
## 4 facility_01 2023-04 36.8
## 5 facility_02 2023-01 31.9
## 6 facility_02 2023-02 21.3
## 7 facility_02 2023-03 39.0
## 8 facility_02 2023-04 25.0
## 9 facility_03 2023-01 37.6
## 10 facility_03 2023-02 25.3
## 11 facility_03 2023-03 25.1
## 12 facility_03 2023-04 35.8
function_reference <- tibble::tibble(
Function = c(
"`calculate_baseline_agricultural_emissions()`",
"`calculate_project_agricultural_emissions()`",
"`calculate_leakage_emissions_iif()`",
"`calculate_emission_reductions_iif()`",
"`aggregate_monitoring_periods_iif()`",
"`estimate_emission_reductions_ams_iif()`",
"`simulate_ams_iif_dataset()`"
),
Signature = c(
"`calculate_baseline_agricultural_emissions(baseline_data, fuel_energy_col = \"baseline_fuel_energy_gj\", fuel_emission_factor_col = \"baseline_fuel_emission_factor_tco2_per_gj\", electricity_col = \"baseline_electricity_mwh\", electricity_emission_factor_col = \"baseline_electricity_emission_factor_tco2_per_mwh\", group_cols = NULL, output_col = \"baseline_emissions_tco2e\")`",
"`calculate_project_agricultural_emissions(project_data, fuel_energy_col = \"project_fuel_energy_gj\", fuel_emission_factor_col = \"project_fuel_emission_factor_tco2_per_gj\", electricity_col = \"project_electricity_mwh\", electricity_emission_factor_col = \"project_electricity_emission_factor_tco2_per_mwh\", group_cols = NULL, output_col = \"project_emissions_tco2e\")`",
"`calculate_leakage_emissions_iif(leakage_data, leakage_col = \"leakage_emissions_tco2e\", group_cols = NULL, output_col = \"leakage_emissions_tco2e\")`",
"`calculate_emission_reductions_iif(baseline_emissions, project_emissions, leakage_emissions = NULL, baseline_col = \"baseline_emissions_tco2e\", project_col = \"project_emissions_tco2e\", leakage_col = \"leakage_emissions_tco2e\", output_col = \"emission_reductions_tco2e\", group_cols = NULL)`",
"`aggregate_monitoring_periods_iif(monitoring_data, period_col = \"monitoring_period\", group_cols = NULL, summarise_cols = NULL, output_col = \"monitoring_period\")`",
"`estimate_emission_reductions_ams_iif(baseline_data, project_data, leakage_data = NULL, group_cols = NULL, baseline_args = list(), project_args = list(), leakage_args = list(), reduction_args = list())`",
"`simulate_ams_iif_dataset(n_facilities = 6, n_periods = 12, start_year = 2023, start_month = 1, baseline_electricity_mean = 140, baseline_fuel_mean = 420, electricity_savings = 0.22, fuel_savings = 0.38, fuel_switch_reduction = 0.35)`"
),
Purpose = c(
"Aggregates baseline fossil fuel and electricity use into emissions.<br>\\(BE_y = \\sum_i Fuel^{BL}_{i,y} \\times EF^{fuel,BL}_{i,y} + \\sum_i E^{el,BL}_{i,y} \\times EF^{el,BL}_{i,y}\\)",
"Summarises project energy use into comparable emission totals.<br>\\(PE_y = \\sum_i Fuel^{PR}_{i,y} \\times EF^{fuel,PR}_{i,y} + \\sum_i E^{el,PR}_{i,y} \\times EF^{el,PR}_{i,y}\\)",
"Collects leakage emissions associated with agricultural interventions.<br>\\(LE_y = \\sum_i LE_{i,y}\\)",
"Computes emission reductions from baseline, project, and leakage components.<br>\\(ER_y = BE_y - (PE_y + LE_y)\\)",
"Rolls monitoring data to reporting periods for downstream analysis.<br>\\(ER_{p,y} = BE_{p,y} - (PE_{p,y} + LE_{p,y})\\)",
"Wrapper orchestrating the baseline, project, leakage, and reduction helpers.<br>\\(ER_y = BE_y - (PE_y + LE_y)\\)",
"Generates representative agricultural monitoring datasets for demos and tests."
)
)
quiet_kable(function_reference, format = "html", escape = FALSE)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| Function | Signature | Purpose |
|---|---|---|
calculate_baseline_agricultural_emissions()
|
calculate_baseline_agricultural_emissions(baseline_data, fuel_energy_col = "baseline_fuel_energy_gj", fuel_emission_factor_col = "baseline_fuel_emission_factor_tco2_per_gj", electricity_col = "baseline_electricity_mwh", electricity_emission_factor_col = "baseline_electricity_emission_factor_tco2_per_mwh", group_cols = NULL, output_col = "baseline_emissions_tco2e")
|
Aggregates baseline fossil fuel and electricity use into
emissions. |
calculate_project_agricultural_emissions()
|
calculate_project_agricultural_emissions(project_data, fuel_energy_col = "project_fuel_energy_gj", fuel_emission_factor_col = "project_fuel_emission_factor_tco2_per_gj", electricity_col = "project_electricity_mwh", electricity_emission_factor_col = "project_electricity_emission_factor_tco2_per_mwh", group_cols = NULL, output_col = "project_emissions_tco2e")
|
Summarises project energy use into comparable emission
totals. |
calculate_leakage_emissions_iif()
|
calculate_leakage_emissions_iif(leakage_data, leakage_col = "leakage_emissions_tco2e", group_cols = NULL, output_col = "leakage_emissions_tco2e")
|
Collects leakage emissions associated with agricultural
interventions. |
calculate_emission_reductions_iif()
|
calculate_emission_reductions_iif(baseline_emissions, project_emissions, leakage_emissions = NULL, baseline_col = "baseline_emissions_tco2e", project_col = "project_emissions_tco2e", leakage_col = "leakage_emissions_tco2e", output_col = "emission_reductions_tco2e", group_cols = NULL)
|
Computes emission reductions from baseline, project, and leakage
components. |
aggregate_monitoring_periods_iif()
|
aggregate_monitoring_periods_iif(monitoring_data, period_col = "monitoring_period", group_cols = NULL, summarise_cols = NULL, output_col = "monitoring_period")
|
Rolls monitoring data to reporting periods for downstream
analysis. |
estimate_emission_reductions_ams_iif()
|
estimate_emission_reductions_ams_iif(baseline_data, project_data, leakage_data = NULL, group_cols = NULL, baseline_args = list(), project_args = list(), leakage_args = list(), reduction_args = list())
|
Wrapper orchestrating the baseline, project, leakage, and reduction
helpers. |
simulate_ams_iif_dataset()
|
simulate_ams_iif_dataset(n_facilities = 6, n_periods = 12, start_year = 2023, start_month = 1, baseline_electricity_mean = 140, baseline_fuel_mean = 420, electricity_savings = 0.22, fuel_savings = 0.38, fuel_switch_reduction = 0.35)
|
Generates representative agricultural monitoring datasets for demos and tests. |
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| Step | Purpose |
|---|---|
| Input agricultural monitoring data | Collect facility-level baseline, project, and leakage metrics. |
| calculate_baseline_agricultural_emissions | Translate baseline fuel and electricity use into emissions. |
| calculate_project_agricultural_emissions | Quantify project emissions after efficiency and fuel-switch measures. |
| calculate_leakage_emissions_iif | Summarise leakage contributions across the supply chain. |
| calculate_emission_reductions_iif | Compute net emission reductions for each facility-period. |
| estimate_emission_reductions_ams_iif | Return a tidy tibble with reductions and diagnostic columns. |