Skip to content

Commit

Permalink
Edit documentation and remove unused commented blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
measrainsey committed Jul 31, 2023
1 parent bd7abd9 commit 8216783
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 57 deletions.
77 changes: 48 additions & 29 deletions message_ix_models/tools/costs/projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,6 @@
get_weo_data,
)

# df_weo = get_weo_data()
# df_nam_orig_message = get_cost_assumption_data()
# df_tech_cost_ratios = calculate_region_cost_ratios(df_weo)
# df_fom_inv_ratios = calculate_fom_to_inv_cost_ratios(df_weo)

# df_region_diff = get_region_differentiated_costs(
# df_weo, df_nam_orig_message, df_tech_cost_ratios
# )

# df_learning_rates = get_cost_reduction_data()
# df_technology_first_year = get_technology_first_year_data()

# df_gdp = get_gdp_data()
# df_linreg = linearly_regress_tech_cost_vs_gdp_ratios(df_gdp, df_tech_cost_ratios)

# df_adj_cost_ratios = calculate_adjusted_region_cost_ratios(df_gdp, df_linreg)
# df_nam_learning = project_NAM_inv_costs_using_learning_rates(
# df_region_diff, df_learning_rates, df_technology_first_year
# )

# df_reg_learning = project_adjusted_inv_costs(
# df_nam_learning,
# df_adj_cost_ratios,
# df_region_diff,
# convergence_year_flag=2070,
# )

# df_reg_learning.to_csv('/Users/meas/Desktop/test-methods.csv', index=False)


# Function to get cost projections based on method specified
# (learning only, GDP adjusted, or convergence via spline projections)
Expand All @@ -64,6 +35,31 @@ def get_cost_projections(
converge_costs: bool = True,
convergence_year: int = 2050,
):
"""Get cost projections based on method specified
Parameters
----------
cost_type : str, optional
Type of cost to project, by default "inv_cost"
scenario : str, optional
SSP scenario, by default "ssp2"
format : str, optional
Format of output, by default "message"
use_gdp : bool, optional
Whether to use GDP projections, by default False
converge_costs : bool, optional
Whether to converge costs, by default True
convergence_year : int, optional
Year to converge costs to, by default 2050
Returns
-------
pandas.DataFrame
Columns depend on the format specified:
- message: scenario, node_loc, technology, year_vtg, value, unit
- iamc: Scenario, Region, Variable, 2020, 2025, ..., 2100
"""
df_weo = get_weo_data()
df_nam_orig_message = get_cost_assumption_data()
df_tech_cost_ratios = calculate_region_cost_ratios(df_weo)
Expand Down Expand Up @@ -167,6 +163,29 @@ def get_all_costs(
converge_costs: bool = True,
convergence_year: int = 2050,
):
"""Get all costs
Parameters
----------
use_gdp : bool, optional
Whether to use GDP projections, by default False
converge_costs : bool, optional
Whether to converge costs, by default True
convergence_year : int, optional
Year to converge costs to, by default 2050
Returns
-------
pandas.DataFrame
DataFrame with columns:
- scenario: SSP1, SSP2, or SSP3
- message_technology: MESSAGEix technology name
- r11_region: R11 region
- year: year
- inv_cost: investment cost
- fix_cost: fixed cost
"""
df_weo = get_weo_data()
df_nam_orig_message = get_cost_assumption_data()
df_tech_cost_ratios = calculate_region_cost_ratios(df_weo)
Expand Down
32 changes: 4 additions & 28 deletions message_ix_models/tools/costs/splines.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,6 @@ def project_adjusted_inv_costs(
x.inv_cost_learning_NAM,
),
),
# inv_cost_region=lambda x: np.where(
# converge_costs_flag is True,
# x.inv_cost_converge,
# np.where(
# use_gdp_flag is True, x.inv_cost_gdp_adj, x.inv_cost_learning_only
# ),
# ),
# inv_cost_no_gdj_adj=lambda x: np.where(
# x.year <= FIRST_MODEL_YEAR,
# x.cost_region_2021, x.inv_cost_learning_NAM
# ),
# inv_cost_gdp_adj=lambda x: np.where(
# x.year <= FIRST_MODEL_YEAR,
# x.cost_region_2021,
# x.inv_cost_learning_NAM * x.cost_ratio_adj,
# ),
# inv_cost_learning_region=lambda x: np.where(
# use_gdp_flag is True, x.inv_cost_gdp_adj, x.inv_cost_no_gdj_adj
# ),
)
.reindex(
[
Expand Down Expand Up @@ -285,15 +266,6 @@ def apply_splines_projection(
"year",
],
)
# .assign(
# inv_cost=lambda x: np.where(
# x.r11_region == "NAM",
# x.inv_cost_learning_region,
# x.inv_cost_splines,
# )
# )
# .merge(fom_inv_ratios_df, on=["message_technology", "r11_region"])
# .assign(fix_cost=lambda x: x.inv_cost * x.fom_to_inv_cost_ratio)
.reindex(
[
"scenario",
Expand Down Expand Up @@ -331,6 +303,10 @@ def project_final_inv_and_fom_costs(
Output of :func:`apply_splines_projection`
fom_inv_ratios_df : pandas.DataFrame
Output of :func:`calculate_fom_to_inv_cost_ratios`
use_gdp_flag : bool, optional
If True, use GDP-adjusted cost ratios, by default False
converge_costs_flag : bool, optional
If True, converge costs, by default True
Returns
-------
Expand Down

0 comments on commit 8216783

Please sign in to comment.