Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement explicit scenario choice across package (clean version). #30

Merged
merged 3 commits into from
Feb 21, 2025

Conversation

johanneskoch94
Copy link
Member

  • Introduce a scenario argument to calcFeDemandIndustry, calcIndustry_EEK and calcIndustry_Value_Added. The larger picture is the attempt to step away from a default set of scenarios. The choice of scenarios should be explicit. In the case of the input data pipeline, it is made in fullREMIND and then passed on to the different calcOutput functions. Hopefully this will help us control/drop/introduce new scenarios more easily in the future.
  • Add placeholder assumptions in inst data for the SSP2IndiaDEA scenarios.
  • Move SSP2_NAV_all duplication over from mrremind.

@johanneskoch94 johanneskoch94 changed the title Implement explicit scenario choice across package (no refactoring version). Implement explicit scenario choice across package (clean version). Feb 20, 2025
SSP2IndiaMedium, SSP2, NA, cement, 1
SSP2IndiaMedium, SSP2, NA, chemicals, 1
SSP2IndiaMedium, SSP2, NA, steel_primary, 1
SSP2IndiaMedium, SSP2, NA, steel_secondary, 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to be adjusted or validated by @JakobBD

@JakobBD
Copy link
Contributor

JakobBD commented Feb 20, 2025

Thanks, the India scenarios are really helpful, and the scenario argument seems like a step n the right direction.

Would be great if you could add the error handling I suggested.

Would be nice to create some comparison plots, but I can also do this (tomorrow).

@JakobBD JakobBD self-requested a review February 20, 2025 14:42
Comment on lines 8 to 9
#' @param scenario String designating the scenario. !!Currently it acts as a filter only, with the actual scenarios
#' computed within the function hard-coded into remind_scenarios.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a string designating one scenario, but a character vector designating several. Should be named and documented accordingly.

@@ -87,7 +87,7 @@ calcIndustry_CCS_limits <- function(
remind_timesteps <- unique(quitte::remind_timesteps$period)

## read SSP2 industry activity ----
ind_activity <- calcOutput('FEdemand', aggregate = FALSE, years = remind_timesteps) %>%
ind_activity <- calcOutput("FEdemand", scenario = "SSP2", aggregate = FALSE, years = remind_timesteps) %>%

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will re-run the entire caclFEdemand() calculation, instead of just pulling results from the cache and filtering them.

$ tar -Oxf /p/projects/rd3mod/inputdata/output_1.27/rev7.23APT-2025-02-15_62eff8f7_remind.tgz ./diagnostics.log | sed -n '/Run.*f37_indCCSlimit_default.cs4r/,/Exit.*f37_indCCSlimit_default.cs4r/ p'
Run calcOutput(type = "Industry_CCS_limits", file = "f37_indCCSlimit_default.cs4r", years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050), signif = 3, a1 = 0.3, a2 = 0.15, installation_...
~ Run calcOutput(type = "FEdemand", aggregate = FALSE, years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050, 2055, 2060, 2070, 2080, 2090, 2100, 2110, 2130, 2150))
~~  - loading cache calcFEdemand-F2abbec8c.rds
~ Exit calcOutput(type = "FEdemand", aggregate = FALSE, years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050, 2055, 2060, 2070, 2080, 2090, 2100, 2110, 2130, 2150)) in 0.32 seconds
~ Run readSource(type = "GlobalCCSinstitute", subtype = "2023-11", convert = FALSE)
~~  - writing cache readGlobalCCSinstitute-F12564c33-9f87aab4.rds
~ Exit readSource(type = "GlobalCCSinstitute", subtype = "2023-11", convert = FALSE) in 0.04 seconds
~  - writing cache calcIndustry_CCS_limits-F9cf30182-a5356021.rds
Exit calcOutput(type = "Industry_CCS_limits", file = "f37_indCCSlimit_default.cs4r", years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050), signif = 3, a1 = 0.3, a2 = 0.15, installation_... in 2.92 seconds

vs

$ tar -Oxf /p/projects/rd3mod/inputdata/output_1.27/rev7.22johannes_test8_62eff8f7_remind.tgz ./diagnostics.log | sed -n '/Run.*f37_indCCSlimit_default.cs4r/,/Exit.*f37_indCCSlimit_default.cs4r/ p'
Run calcOutput(type = "Industry_CCS_limits", file = "f37_indCCSlimit_default.cs4r", years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050), signif = 3, a1 = 0.3, a2 = 0.15, installation_...
~ Run calcOutput(type = "FEdemand", aggregate = FALSE, years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050, 2055, 2060, 2070, 2080, 2090, 2100, 2110, 2130, 2150), scenario = "SSP2")
~~ Run calcOutput(type = "FeDemandBuildings", aggregate = FALSE, warnNA = FALSE, subtype = "FE", scenario = "SSP2")
~~~ Run readSource(type = "Stationary", subset = "SSP2")
~~~~  - loading cache readStationary-F242fe856.rds
~~~~ Run calcOutput(type = "GDP", aggregate = FALSE, scenario = "SSP2", average2020 = FALSE)
~~~~~  - loading cache calcGDP-F83a9fc16-c25d42e0.rds
~~~~ Exit calcOutput(type = "GDP", aggregate = FALSE, scenario = "SSP2", average2020 = FALSE) in 0.03 seconds
~~~~ Run calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE")
~~~~~  - loading cache calcIOEdgeBuildings-F9a98f57d-4aaa938d.rds
~~~~ Exit calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE") in 0.05 seconds
~~~~ Run calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE_buildings")
~~~~~  - loading cache calcIOEdgeBuildings-F9a98f57d-0bb86146.rds
~~~~ Exit calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE_buildings") in 0.04 seconds
~~~~ WARNING: 
~~~~ calcOutput('IOEdgeBuildings', subtype = X), with X in (output_EDGE, output_EDGE_buildings) produces negative values, set to 0
~~~~ WARNING: 
~~~~ Weight sum is 0, so cannot normalize and will return 0 for some aggregation targets. This changes the total sum of the magpie object! If this is really intended set zeroWeight = "allow", or "setNA" to return NA.
~~~~  - writing cache convertStationary-F242fe856-b85bb017.rds
~~~ Exit readSource(type = "Stationary", subset = "SSP2") in 0.63 seconds
~~~ Run readSource(type = "EdgeBuildings", subtype = "FE", subset = "SSP2")
~~~~  - loading cache readEdgeBuildings-F66deb4dc-8fa9d490.rds
~~~~ Run calcOutput(type = "GDP", aggregate = FALSE, scenario = "SSP2", average2020 = FALSE)
~~~~~  - loading cache calcGDP-F83a9fc16-c25d42e0.rds
~~~~ Exit calcOutput(type = "GDP", aggregate = FALSE, scenario = "SSP2", average2020 = FALSE) in 0.03 seconds
~~~~ Run calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE")
~~~~~  - loading cache calcIOEdgeBuildings-F9a98f57d-4aaa938d.rds
~~~~ Exit calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE") in 0.05 seconds
~~~~ Run calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE_buildings")
~~~~~  - loading cache calcIOEdgeBuildings-F9a98f57d-0bb86146.rds
~~~~ Exit calcOutput(type = "IOEdgeBuildings", aggregate = FALSE, subtype = "output_EDGE_buildings") in 0.04 seconds
~~~~ WARNING: 
~~~~ calcOutput('IOEdgeBuildings', subtype = X), with X in (output_EDGE, output_EDGE_buildings) produces negative values, set to 0
~~~~  - writing cache convertEdgeBuildings-F66deb4dc-6d5f3c19.rds
~~~ Exit readSource(type = "EdgeBuildings", subtype = "FE", subset = "SSP2") in 0.89 seconds
~~~  - writing cache calcFeDemandBuildings-F75d9f23a-2a4775b2.rds
~~ Exit calcOutput(type = "FeDemandBuildings", aggregate = FALSE, warnNA = FALSE, subtype = "FE", scenario = "SSP2") in 2.42 seconds
~~ Run calcOutput(type = "FeDemandIndustry", aggregate = FALSE, warnNA = FALSE, scenario = "SSP2")
~~~ Run readSource(type = "Stationary", subset = c("SSP1", "SSP2", "SSP3", "SSP4", "SSP5", "SSP2_lowEn", "SSP2_highDemDEU", "SSP2IndiaHigh", "SSP2IndiaMedium", "SDP", "SDP_EI", "SDP_RC", "SDP_MC"))
~~~~  - loading cache convertStationary-F242fe856-59378c6e.rds
~~~ Exit readSource(type = "Stationary", subset = c("SSP1", "SSP2", "SSP3", "SSP4", "SSP5", "SSP2_lowEn", "SSP2_highDemDEU", "SSP2IndiaHigh", "SSP2IndiaMedium", "SDP", "SDP_EI", "SDP_RC", "SDP_MC")) in 0.19 seconds
~~~ Run calcOutput(type = "industry_subsectors_specific", subtype = "fixing_year",     scenarios = remind_scenarios, regions = unique(region_mapping_21$region),     aggregate = FALSE)
~~~~  - loading cache calcindustry_subsectors_specific-Fd28e5862-bff31f22.rds
~~~ Exit calcOutput(type = "industry_subsectors_specific", subtype = "fixing_year",     scenarios = remind_scenarios, regions = unique(region_mapping_21$region),     aggregate = FALSE) in 0.02 seconds
~~~ Run readSource(type = "ExpertGuess", subtype = "Chinese_Steel_Production", convert = FALSE)
~~~~  - loading cache readExpertGuess-Fb59a3392-68277e34.rds
~~~ Exit readSource(type = "ExpertGuess", subtype = "Chinese_Steel_Production", convert = FALSE) in 0.02 seconds
~~~ Run calcOutput(type = "Industry_Value_Added", aggregate = FALSE, years = c(1995, 2000, 2005, 2010, 2015, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2030, 2035, 2040, 2045, 2050, 2055, 2060, ...
~~~~  - loading cache calcIndustry_Value_Added-Ff607a966-791e2880.rds
~~~ Exit calcOutput(type = "Industry_Value_Added", aggregate = FALSE, years = c(1995, 2000, 2005, 2010, 2015, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2030, 2035, 2040, 2045, 2050, 2055, 2060, ... in 0.15 seconds
~~~ Run readSource(type = "ExpertGuess", subtype = "Chinese_Steel_Production", convert = FALSE)
~~~~  - loading cache readExpertGuess-Fb59a3392-68277e34.rds
~~~ Exit readSource(type = "ExpertGuess", subtype = "Chinese_Steel_Production", convert = FALSE) in 0.01 seconds
~~~ Run calcOutput(type = "Steel_Projections", aggregate = FALSE, years = c(1995, 2000, 2005, 2010, 2015, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2030, 2035, 2040, 2045, 2050, 2055, 2060, 206...
~~~~  - loading cache calcSteel_Projections-Fd2edd164-791e2880.rds
~~~ Exit calcOutput(type = "Steel_Projections", aggregate = FALSE, years = c(1995, 2000, 2005, 2010, 2015, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2030, 2035, 2040, 2045, 2050, 2055, 2060, 206... in 0.14 seconds
~~~ Run calcOutput("GDP", scenario = gdpPopScen, average2020 = FALSE,     years = sort(union(remind_years, last_empirical_year:max(fixing_year$fixing_year))),     aggregate = FALSE)
~~~~  - loading cache calcGDP-F83a9fc16-29cc38f7.rds
~~~ Exit calcOutput("GDP", scenario = gdpPopScen, average2020 = FALSE,     years = sort(union(remind_years, last_empirical_year:max(fixing_year$fixing_year))),     aggregate = FALSE) in 0.04 seconds
~~~ Run calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "material_alpha", scenarios = c("SSP1", "SSP2", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4", "SSP5", "SSP2_lowE...
~~~~  - loading cache calcindustry_subsectors_specific-Fd28e5862-852925be.rds
~~~ Exit calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "material_alpha", scenarios = c("SSP1", "SSP2", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4", "SSP5", "SSP2_lowE... in 0.02 seconds
~~~ Run calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "material_relative", scenarios = c("SSP1", "SSP2", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4", "SSP5", "SSP2_l...
~~~~  - loading cache calcindustry_subsectors_specific-Fd28e5862-71e85a83.rds
~~~ Exit calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "material_relative", scenarios = c("SSP1", "SSP2", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4", "SSP5", "SSP2_l... in 0.02 seconds
~~~ Run calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "material_relative_change", scenarios = c("SSP1", "SSP2", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4", "SSP5", ...
~~~~  - loading cache calcindustry_subsectors_specific-Fd28e5862-524c9a93.rds
~~~ Exit calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "material_relative_change", scenarios = c("SSP1", "SSP2", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4", "SSP5", ... in 0.02 seconds
~~~ WARNING: 
~~~ Duplicate entries found, only the last entry will be used (duplicate entries: AUS|1995|SSP2.ue_cement, AUS|2000|SSP2.ue_cement, AUS|2005|SSP2.ue_cement, AUS|2010|SSP2.ue_cement, AUS|2015|SSP2.ue_cement, AUS|2020|SSP2.ue_cement, AUS|2021|SSP2.ue_cement, AUS|2022|SSP2.ue_cement, AUS|2023|SSP2.ue_cement, AUS|2024|SSP2.ue_cement, AUS|2025|SSP2.ue_cement, AUS|2026|SSP2.ue_cement, AUS|2027|SSP2.ue_cement, AUS|2028|SSP2.ue_cement, AUS|2030|SSP2.ue_cement, AUS|2035|SSP2.ue_cement, AUS|2040|SSP2.ue_cement, AUS|2045|SSP2.ue_cement, AUS|2050|SSP2.ue_cement, AUS|2055|SSP2.ue_cement, AUS|2060|SSP2.ue_cement, AUS|2065|SSP2.ue_cement, AUS|2070|SSP2.ue_cement, AUS|2075|SSP2.ue_cement, AUS|2080|SSP2.ue_cement, AUS|2085|SSP2.ue_cement, AUS|2090|SSP2.ue_cement, AUS|2095|SSP2.ue_cement, AUS|2100|SSP2.ue_cement, AUS|2105|SSP2.ue_cement, AUS|2110|SSP2.ue_cement, AUS|2115|SSP2.ue_cement, AUS|2120|SSP2.ue_cement, AUS|2125|SSP2.ue_cement, AUS|2130|SSP2.ue_cement, AUS|2135|SSP2.ue_cement, AUS|2140|SSP2.ue_cement, AUS|2145|SSP2.ue_cement, AUS|2150|SSP2.ue_cement, CAN|1995|SSP2.ue_cement, CAN|2000|SSP2.ue_cement, CAN|2005|SSP2.ue_cement, CAN|2010|SSP2.ue_cement, CAN|2015|SSP2.ue_cement, CAN|2020|SSP2.ue_cement, CAN|2021|SSP2.ue_cement, CAN|2022|SSP2.ue_cement, CAN|2023|SSP2.ue_cement, CAN|2024|SSP2.ue_cement, CAN|2025|SSP2.ue_cement, CAN|2026|SSP2.ue_cement, CAN|2027|SSP2.ue_cement, CAN|2028|SSP2.ue_cement, CAN|2030|SSP2.ue_cement, CAN|2035|SSP2.ue_cement, CAN|2040|SSP2.ue_cement, CAN|2045|SSP2.ue_cement, CAN|2050|SSP2.ue_cement, CAN|2055|SSP2.ue_cement, CAN|2060|SSP2.ue_cement, CAN|2065|SSP2.ue_cement, CAN|2070|SSP2.ue_cement, CAN|2075|SSP2.ue_cement, CAN|2080|SSP2.ue_cement, CAN|2085|SSP2.ue_cement, CAN|2090|SSP2.ue_cement, CAN|2095|SSP2.ue_cement, CAN|2100|SSP2.ue_cement, CAN|2105|SSP2.ue_cement, CAN|2110|SSP2.ue_cement, CAN|2115|SSP2.ue_cement, CAN|2120|SSP2.ue_cement, CAN|2125|SSP2.ue_cement, CAN|2130|SSP2.ue_cement, CAN|2135|SSP2.ue_cement, CAN|2140|SSP2.ue_cement, CAN|2145|SSP2.ue_cement, CAN|2150|SSP2.ue_cement, HMD|1995|SSP2.ue_cement, HMD|2000|SSP2.ue_cement, HMD|2005|SSP2.ue_cement, HMD|2010|SSP2.ue_cement, HMD|2015|SSP2.ue_cement, HMD|2020|SSP2.ue_cement, HMD|2021|SSP2.ue_cement, HMD|2022|SSP2.ue_cement, HMD|2023|SSP2.ue_cement, HMD|2024|SSP2.ue_cement, HMD|2025|SSP2.ue_cement, HMD|2026|SSP2.ue_cement, HMD|2027|SSP2.ue_cement, HMD|2028|SSP2.ue_cement, HMD|2030|SSP2.ue_cement, HMD|2035|SSP2.ue_cement, HMD|2040|SSP2.ue_cement, HMD|2045|SSP2.ue_cement, HMD|2050|SSP2.ue_cement, HMD|2055|SSP2.ue_cement, HMD|2060|SSP2.ue_cement, HMD|2065|SSP2.ue_cement, HMD|2070|SSP2.ue_cement, HMD|2075|SSP2.ue_cement, HMD|2080|SSP2.ue_cement, HMD|2085|SSP2.ue_cement, HMD|2090|SSP2.ue_cement, HMD|2095|SSP2.ue_cement, HMD|2100|SSP2.ue_cement, HMD|2105|SSP2.ue_cement, HMD|2110|SSP2.ue_cement, HMD|2115|SSP2.ue_cement, HMD|2120|SSP2.ue_cement, HMD|2125|SSP2.ue_cement, HMD|2130|SSP2.ue_cement, HMD|2135|SSP2.ue_cement, HMD|2140|SSP2.ue_cement, HMD|2145|SSP2.ue_cement, HMD|2150|SSP2.ue_cement, NZL|1995|SSP2.ue_cement, NZL|2000|SSP2.ue_cement, NZL|2005|SSP2.ue_cement, NZL|2010|SSP2.ue_cement, NZL|2015|SSP2.ue_cement, NZL|2020|SSP2.ue_cement, NZL|2021|SSP2.ue_cement, NZL|2022|SSP2.ue_cement, NZL|2023|SSP2.ue_cement, NZL|2024|SSP2.ue_cement, NZL|2025|SSP2.ue_cement, NZL|2026|SSP2.ue_cement, NZL|2027|SSP2.ue_cement, NZL|2028|SSP2.ue_cement, NZL|2030|SSP2.ue_cement, NZL|2035|SSP2.ue_cement, NZL|2040|SSP2.ue_cement, NZL|2045|SSP2.ue_cement, NZL|2050|SSP2.ue_cement, NZL|2055|SSP2.ue_cement, NZL|2060|SSP2.ue_cement, NZL|2065|SSP2.ue_cement, NZL|2070|SSP2.ue_cement, NZL|2075|SSP2.ue_cement, NZL|2080|SSP2.ue_cement, NZL|2085|SSP2.ue_cement, NZL|2090|SSP2.ue_cement, NZL|2095|SSP2.ue_cement, NZL|2100|SSP2.ue_cement, NZL|2105|SSP2.ue_cement, NZL|2110|SSP2.ue_cement, NZL|2115|SSP2.ue_cement, NZL|2120|SSP2.ue_cement, NZL|2125|SSP2.ue_cement, NZL|2130|SSP2.ue_cement, NZL|2135|SSP2.ue_cement, NZL|2140|SSP2.ue_cement, NZL|2145|SSP2.ue_cement, NZL|2150|SSP2.ue_cement, SPM|1995|SSP2.ue_cement, SPM|2000|SSP2.ue_cement, SPM|2005|SSP2.ue_cement, SPM|2010|SSP2.ue_cement, SPM|2015|SSP2.ue_cement, SPM|2020|SSP2.ue_cement, SPM|2021|SSP2.ue_cement, SPM|2022|SSP2.ue_cement, SPM|2023|SSP2.ue_cement, SPM|2024|SSP2.ue_cement, SPM|2025|SSP2.ue_cement, SPM|2026|SSP2.ue_cement, SPM|2027|SSP2.ue_cement, SPM|2028|SSP2.ue_cement, SPM|2030|SSP2.ue_cement, SPM|2035|SSP2.ue_cement, SPM|2040|SSP2.ue_cement, SPM|2045|SSP2.ue_cement, SPM|2050|SSP2.ue_cement, SPM|2055|SSP2.ue_cement, SPM|2060|SSP2.ue_cement, SPM|2065|SSP2.ue_cement, SPM|2070|SSP2.ue_cement, SPM|2075|SSP2.ue_cement, SPM|2080|SSP2.ue_cement, SPM|2085|SSP2.ue_cement, SPM|2090|SSP2.ue_cement, SPM|2095|SSP2.ue_cement, SPM|2100|SSP2.ue_cement, SPM|2105|SSP2.ue_cement, SPM|2110|SSP2.ue_cement, SPM|2115|SSP2.ue_cement, SPM|2120|SSP2.ue_cement, SPM|2125|SSP2.ue_cement, SPM|2130|SSP2.ue_cement, SPM|2135|SSP2.ue_cement, SPM|2140|SSP2.ue_cement, SPM|2145|SSP2.ue_cement, SPM|2150|SSP2.ue_cement, CHN|1995|SSP2.ue_cement, CHN|2000|SSP2.ue_cement, CHN|2005|SSP2.ue_cement, CHN|2010|SSP2.ue_cement, CHN|2015|SSP2.ue_cement, CHN|2020|SSP2.ue_cement, CHN|2021|SSP2.ue_cement, CHN|2022|SSP2.ue_cement, CHN|2023|SSP2.ue_cement, CHN|2024|SSP2.ue_cement, CHN|2025|SSP2.ue_cement, CHN|2026|SSP2.ue_cement, CHN|2027|SSP2.ue_cement, CHN|2028|SSP2.ue_cement, CHN|2030|SSP2.ue_cement, CHN|2035|SSP2.ue_cement, CHN|2040|SSP2.ue_cement, CHN|2045|SSP2.ue_cement, CHN|2050|SSP2.ue_cement, CHN|2055|SSP2.ue_cement, CHN|2060|SSP2.ue_cement, CHN|2065|SSP2.ue_cement, CHN|2070|SSP2.ue_cement, CHN|2075|SSP2.ue_cement, CHN|2080|SSP2.ue_cement, CHN|2085|SSP2.ue_cement, CHN|2090|SSP2.ue_cement, CHN|2095|SSP2.ue_cement, CHN|2100|SSP2.ue_cement, CHN|2105|SSP2.ue_cement, CHN|2110|SSP2.ue_cement, CHN|2115|SSP2.ue_cement, CHN|2120|SSP2.ue_cement, CHN|2125|SSP2.ue_cement, CHN|2130|SSP2.ue_cement, CHN|2135|SSP2.ue_cement, CHN|2140|SSP2.ue_cement, CHN|2145|SSP2.ue_cement, CHN|2150|SSP2.ue_cement, HKG|1995|SSP2.ue_cement, HKG|2000|SSP2.ue_cement, HKG|2005|SSP2.ue_cement, HKG|2010|SSP2.ue_cement, HKG|2015|SSP2.ue_cement, HKG|2020|SSP2.ue_cement, HKG|2021|SSP2.ue_cement, HKG|2022|SSP2.ue_cement, HKG|2023|SSP2.ue_cement, HKG|2024|SSP2.ue_cement, HKG|2025|SSP2.ue_cement, HKG|2026|SSP2.ue_cement, HKG|2027|SSP2.ue_cement, HKG|2028|SSP2.ue_cement, HKG|2030|SSP2.ue_cement, HKG|2035|SSP2.ue_cement, HKG|2040|SSP2.ue_cement, HKG|2045|SSP2.ue_cement, HKG|2050|SSP2.ue_cement, HKG|2055|SSP2.ue_cement, HKG|2060|SSP2.ue_cement, HKG|2065|SSP2.ue_cement, HKG|2070|SSP2.ue_cement, HKG|2075|SSP2.ue_cement, HKG|2080|SSP2.ue_cement, HKG|2085|SSP2.ue_cement, HKG|2090|SSP2.ue_cement, HKG|2095|SSP2.ue_cement, HKG|2100|SSP2.ue_cement, HKG|2105|SSP2.ue_cement, HKG|2110|SSP2.ue_cement, HKG|2115|SSP2.ue_cement, HKG|2120|SSP2.ue_cement, HKG|2125|SSP2.ue_cement, HKG|2130|SSP2.ue_cement, HKG|2135|SSP2.ue_cement, HKG|2140|SSP2.ue_cement, HKG|2145|SSP2.ue_cement, HKG|2150|SSP2.ue_cement, MAC|1995|SSP2.ue_cement, MAC|2000|SSP2.ue_cement, MAC|2005|SSP2.ue_cement, MAC|2010|SSP2.ue_cement, MAC|2015|SSP2.ue_cement, MAC|2020|SSP2.ue_cement, MAC|2021|SSP2.ue_cement, MAC|2022|SSP2.ue_cement, MAC|2023|SSP2.ue_cement, MAC|2024|SSP2.ue_cement, MAC|2025|SSP2.ue_cement, MAC|2026|SSP2.ue_cement, MAC|2027|SSP2.ue_cement, MAC|2028|SSP2.ue_cement, MAC|2030|SSP2.ue_cement, MAC|2035|SSP2.ue_cement, MAC|2040|SSP2.ue_cement, MAC|2045|SSP2.ue_cement, MAC|2050|SSP2.ue_cement, MAC|2055|SSP2.ue_cement, MAC|2060|SSP2.ue_cement, MAC|2065|SSP2.ue_cement, MAC|2070|SSP2.ue_cement, MAC|2075|SSP2.ue_cement, MAC|2080|SSP2.ue_cement, MAC|2085|SSP2.ue_cement, MAC|2090|SSP2.ue_cement, MAC|2095|SSP2.ue_cement, MAC|2100|SSP2.ue_cement, MAC|2105|SSP2.ue_cement, MAC|2110|SSP2.ue_cement, MAC|2115|SSP2.ue_cement, MAC|2120|SSP2.ue_cement, MAC|2125|SSP2.ue_cement, MAC|2130|SSP2.ue_cement, MAC|2135|SSP2.ue_cement, MAC|2140|SSP2.ue_cement, MAC|2145|SSP2.ue_cement, MAC|2150|SSP2.ue_cement, TWN|1995|SSP2.ue_cement, TWN|2000|SSP2.ue_cement, TWN|2005|SSP2.ue_cement, TWN|2010|SSP2.ue_cement, TWN|2015|SSP2.ue_cement, TWN|2020|SSP2.ue_cement, TWN|2021|SSP2.ue_cement, TWN|2022|SSP2.ue_cement, TWN|2023|SSP2.ue_cement, TWN|2024|SSP2.ue_cement, TWN|2025|SSP2.ue_cement, TWN|2026|SSP2.ue_cement, TWN|2027|SSP
~~~ Run calcOutput(type = "IO", aggregate = FALSE, subtype = "output_Industry_subsectors")
~~~~  - loading cache calcIO-F822c96fb-926a760f.rds
~~~ Exit calcOutput(type = "IO", aggregate = FALSE, subtype = "output_Industry_subsectors") in 0.2 seconds
~~~ Run readSource(type = "IEA_ETP", subtype = "industry", convert = FALSE)
~~~~  - loading cache readIEA_ETP-F48490537-3d4f1419.rds
~~~ Exit readSource(type = "IEA_ETP", subtype = "industry", convert = FALSE) in 0.11 seconds
~~~ Run readSource(type = "industry_subsectors_specific", subtype = "industry_specific_FE_limits", convert = FALSE)
~~~~  - loading cache readindustry_subsectors_specific-F890669a3-dc54d8d4.rds
~~~ Exit readSource(type = "industry_subsectors_specific", subtype = "industry_specific_FE_limits", convert = FALSE) in 0.03 seconds
~~~ Run calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "FE", scenarios = c("SSP2", "SSP1", "SSP2_lowEn", "SSP2_highDemDEU", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4...
~~~~  - loading cache calcindustry_subsectors_specific-Fd28e5862-2d9c5954.rds
~~~ Exit calcOutput(type = "industry_subsectors_specific", aggregate = FALSE, subtype = "FE", scenarios = c("SSP2", "SSP1", "SSP2_lowEn", "SSP2_highDemDEU", "SSP2IndiaHigh", "SSP2IndiaMedium", "SSP3", "SSP4... in 0.02 seconds
~~~  - writing cache calcFeDemandIndustry-Fe7fe49bb-d4e449d0.rds
~~ Exit calcOutput(type = "FeDemandIndustry", aggregate = FALSE, warnNA = FALSE, scenario = "SSP2") in 48.21 seconds
~~  - writing cache calcFEdemand-F6cab8d89-d4e449d0.rds
~ Exit calcOutput(type = "FEdemand", aggregate = FALSE, years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050, 2055, 2060, 2070, 2080, 2090, 2100, 2110, 2130, 2150), scenario = "SSP2") in 51.21 seconds
~ Run readSource(type = "GlobalCCSinstitute", subtype = "2023-11", convert = FALSE)
~~  - loading cache readGlobalCCSinstitute-F12564c33-9f87aab4.rds
~ Exit readSource(type = "GlobalCCSinstitute", subtype = "2023-11", convert = FALSE) in 0.02 seconds
~  - writing cache calcIndustry_CCS_limits-F9716bd18-a5356021.rds
Exit calcOutput(type = "Industry_CCS_limits", file = "f37_indCCSlimit_default.cs4r", years = c(2005, 2010, 2015, 2020, 2025, 2030, 2035, 2040, 2045, 2050), signif = 3, a1 = 0.3, a2 = 0.15, installation_... in 54.3 seconds

@@ -2,6 +2,7 @@
#'
#' @param kap General internal capital stock, as calculated internally by
#' `calcCapital()`.
#' @param scenario string or vector of strings, designating the scenarios to be returned.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Comment on lines 28 to 38
industry_VA <- calcOutput(
type = 'Industry_Value_Added',
subtype = 'economic',
scenario = "SSP2",
match.steel.historic.values = TRUE,
match.steel.estimates = 'IEA_ETP',
China_Production = readSource(type = 'ExpertGuess',
subtype = 'Chinese_Steel_Production',
convert = FALSE) %>%
madrat_mule(),
aggregate = FALSE, years = base_year, supplementary = FALSE, warnNA = FALSE) %>%
`[`(,,'SSP2') %>%
aggregate = FALSE,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. Does not recycle cached results.

@@ -44,7 +49,7 @@ calcIndustry_EEK <- function(kap) {
madrat_mule()

## industry subsector activity and FE projections ----
FEdemand <- calcOutput(type = 'FEdemand', aggregate = FALSE, supplementary = FALSE)
FEdemand <- calcOutput("FEdemand", scenario = unique(c("SSP2", scenario)), aggregate = FALSE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching this to unique(c(scenario, "SSP2")) will present madrat with identical arguemnts, leveraging the existing cache.

@@ -4,6 +4,7 @@
#' @param subtype One of
#' - `physical` Returns physical production trajectories for cement.
#' - `economic` Returns value added trajectories for all subsectors.
#' @param scenario string or vector of strings, designating the scenarios to be returned.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

@@ -45,6 +46,7 @@
#' @export
#'
calcIndustry_Value_Added <- function(subtype = 'physical',
scenario = "SSP2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the default scenario? It is never used.

@@ -45,6 +46,7 @@
#' @importFrom magclass setNames
#' @export
calcSteel_Projections <- function(subtype = 'production',
scenario = "SSP2",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the default scenario? It is never used.

@johanneskoch94
Copy link
Member Author

johanneskoch94 commented Feb 21, 2025

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q Thanks for the suggestions. I renamed the scenario argument to scenarios, and switched around the order of the unique call. I don't see an easy way to improve the calls where you flagged the madrat-cache usage. Do you have an idea, or can this be addressed in the future? (It's a large relative increase in time, but still overall manageable at <1 min.)

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q
Copy link
Member

I don't see an easy way to improve the calls where you flagged the madrat-cache usage. Do you have an idea

Same as with mrremind. Pass state information explicitly, as a parameter. All these functions ultimately are called from fullREMIND().

(It's a large relative increase in time, but still overall manageable at <1 min.)

Yes, it is an issue of principle.

@johanneskoch94
Copy link
Member Author

@0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q I implemented the changes. If it's OK with you, I'ld squash, rebase, bump the version, and test the input data pipeline.

@johanneskoch94 johanneskoch94 force-pushed the scen branch 3 times, most recently from c79ef2d to 9a8772a Compare February 21, 2025 16:03
@johanneskoch94 johanneskoch94 merged commit 149b45b into pik-piam:main Feb 21, 2025
1 check passed
@johanneskoch94 johanneskoch94 deleted the scen branch February 21, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants