cdmAmsIa-methodology.RmdThis vignette demonstrates how to reproduce the AMS-I.A calculations
using cdmAmsIa. The methodology covers on-site renewable
electricity systems that displace fossil electricity consumption by the
end user. The core steps involve calculating baseline generation,
estimating emissions using a grid factor, and confirming negligible
project emissions.
library(cdmAmsIa)
check_applicability_installed_capacity(capacity_kw = 1000, renewable_fraction = 1)## [1] TRUE
check_applicability_distributed_generation(fossil_fraction_baseline = 0.85)## [1] TRUE
set.seed(123)
example_data <- simulate_ams_ia_dataset(n_users = 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")
| user_id | monitoring_period | year | month | day | monitoring_date | monitoring_label | generation_kwh | grid_emission_factor | baseline_generation_kwh | baseline_emissions_tco2e | project_emissions_tco2e | emission_reductions_tco2e |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| user_1 | 1 | 2024 | 10 | 15 | 2024-10-15 | 2024-10 | 3988.21 | 0.75 | 3988.21 | 2991.16 | 0 | 2991.16 |
| user_1 | 2 | 2024 | 11 | 19 | 2024-11-19 | 2024-11 | 2701.11 | 0.75 | 2701.11 | 2025.83 | 0 | 2025.83 |
| user_1 | 3 | 2024 | 12 | 14 | 2024-12-14 | 2024-12 | 5044.76 | 0.75 | 5044.76 | 3783.57 | 0 | 3783.57 |
| user_1 | 4 | 2025 | 1 | 3 | 2025-01-03 | 2025-01 | 4575.54 | 0.75 | 4575.54 | 3431.65 | 0 | 3431.65 |
| user_2 | 1 | 2024 | 10 | 10 | 2024-10-10 | 2024-10 | 3694.31 | 0.75 | 3694.31 | 2770.74 | 0 | 2770.74 |
| user_2 | 2 | 2024 | 11 | 18 | 2024-11-18 | 2024-11 | 2965.62 | 0.75 | 2965.62 | 2224.21 | 0 | 2224.21 |
The simulation now includes explicit monitoring metadata
(monitoring_period, year, month,
day, and monitoring_label) so that
calculations can be aggregated over reporting periods.
baseline_gen <- calculate_baseline_generation(example_data, group_cols = "user_id")
baseline_emis <- calculate_baseline_emissions(baseline_gen, grid_emission_factor = 0.75)
project_emis <- calculate_project_emissions(baseline_gen)
emission_reductions <- calculate_emission_reductions(baseline_emis, project_emis)
quiet_kable(head(emission_reductions), format = "html", digits = 2)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| user_id | baseline_generation_kwh | baseline_emissions_tco2e | project_emissions_tco2e | emission_reductions_tco2e |
|---|---|---|---|---|
| user_1 | 16309.62 | 12232.22 | 0 | 12232.22 |
| user_2 | 13210.56 | 9907.92 | 0 | 9907.92 |
| user_3 | 14564.58 | 10923.43 | 0 | 10923.43 |
| user_4 | 13555.48 | 10166.61 | 0 | 10166.61 |
| user_5 | 12639.40 | 9479.55 | 0 | 9479.55 |
| user_6 | 12837.81 | 9628.36 | 0 | 9628.36 |
period_summary <- aggregate_monitoring_periods(
generation_data = example_data,
monitoring_cols = c("monitoring_label"),
group_cols = "user_id"
)
quiet_kable(head(period_summary), format = "html", digits = 2)## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| user_id | monitoring_label | baseline_emissions_tco2e | project_emissions_tco2e | emission_reductions_tco2e | baseline_generation_kwh | grid_emission_factor |
|---|---|---|---|---|---|---|
| user_1 | 2024-10 | 2991.16 | 0 | 2991.16 | 3988.21 | 0.75 |
| user_1 | 2024-11 | 2025.83 | 0 | 2025.83 | 2701.11 | 0.75 |
| user_1 | 2024-12 | 3783.57 | 0 | 3783.57 | 5044.76 | 0.75 |
| user_1 | 2025-01 | 3431.65 | 0 | 3431.65 | 4575.54 | 0.75 |
| user_2 | 2024-10 | 2770.74 | 0 | 2770.74 | 3694.31 | 0.75 |
| user_2 | 2024-11 | 2224.21 | 0 | 2224.21 | 2965.62 | 0.75 |
estimate_emission_reductions_ams_ia(
generation_data = example_data,
grid_emission_factor = 0.75,
group_cols = "user_id"
)## # A tibble: 6 × 5
## user_id baseline_generation_kwh baseline_emissions_tc…¹ project_emissions_tc…²
## <chr> <dbl> <dbl> <dbl>
## 1 user_1 16310. 12232. 0
## 2 user_2 13211. 9908. 0
## 3 user_3 14565. 10923. 0
## 4 user_4 13555. 10167. 0
## 5 user_5 12639. 9480. 0
## 6 user_6 12838. 9628. 0
## # ℹ abbreviated names: ¹baseline_emissions_tco2e, ²project_emissions_tco2e
## # ℹ 1 more variable: emission_reductions_tco2e <dbl>
function_reference <- tibble::tibble(
Function = c(
"`calculate_baseline_generation()`",
"`calculate_baseline_emissions()`",
"`calculate_project_emissions()`",
"`calculate_emission_reductions()`",
"`aggregate_monitoring_periods()`",
"`estimate_emission_reductions_ams_ia()`",
"`simulate_ams_ia_dataset()`"
),
Signature = c(
"`calculate_baseline_generation(generation_data, generation_col = \"generation_kwh\", group_cols = NULL)`",
"`calculate_baseline_emissions(baseline_generation, grid_emission_factor, output_col = \"baseline_emissions_tco2e\")`",
"`calculate_project_emissions(baseline_generation, 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(generation_data, monitoring_cols = c(\"year\", \"month\"), group_cols = \"user_id\")`",
"`estimate_emission_reductions_ams_ia(generation_data, grid_emission_factor, project_emission_factor = 0, group_cols = NULL)`",
"`simulate_ams_ia_dataset(n_users = 20, n_periods = 12, start_year = 2023, start_month = 1, mean_generation_kwh = 15000, sd_generation_kwh = 2000, grid_emission_factor = 0.75)`"
),
Purpose = c(
"Summed baseline generation for each group or monitoring period.<br>\\(E^{BL}_y = \\sum_i E_{i,y}\\)",
"Baseline emissions using the applicable grid factor.<br>\\(BE_y = E^{BL}_y \\times EF^{grid}\\)",
"Project emissions (typically zero for AMS-I.A).<br>\\(PE_y = E^{BL}_y \\times EF^{PR}\\)",
"Emission reductions for each monitoring period.<br>\\(ER_y = BE_y - PE_y\\)",
"Aggregates monitoring data to reporting periods.<br>\\(ER_{p,y} = BE_{p,y} - PE_{p,y}\\)",
"Meta-calculation composing the core equations.<br>\\(ER_y = BE_y - PE_y\\)",
"DeclareDesign-based simulation with temporal monitoring metadata."
)
)
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_generation()
|
calculate_baseline_generation(generation_data, generation_col = "generation_kwh", group_cols = NULL)
|
Summed baseline generation for each group or monitoring
period. |
calculate_baseline_emissions()
|
calculate_baseline_emissions(baseline_generation, grid_emission_factor, output_col = "baseline_emissions_tco2e")
|
Baseline emissions using the applicable grid
factor. |
calculate_project_emissions()
|
calculate_project_emissions(baseline_generation, project_emission_factor = 0, output_col = "project_emissions_tco2e")
|
Project emissions (typically zero for
AMS-I.A). |
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")
|
Emission reductions for each monitoring
period. |
aggregate_monitoring_periods()
|
aggregate_monitoring_periods(generation_data, monitoring_cols = c("year", "month"), group_cols = "user_id")
|
Aggregates monitoring data to reporting
periods. |
estimate_emission_reductions_ams_ia()
|
estimate_emission_reductions_ams_ia(generation_data, grid_emission_factor, project_emission_factor = 0, group_cols = NULL)
|
Meta-calculation composing the core
equations. |
simulate_ams_ia_dataset()
|
simulate_ams_ia_dataset(n_users = 20, n_periods = 12, start_year = 2023, start_month = 1, mean_generation_kwh = 15000, sd_generation_kwh = 2000, grid_emission_factor = 0.75)
|
DeclareDesign-based simulation with temporal monitoring metadata. |
## Warning: 'xfun::attr()' is deprecated.
## Use 'xfun::attr2()' instead.
## See help("Deprecated")
| Step | Purpose |
|---|---|
| Input generation data | Collect user-level generation and monitoring metadata. |
| calculate_baseline_generation | Aggregate electricity delivered to each user or period. |
| calculate_baseline_emissions | Apply the grid emission factor to baseline generation. |
| calculate_project_emissions | Account for any residual project emissions (often zero). |
| calculate_emission_reductions | Compute emission reductions by differencing baselines and project values. |
| estimate_emission_reductions_ams_ia | Provide a single wrapper returning reductions and supporting columns. |