cdmAmsIb-methodology.RmdThis vignette demonstrates how to reproduce the AMS-I.B calculations
using cdmAmsIb. The methodology covers renewable mechanical
energy systems (e.g. water pumping or grain milling) that displace
fossil fuel-based equipment. The core steps involve quantifying baseline
fuel consumption, converting it to energy, applying fossil emission
factors, and accounting for any residual project fossil use.
library(cdmAmsIb)
check_applicability_mechanical_capacity(capacity_kw = 1000)## [1] TRUE
check_applicability_renewable_driver(renewable_fraction = 0.95)## [1] TRUE
check_applicability_service_displacement(fossil_service_share = 0.8)## [1] TRUE
set.seed(123)
example_data <- simulate_ams_ib_dataset(n_machines = 6, n_periods = 4, start_year = 2024, start_month = 10)
quiet_kable(
head(example_data),
format = "html",
digits = 2
)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| machine_id | monitoring_period | year | month | day | monitoring_date | monitoring_label | service_output_mj | fuel_consumption | net_calorific_value | emission_factor | project_energy_mj | baseline_energy_mj | baseline_emissions_tco2e | project_emissions_tco2e | emission_reductions_tco2e |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| machine_1 | 1 | 2024 | 10 | 15 | 2024-10-15 | 2024-10 | 12714.64 | 309.35 | 41.10 | 0 | 635.73 | 12714.64 | 0.89 | 0.04 | 0.85 |
| machine_1 | 2 | 2024 | 11 | 19 | 2024-11-19 | 2024-11 | 8853.32 | 211.30 | 41.90 | 0 | 442.67 | 8853.32 | 0.62 | 0.03 | 0.59 |
| machine_1 | 3 | 2024 | 12 | 14 | 2024-12-14 | 2024-12 | 15884.29 | 368.85 | 43.06 | 0 | 794.21 | 15884.29 | 1.11 | 0.06 | 1.06 |
| machine_1 | 4 | 2025 | 1 | 3 | 2025-01-03 | 2025-01 | 14476.62 | 346.67 | 41.76 | 0 | 723.83 | 14476.62 | 1.01 | 0.05 | 0.96 |
| machine_2 | 1 | 2024 | 10 | 10 | 2024-10-10 | 2024-10 | 11832.94 | 291.77 | 40.56 | 0 | 591.65 | 11832.94 | 0.83 | 0.04 | 0.79 |
| machine_2 | 2 | 2024 | 11 | 18 | 2024-11-18 | 2024-11 | 9646.85 | 234.04 | 41.22 | 0 | 482.34 | 9646.85 | 0.68 | 0.03 | 0.64 |
The simulation includes monitoring metadata
(monitoring_period, year, month,
day, and monitoring_label) plus baseline fuel
characteristics and derived emissions that can be aggregated over
reporting periods.
baseline_energy <- calculate_baseline_energy_content(example_data, group_cols = "machine_id")
baseline_emis <- calculate_baseline_emissions(baseline_energy, emission_factor = 0.00007)
project_energy <- tibble::tibble(
machine_id = unique(example_data$machine_id),
project_energy_mj = 0
)
project_emis <- calculate_project_emissions(project_energy, project_emission_factor = 0)
emission_reductions <- calculate_emission_reductions(baseline_emis, project_emis)
quiet_kable(head(emission_reductions), format = "html", digits = 4)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| machine_id | baseline_energy_mj | baseline_emissions_tco2e | project_energy_mj | project_emissions_tco2e | emission_reductions_tco2e |
|---|---|---|---|---|---|
| machine_1 | 51928.87 | 3.6350 | 0 | 0 | 3.6350 |
| machine_2 | 42631.69 | 2.9842 | 0 | 0 | 2.9842 |
| machine_3 | 46693.73 | 3.2686 | 0 | 0 | 3.2686 |
| machine_4 | 43666.45 | 3.0567 | 0 | 0 | 3.0567 |
| machine_5 | 40918.21 | 2.8643 | 0 | 0 | 2.8643 |
| machine_6 | 41513.43 | 2.9059 | 0 | 0 | 2.9059 |
period_summary <- aggregate_monitoring_periods(
monitoring_data = example_data,
monitoring_cols = c("monitoring_label"),
group_cols = "machine_id"
)
quiet_kable(head(period_summary), format = "html", digits = 4)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| machine_id | monitoring_label | baseline_energy_mj | emission_factor | baseline_emissions_tco2e | project_energy_mj | project_emissions_tco2e | emission_reductions_tco2e |
|---|---|---|---|---|---|---|---|
| machine_1 | 2024-10 | 12714.639 | 1e-04 | 0.8900 | 635.7319 | 0.0445 | 0.8455 |
| machine_1 | 2024-11 | 8853.321 | 1e-04 | 0.6197 | 442.6660 | 0.0310 | 0.5887 |
| machine_1 | 2024-12 | 15884.290 | 1e-04 | 1.1119 | 794.2145 | 0.0556 | 1.0563 |
| machine_1 | 2025-01 | 14476.620 | 1e-04 | 1.0134 | 723.8310 | 0.0507 | 0.9627 |
| machine_2 | 2024-10 | 11832.942 | 1e-04 | 0.8283 | 591.6471 | 0.0414 | 0.7869 |
| machine_2 | 2024-11 | 9646.853 | 1e-04 | 0.6753 | 482.3427 | 0.0338 | 0.6415 |
estimate_emission_reductions_ams_ib(
fuel_data = example_data,
emission_factor = 0.00007,
group_cols = "machine_id"
)## # A tibble: 6 × 6
## machine_id baseline_energy_mj baseline_emissions_tco2e project_energy_mj
## <chr> <dbl> <dbl> <dbl>
## 1 machine_1 51929. 3.64 0
## 2 machine_2 42632. 2.98 0
## 3 machine_3 46694. 3.27 0
## 4 machine_4 43666. 3.06 0
## 5 machine_5 40918. 2.86 0
## 6 machine_6 41513. 2.91 0
## # ℹ 2 more variables: project_emissions_tco2e <dbl>,
## # emission_reductions_tco2e <dbl>
function_reference <- tibble::tibble(
Function = c(
"`calculate_baseline_energy_content()`",
"`calculate_baseline_emissions()`",
"`calculate_project_emissions()`",
"`calculate_emission_reductions()`",
"`aggregate_monitoring_periods()`",
"`estimate_emission_reductions_ams_ib()`",
"`simulate_ams_ib_dataset()`"
),
Signature = c(
"`calculate_baseline_energy_content(fuel_data, consumption_col = \"fuel_consumption\", ncv_col = \"net_calorific_value\", group_cols = NULL)`",
"`calculate_baseline_emissions(energy_data, energy_col = \"baseline_energy_mj\", emission_factor, output_col = \"baseline_emissions_tco2e\")`",
"`calculate_project_emissions(project_energy, energy_col = \"project_energy_mj\", project_emission_factor = 0, output_col = \"project_emissions_tco2e\")`",
"`calculate_emission_reductions(baseline_emissions, project_emissions, baseline_col = \"baseline_emissions_tco2e\", project_col = \"project_emissions_tco2e\", output_col = \"emission_reductions_tco2e\")`",
"`aggregate_monitoring_periods(monitoring_data, monitoring_cols = c(\"year\", \"month\"), group_cols = \"machine_id\")`",
"`estimate_emission_reductions_ams_ib(fuel_data, consumption_col = \"fuel_consumption\", ncv_col = \"net_calorific_value\", group_cols = NULL, emission_factor, project_energy_col = NULL, project_emission_factor = 0)`",
"`simulate_ams_ib_dataset(n_machines = 15, n_periods = 12, start_year = 2023, start_month = 1, mean_service_mj = 48000, sd_service_mj = 6000, emission_factor = 0.00007, project_fossil_share = 0.05)`"
),
Purpose = c(
"Convert baseline fuel consumption into mechanical energy.<br>\\(E^{BL}_y = \\sum_i FC^{BL}_{i,y} \\times NCV^{BL}_{i,y}\\)",
"Calculate baseline emissions using fossil fuel factors.<br>\\(BE_y = E^{BL}_y \\times EF^{BL}_y\\)",
"Estimate project emissions from any residual fossil use.<br>\\(PE_y = \\sum_i E^{PR}_{i,y} \\times EF^{PR}_{i,y}\\)",
"Compute emission reductions by differencing baselines and project values.<br>\\(ER_y = BE_y - PE_y\\)",
"Aggregate monitoring data to reporting periods.<br>\\(ER_{p,y} = BE_{p,y} - PE_{p,y}\\)",
"Provide a wrapper returning emission reductions and supporting columns.<br>\\(ER_y = BE_y - PE_y\\)",
"Generate representative monitoring data for demonstrations 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_energy_content()
|
calculate_baseline_energy_content(fuel_data, consumption_col = "fuel_consumption", ncv_col = "net_calorific_value", group_cols = NULL)
|
Convert baseline fuel consumption into mechanical
energy. |
calculate_baseline_emissions()
|
calculate_baseline_emissions(energy_data, energy_col = "baseline_energy_mj", emission_factor, output_col = "baseline_emissions_tco2e")
|
Calculate baseline emissions using fossil fuel
factors. |
calculate_project_emissions()
|
calculate_project_emissions(project_energy, energy_col = "project_energy_mj", project_emission_factor = 0, output_col = "project_emissions_tco2e")
|
Estimate project emissions from any residual fossil
use. |
calculate_emission_reductions()
|
calculate_emission_reductions(baseline_emissions, project_emissions, baseline_col = "baseline_emissions_tco2e", project_col = "project_emissions_tco2e", output_col = "emission_reductions_tco2e")
|
Compute emission reductions by differencing baselines and project
values. |
aggregate_monitoring_periods()
|
aggregate_monitoring_periods(monitoring_data, monitoring_cols = c("year", "month"), group_cols = "machine_id")
|
Aggregate monitoring data to reporting
periods. |
estimate_emission_reductions_ams_ib()
|
estimate_emission_reductions_ams_ib(fuel_data, consumption_col = "fuel_consumption", ncv_col = "net_calorific_value", group_cols = NULL, emission_factor, project_energy_col = NULL, project_emission_factor = 0)
|
Provide a wrapper returning emission reductions and supporting
columns. |
simulate_ams_ib_dataset()
|
simulate_ams_ib_dataset(n_machines = 15, n_periods = 12, start_year = 2023, start_month = 1, mean_service_mj = 48000, sd_service_mj = 6000, emission_factor = 0.00007, project_fossil_share = 0.05)
|
Generate representative monitoring data for demonstrations and tests. |
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| Step | Purpose |
|---|---|
| Input fuel consumption data | Collect machine-level fuel data and monitoring metadata. |
| calculate_baseline_energy_content | Aggregate fossil fuel energy content per machine or period. |
| calculate_baseline_emissions | Apply emission factors to quantify baseline emissions. |
| calculate_project_emissions | Account for any residual project fossil energy consumption. |
| calculate_emission_reductions | Compute emission reductions by differencing baseline and project emissions. |
| estimate_emission_reductions_ams_ib | Provide a single wrapper returning reductions and supporting columns. |