Skip to content

Commit

Permalink
use final common year across sectors as limit for p4b scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobvjk committed May 30, 2024
1 parent 1b9342c commit 2f565fe
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions format_scenarios_for_p4b.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ final_year <- dplyr::summarise(
.by = "source"
)

final_year <- min(final_year$final_year_source, na.rm = TRUE)

logger::log_info("Define interpolation groups for interpolation of yearly values.")

interpolation_groups <- c(
Expand All @@ -81,10 +79,22 @@ scenario_input_p4b <- pacta.scenario.data.preparation::interpolate_yearly(
scenario_input_p4b <- dplyr::filter(
scenario_input_p4b,
.data$year >= .env$reference_year,
.data$year <= .env$final_year,
.data$sector %in% .env$market_share_sectors
)

final_year_by_sector_market_share <- dplyr::summarise(
scenario_input_p4b,
final_year = max(.data$year, na.rm = TRUE),
.by = "sector"
)

final_year_market_share <- min(final_year_by_sector_market_share$final_year, na.rm = TRUE)

scenario_input_p4b <- dplyr::filter(
scenario_input_p4b,
.data$year <= .env$final_year_market_share
)

scenario_input_p4b <- pacta.scenario.data.preparation::add_market_share_columns(
data = scenario_input_p4b,
reference_year = reference_year
Expand Down Expand Up @@ -119,10 +129,22 @@ scenario_input_p4b_ei <- pacta.scenario.data.preparation::interpolate_yearly(
scenario_input_p4b_ei <- dplyr::filter(
scenario_input_p4b_ei,
.data$year >= .env$reference_year,
.data$year <= .env$final_year,
.data$sector %in% .env$emission_intensity_sectors
)

final_year_by_sector_ei <- dplyr::summarise(
scenario_input_p4b,
final_year = max(.data$year, na.rm = TRUE),
.by = "sector"
)

final_year_ei <- min(final_year_by_sector_ei$final_year, na.rm = TRUE)

scenario_input_p4b <- dplyr::filter(
scenario_input_p4b,
.data$year <= .env$final_year_ei
)

scenario_input_p4b_ei <- pacta.scenario.data.preparation::format_p4b_ei(scenario_input_p4b_ei)

if (pacta.data.validation::validate_intermediate_scenario_output(scenarios_p4b)) {
Expand Down

0 comments on commit 2f565fe

Please sign in to comment.