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

feat: target_market_share handling scenario inputs with data starting earlier than abcd input #482

Open
jdhoffa opened this issue Mar 20, 2024 · 0 comments
Assignees
Labels
ADO Maintenance Day! feature a feature request or enhancement priority

Comments

@jdhoffa
Copy link
Member

jdhoffa commented Mar 20, 2024

@jacobvjk has identified that potentiall bizarre behaviour may occur in the case that:

  • the scenario input is prepared for and thus starts at some year, e.g. 2020
  • a company in the abcd has production that "turns on" in a later year, e.g. 2023

A reprex below shows the current behaviour.

I am not sure what the desired behaviour is and leave it to @jacobvjk to elaborate.

Relates (somewhat) to #481

library(r2dii.data)
library(r2dii.match)
library(r2dii.analysis)
library(r2dii.plot)

matched <- tibble::tribble(
  ~id_loan, ~loan_size_outstanding, ~loan_size_outstanding_currency, ~loan_size_credit_limit, ~loan_size_credit_limit_currency, ~id_2dii,            ~level, ~score,      ~sector,     ~name_abcd, ~sector_abcd,
  "L162",                      1,                           "EUR",                       2,                            "EUR",    "UP1", "ultimate_parent",      1, "automotive", "shaanxi auto", "automotive"
)

# we have an ABCD that "turns on" in 2023
abcd <- tibble::tribble(
  ~name_company,      ~sector, ~technology, ~year, ~production, ~emission_factor, ~plant_location, ~is_ultimate_owner,
  "shaanxi auto", "automotive",       "ice", 2023L,           1,                1,            "BF",               TRUE,
  "shaanxi auto", "automotive",       "ice", 2024L,           1,                1,            "BF",               TRUE,
  "shaanxi auto", "automotive",       "ice", 2025L,           1,                1,            "BF",               TRUE
)

# we have a Scenario that is "prepared" for 2020, that is to say TMSR is 
# determind based on a 2020 start year
scenario <- tibble::tribble(
  ~scenario,      ~sector, ~technology,  ~region, ~year, ~tmsr, ~smsp, ~scenario_source,
  "1.5c-scen", "automotive",       "ice", "global", 2020L,     1, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2021L,   0.9, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2022L,   0.8, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2023L,   0.7, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2024L,   0.6, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2025L,   0.5, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2026L,   0.4, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2027L,   0.3, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2028L,   0.2, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2029L,   0.1, -0.08,      "demo_2020",
  "1.5c-scen", "automotive",       "ice", "global", 2030L,     0, -0.08,      "demo_2020"
)

out <- target_market_share(
  matched,
  abcd,
  scenario,
  region_isos_demo
)

# this is the tabular output
out
#> # A tibble: 9 × 10
#>   sector     technology  year region scenario_source metric           production
#>   <chr>      <chr>      <int> <chr>  <chr>           <chr>                 <dbl>
#> 1 automotive ice         2023 global demo_2020       projected               1  
#> 2 automotive ice         2023 global demo_2020       target_1.5c-scen        0.7
#> 3 automotive ice         2024 global demo_2020       projected               1  
#> 4 automotive ice         2024 global demo_2020       target_1.5c-scen        0.6
#> 5 automotive ice         2025 global demo_2020       projected               1  
#> 6 automotive ice         2025 global demo_2020       target_1.5c-scen        0.5
#> 7 automotive ice         2023 global demo_2020       corporate_econo…        1  
#> 8 automotive ice         2024 global demo_2020       corporate_econo…        1  
#> 9 automotive ice         2025 global demo_2020       corporate_econo…        1  
#> # ℹ 3 more variables: technology_share <dbl>, scope <chr>,
#> #   percentage_of_initial_production_by_scope <dbl>

# this is the resulting plot
out |> 
  r2dii.plot::prep_trajectory() |> 
  r2dii.plot::plot_trajectory()

Created on 2024-03-20 with reprex v2.1.0

AB#10659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADO Maintenance Day! feature a feature request or enhancement priority
Projects
None yet
Development

No branches or pull requests

2 participants