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

Add technoeconomic cost projections and related data #99

Merged
merged 255 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
255 commits
Select commit Hold shift + click to select a range
ee19ef1
Rename function
measrainsey May 12, 2023
56eb164
Add comments
measrainsey May 12, 2023
770ca0c
Add dictionaries of weo regions and technologies
measrainsey May 15, 2023
ee38b17
Add function to calculate cost ratios between regions
measrainsey May 15, 2023
74d2f98
Add cost assumption data
measrainsey May 15, 2023
3d4b358
Add adjustments to NAM cost for technologies
measrainsey May 23, 2023
92df57b
Edit to conform to flake8 linting
measrainsey May 23, 2023
a63ca8d
Disable test for now
measrainsey May 23, 2023
5d6fbe2
Get region differentiated costs
measrainsey May 23, 2023
addea82
Change Europe to European Union to reflect 2022 WEO
measrainsey May 23, 2023
bf13d12
Add/remove comments
measrainsey May 23, 2023
d59b382
Add test for get_weo_data()
measrainsey May 23, 2023
6bea19d
Rename region ratios function
measrainsey May 23, 2023
2ecfb7b
Add tests
measrainsey May 23, 2023
cf8e863
Add pyxlsb to pyproject
measrainsey May 24, 2023
251d820
Rename files and change description
measrainsey Jun 1, 2023
ad4d288
Modify script for PR review
measrainsey Jun 1, 2023
74cec53
Update tests
measrainsey Jun 1, 2023
5170c38
Edit to comply with linting
measrainsey Jun 1, 2023
7825d0f
Change how to replace MEA cost ratios with FSU ratios
measrainsey Jun 2, 2023
aecf5b6
Remove comment
measrainsey Jun 2, 2023
944721b
Add docs section, expand docstrings for .tools.iea.weo
khaeru Jun 2, 2023
1ef1152
Use a `mask` in adj_nam_cost_message()
khaeru Jun 2, 2023
13a5ab1
Add and update documentation for WEO functions
measrainsey Jun 6, 2023
cf7864e
Update to pass linting
measrainsey Jun 6, 2023
c08106a
Fix input types for functions
measrainsey Jun 12, 2023
0b385b0
Change file location from p-drive to Github link
measrainsey Jun 16, 2023
ae06841
Add SPP cost reduction data
measrainsey Jun 16, 2023
ab17011
Move to ssp data folder
measrainsey Jun 16, 2023
fa66910
Rename module from iea to costs
measrainsey Jun 16, 2023
b27938d
Update docs with new iea -> costs name
measrainsey Jun 27, 2023
286c529
Add GEA cost reduction data
measrainsey Jun 27, 2023
b0f1f40
Add functionality to create SSP technology learning data
measrainsey Jun 28, 2023
5b01365
Update docs to include SSP technology learning module
measrainsey Jun 28, 2023
08e62dc
Fix missing comma in array after resolving conflict in pyproject.toml
measrainsey Jun 28, 2023
632454a
Move and rename WEO tests
measrainsey Jun 28, 2023
275163b
Add tests for GEA and SSP learning module
measrainsey Jun 28, 2023
478b8a1
Remove pandas from import
measrainsey Jun 28, 2023
72a56f5
Remove cost reduction data in SSP folder
measrainsey Jun 28, 2023
42f3bf6
Add SSP GDP per capita data
measrainsey Jun 28, 2023
7d4e964
Add functionality to derive technology costs vs GDP linear regressions
measrainsey Jun 29, 2023
be330fb
Add tests for GDP and regression functions
measrainsey Jun 29, 2023
e0fa4ba
Add GDP data and functionality to docs
measrainsey Jun 29, 2023
d6eac9f
Remove docstring title
measrainsey Jun 29, 2023
da8d6e6
Add line to suppress import error for mypy
measrainsey Jun 29, 2023
8889590
Change some function inputs into global variables and some function v…
measrainsey Jun 30, 2023
956bda6
Update column name
measrainsey Jun 30, 2023
99914ed
Take out function input and make global variable instead
measrainsey Jun 30, 2023
cee0eb9
Add year to column name
measrainsey Jun 30, 2023
e981487
Move Dict from inputs and set as global variable
measrainsey Jun 30, 2023
f467ffd
Update tests to match new inputs configuration
measrainsey Jun 30, 2023
78c0093
Update WEO tests to reflect removed Dict inputs
measrainsey Jun 30, 2023
33bdf72
Add csv of first years for technologies
measrainsey Jul 4, 2023
3ed3605
Add functionality to apply polynomial regression to costs
measrainsey Jul 4, 2023
04b9ada
Add splines module to documentation
measrainsey Jul 4, 2023
4e2ee6b
Add scipy to mypy overrides
measrainsey Jul 4, 2023
ea7f921
Fix missing row (Brazil) in reading in WEO data
measrainsey Jul 4, 2023
eff575d
Filter out WEO technology costs that are NaN
measrainsey Jul 4, 2023
81a833e
Change function to apply regressions to other regions as well
measrainsey Jul 4, 2023
0231e59
Update WEO test to have Brazil as a region
measrainsey Jul 4, 2023
4e389f0
Change functions to loop through and include data from SSP1-SSP3 scen…
measrainsey Jul 5, 2023
448cf4a
Change function name
measrainsey Jul 5, 2023
b712fb4
Update function inputs and documentation
measrainsey Jul 5, 2023
94f7447
Change polynomial regression function name
measrainsey Jul 5, 2023
7883405
Change column name
measrainsey Jul 5, 2023
b733be8
Add function to project capital costs using splines
measrainsey Jul 5, 2023
cd9b436
Add function to calculate o&m to investment costs ratios
measrainsey Jul 5, 2023
77e33dd
Update WEO tests to match new inputs
measrainsey Jul 5, 2023
e2c6ee4
Change projection function to also project fixed o&m costs
measrainsey Jul 5, 2023
62460a7
Create output of projections in IAMC format
measrainsey Jul 5, 2023
e4b05f5
Fix input for function in test
measrainsey Jul 10, 2023
5d4c5c0
Fix missing LAM cost ratios by replacing with AFR ratios
measrainsey Jul 17, 2023
ec0215d
Remove incorrect documentation
measrainsey Jul 19, 2023
8985418
Remove IAMC formatting code
measrainsey Jul 19, 2023
c9f4e24
Add function to create cost outputs
measrainsey Jul 19, 2023
243122f
Add short demo
measrainsey Jul 19, 2023
f6ae0d9
Remove unused functions import
measrainsey Jul 19, 2023
0a62a9d
Update methodology for calculating cost projections
measrainsey Jul 25, 2023
825325a
Update tests for WEO, learning, and GDP
measrainsey Jul 26, 2023
5811041
Remove unused package import
measrainsey Jul 26, 2023
4aac49a
Remove commented section at the end
measrainsey Jul 26, 2023
e98b03e
Add tests for GDP and learning
measrainsey Jul 26, 2023
ed6faf0
Remove function that is no longer needed
measrainsey Jul 26, 2023
08d681b
Update function names and docstrings
measrainsey Jul 26, 2023
e1d74ef
Add and edit tests for GDP and learning functions
measrainsey Jul 26, 2023
69c7fa1
Add option to choose whether or not to use GDP adjustments
measrainsey Jul 27, 2023
1d52c83
Fix GDP tests
measrainsey Jul 27, 2023
565a830
Remove unused functions import in test
measrainsey Jul 27, 2023
e9b051f
Add functions for calculating projections with constant learning SSP …
measrainsey Jul 28, 2023
9fee8ec
Add functionality to specify method of cost projection calculation
measrainsey Jul 31, 2023
3722006
Fix demo
measrainsey Jul 31, 2023
d9f07ee
Edit documentation and remove unused commented blocks
measrainsey Jul 31, 2023
3671942
Edit object name
measrainsey Jul 31, 2023
986bac3
Add tests for splines script
measrainsey Jul 31, 2023
1822c43
Add function to read in updated SSP data
measrainsey Aug 5, 2023
8ab6e13
Add functionality to specify node spatial resolution and reference re…
measrainsey Aug 5, 2023
9bd7c51
Script to filter and save subset of raw SSP data
measrainsey Aug 5, 2023
9f1a984
Ignore library stubs for yaml package
measrainsey Aug 6, 2023
98113e1
Implemented several changes to WEO module
measrainsey Aug 6, 2023
f017cfb
Edit to comply with linting
measrainsey Aug 6, 2023
9b2bcf3
Remove unused package import and global variable
measrainsey Aug 6, 2023
c709d57
Add missing technologies and NA for missing types
measrainsey Aug 6, 2023
935859f
Upload mapping csv for technologies and WEO
measrainsey Aug 6, 2023
3c6dde6
Add raw review phase SSP data to gitignore
measrainsey Aug 6, 2023
ed59cd4
Upload mapping of technology scenario learning rates
measrainsey Aug 6, 2023
b51cf0d
Update learning module to use input mapping
measrainsey Aug 6, 2023
d713f36
Script with basic configurations
measrainsey Aug 7, 2023
23eff81
Restructure .tools.costs to allow for specifying:
measrainsey Aug 7, 2023
f69c00c
Add regex prefix to comply with linting
measrainsey Aug 7, 2023
5c5b726
Add time steps specification to config file
measrainsey Aug 9, 2023
cfcf0aa
Edit function inputs and defaults
measrainsey Aug 9, 2023
5096665
Write tentative function to create MESSAGE scenario-compatible outputs
measrainsey Aug 24, 2023
c2d02b5
Add updated demo
measrainsey Aug 24, 2023
b77aa63
Update projections functions to run each one depending on method sele…
measrainsey Aug 24, 2023
3ba07d0
Update function to not require scenario version
measrainsey Aug 24, 2023
14ae03b
Add more demos
measrainsey Aug 24, 2023
7c4507f
Add R20 mapping
measrainsey Aug 24, 2023
3b2b864
Add adjusted base year and horizon years
measrainsey Sep 6, 2023
e616834
Create new method where splines are applied to GDP adjusted ratios
measrainsey Sep 6, 2023
1ef4b3e
Implement method to calculate costs by adding GDP path to base year r…
measrainsey Sep 7, 2023
8f93c79
Update GDP path equation
measrainsey Sep 7, 2023
bebac36
Edit for linting
measrainsey Sep 7, 2023
c1a9092
Add new GDP-adjusted cost ratio calculation
measrainsey Sep 11, 2023
7b00c9d
Add new csv for learning cost reduction rates
measrainsey Sep 12, 2023
598816e
Update function to pull cost reduction rates from new csv
measrainsey Sep 12, 2023
9a922e9
Remove commented code
measrainsey Sep 12, 2023
03970a0
Remove GDP splines and GDP path methods
measrainsey Sep 12, 2023
a4cbcc0
Remove unused functions in splines script
measrainsey Sep 12, 2023
6608119
Remove old method of calculating GDP-adjusted cost ratios
measrainsey Sep 12, 2023
0e5a4f2
Add function to save excel as .csv.gz
measrainsey Sep 12, 2023
75022a2
Read in compressed .csv.gz data instead
measrainsey Sep 12, 2023
493f102
Add LED scenario
measrainsey Sep 13, 2023
1000de0
Add functions to create outputs in MESSAGE and IAMC formats
measrainsey Sep 15, 2023
19dbf08
message_ix_models/tools/costs/projections.py
measrainsey Sep 15, 2023
334ac39
Update demo
measrainsey Sep 17, 2023
6d876bf
Remove old WEO tests
measrainsey Oct 4, 2023
5829178
Rename base technology costs mapping
measrainsey Oct 5, 2023
6f26260
Add mapping file for materials technologies
measrainsey Oct 5, 2023
d26a1d9
Add initial set of materials technologies to cost projections
measrainsey Oct 5, 2023
1cfd5d7
Remove old tests
measrainsey Oct 5, 2023
bcf0648
Edit for linting
measrainsey Oct 5, 2023
a07421e
Add new tests for WEO
measrainsey Oct 5, 2023
511bc59
Fix for linting
measrainsey Oct 5, 2023
32412c5
Remove old data reading function
measrainsey Oct 5, 2023
c63e9a2
Add new tests for GDP
measrainsey Oct 5, 2023
1a19e2e
Update tests for learning
measrainsey Oct 6, 2023
e5d7653
Add module input to projections
measrainsey Oct 10, 2023
0af592c
Comment out GDP tests for now - might need data to be uploaded
measrainsey Oct 10, 2023
9066ba3
Add updated tests for splines
measrainsey Oct 10, 2023
929bdb0
Comment out other GDP test for now
measrainsey Oct 10, 2023
cb8cdc6
Fix for linting
measrainsey Oct 10, 2023
11a94d4
Fix missing variable
measrainsey Oct 10, 2023
fe09a85
Return outputs as class instead
measrainsey Oct 10, 2023
b218eac
Add total population and total GDP to output dataframe; update docstr…
measrainsey Oct 11, 2023
154fa52
Add .tools.costs.config.Config dataclass
khaeru Oct 25, 2023
8d75930
Assign EEU to European Union
measrainsey Oct 11, 2023
79879c2
Drop population and GDP populations in function
measrainsey Oct 11, 2023
f51875f
Constrain cost ratios for negative regression slopes
measrainsey Oct 25, 2023
fbf72a4
Simple formatting for ruff
measrainsey Nov 2, 2023
c17f04b
Remove misplaced code bit
measrainsey Nov 2, 2023
f3a7e11
Update base year costs; Add other technologies
measrainsey Nov 2, 2023
8530d11
Add comment on top of base mapping file; adjust read_csv accordingly
measrainsey Nov 2, 2023
10f1ffa
Implement using Config
measrainsey Nov 3, 2023
a3bffa8
Fix median calculation in WEO data
measrainsey Nov 7, 2023
f6a6268
Fix issue with year_vtg being assigned to year_act; Filter year_act
measrainsey Nov 7, 2023
417843b
Update gitignore to not track SSP data files or scratch files
measrainsey Nov 10, 2023
a2fb5ee
Made small organizational and renaming changes
measrainsey Nov 10, 2023
8303343
Delete unused data files
measrainsey Nov 10, 2023
eef061a
Rename base module to energy module instead
measrainsey Nov 13, 2023
fb7ded0
Rename base module to energy module
measrainsey Nov 14, 2023
5d034f0
Move first year of technologies into separate csv file
measrainsey Nov 14, 2023
570b409
Rename map_source and map_technology columns to reg_diff_source and r…
measrainsey Nov 20, 2023
fba9389
Add fix-to-inv-cost ratios in tech mapping files
measrainsey Nov 20, 2023
ab8e516
Fix column names
measrainsey Nov 20, 2023
4934c57
Implement changes for materials module:
measrainsey Nov 20, 2023
6b08140
Move input CSVs to module-specific folders
measrainsey Nov 20, 2023
ed8634f
Add missing cost values of materials technologies
macflo8 Nov 21, 2023
1182295
Change LED scenario cost reduction rates
measrainsey Nov 21, 2023
6ee2d86
Fix for linting
measrainsey Nov 21, 2023
1422a60
Update docs
measrainsey Nov 23, 2023
207b770
Edit docs so that submodules are subsections
measrainsey Nov 23, 2023
e4f571c
Drop duplicates in projections
measrainsey Nov 28, 2023
2c1bd9b
Allow functionality to filter scenarios to come in earlier in GDP adj…
measrainsey Nov 28, 2023
04690b0
Switch from `.pivot()` to `.pivot_table()`
measrainsey Nov 28, 2023
2b714c6
Update tests
measrainsey Nov 28, 2023
89c2e76
Add (empty) tests/tools/costs/__init__.py
khaeru Nov 29, 2023
12c5816
Parametrize test_process_raw_ssp_data()
khaeru Nov 29, 2023
ac1ac25
Simplify assertions in test_process_raw_ssp_data()
khaeru Nov 29, 2023
a07616a
Add process_raw_ssp_data1; parametrize test
khaeru Nov 29, 2023
8219b26
Pass context to process_raw_ssp_data*()
khaeru Nov 29, 2023
66c92e7
Add a function to handle ref_region arg
khaeru Nov 29, 2023
f073a51
Partially implement process_raw_ssp_data1()
khaeru Nov 29, 2023
c87dc36
Update ExoDataSource.raise_on_extra_kw()
khaeru Nov 29, 2023
8271714
Test structure from process_raw_ssp_data()
khaeru Nov 29, 2023
80eca5c
Adjust expected years from process_raw_ssp_data()
khaeru Nov 29, 2023
6fda70d
Complete process_raw_ssp_data1()
khaeru Nov 29, 2023
5b96529
Tidy imports in .costs.gdp
khaeru Nov 29, 2023
47524a9
Ensure "scenario_version" in process_raw_ssp_data()
khaeru Nov 29, 2023
a56f5a1
Use get_codes() in test_adjust_cost_ratios_with_gdp()
khaeru Nov 29, 2023
d52b937
Parametrize test_adjust_cost_ratios_with_gdp()
khaeru Nov 29, 2023
2d68d6d
Use preprocess_raw_ssp_data1()
khaeru Nov 29, 2023
a3b62c3
Adjust expected periods in test_adjust_cost_ratios_with_gdp()
khaeru Nov 29, 2023
4f7e047
Specify selected regions to context
measrainsey Feb 6, 2024
b11bbdb
Remove previous `process_raw_ssp_data()` function and use new one only
measrainsey Feb 6, 2024
13160be
Fix and reorganize docs
measrainsey Feb 8, 2024
e881b8a
Update demo
measrainsey Feb 21, 2024
b55847c
Use .costs.Config as sole arg to create_cost_projections()
khaeru Feb 23, 2024
f1af015
Use Config as sole arg to create_projections_*()
khaeru Feb 23, 2024
f926877
Export .costs.Config, .costs.create_cost_projections
khaeru Feb 23, 2024
c9dffc6
Use common query funcs in create_projections_*()
khaeru Feb 23, 2024
021e9ed
Use Config as arg to 3 functions in .tools.costs.
khaeru Feb 23, 2024
26894ad
Use auto concat of str, not line continuation \, in code
khaeru Feb 23, 2024
012778a
Avoid line continuation in docstrings; reflow text.
khaeru Feb 23, 2024
43c9939
Include .costs.Config in docs; reference in docstrings
khaeru Feb 23, 2024
9ca582a
Use blank line before ReST list in docstrings
khaeru Feb 23, 2024
1d3995e
Return dict from create_cost_projections()
khaeru Feb 23, 2024
35980d9
Convert embedded WEO region maps with annotations
khaeru Feb 23, 2024
fac8ed5
Use log.info() instead of print() in .tools.costs
khaeru Feb 23, 2024
faaebc1
Reduce special-casing on Config.modules
khaeru Feb 23, 2024
fa37754
Remove hard-coded currency deflator
khaeru Feb 23, 2024
e04d57e
Parametrize tests of .tools.costs
khaeru Feb 23, 2024
4407e2c
Remove hard-coded BASE_YEAR, HORIZON_{START,END}
khaeru Feb 23, 2024
ef2d5b7
Move remaining .costs.config globals to .Config
khaeru Feb 26, 2024
986f609
Type hint ScenarioInfo.Y
khaeru Feb 26, 2024
1354f29
Use DataFrame.astype() instead of assign/lambda
khaeru Feb 26, 2024
8e9776e
Use pandas groupby-apply in apply_splines_to_convergence()
khaeru Feb 26, 2024
b7658eb
Simplify apply_splines_to_convergence()
khaeru Feb 26, 2024
e0312a2
Tidy docstrings in .tools.costs
khaeru Feb 26, 2024
3cc6c0b
Simplify adjust_cost_ratios_with_gdp()
khaeru Feb 26, 2024
62cbf0f
Ensure no NaN results from process_raw_ssp_data()
khaeru Feb 26, 2024
9a4a2ca
Raise NotImplementedError for R20/Intratec
khaeru Feb 26, 2024
4175116
Test that .tools.costs data can be added to the RES
khaeru Feb 26, 2024
fb36b3d
Add #99 to doc/whatsnew
khaeru Apr 9, 2024
1ada44a
Remove commented out ` # super().__init__(source, _kw)
measrainsey Mar 28, 2024
fb781c7
Handle name kwarg in `ExoDataSource.raise_on_extra_kw()`
measrainsey Mar 28, 2024
d05102c
Update pyproject to use `genno >= 1.24.0`
measrainsey Mar 28, 2024
86e68cd
Remove `print()` statement
measrainsey Mar 29, 2024
893176c
Remove splines from convergence method projection
measrainsey Apr 4, 2024
d802083
Remove splines code and splines tests
measrainsey Apr 4, 2024
d1ff973
Remove `filter_data.py` script
measrainsey Apr 4, 2024
ea30670
Remove the use of the term `learning` in the projections methods
measrainsey Apr 4, 2024
9259882
Update docs to reflect changes to `splines` and `learning` methods
measrainsey Apr 4, 2024
817b9ae
Update docs to add feedback from reviewers
measrainsey Apr 5, 2024
d01c1ec
Edit for linting
measrainsey Apr 5, 2024
cf5868d
Add linear interpolation between base year and convergence year for a…
measrainsey Apr 5, 2024
0afc6b8
Remove unused code blocks and add comments
measrainsey Apr 5, 2024
9d83bb4
Edit for linting
measrainsey Apr 8, 2024
9c9c7d2
Move .tools.costs docs to their own file
khaeru Apr 9, 2024
657a263
Tidy ReST usage in doc/api/tools-costs
khaeru Apr 9, 2024
3a0d7ee
Copyedit doc/api/tools-costs.
khaeru Apr 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,16 @@ cache/

# VSCode settings
.vscode

# DS_store
.DS_Store

# Temporary Excel files
*~$*

# SSP related files (not ready for public)
SSP-Review-Phase-1.xlsx
message_ix_models/data/ssp/*

# Scratch files
*scratch*
228 changes: 228 additions & 0 deletions doc/api/tools-costs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
.. currentmodule:: message_ix_models.tools.costs

Investment and fixed costs (:mod:`.tools.costs`)
************************************************

:mod:`.tools.costs` implements methods to **project investment and fixed costs of technologies** [1]_ in MESSAGEix-GLOBIOM family models.

.. contents::
:local:

.. [1] Fixed costs are also referred to as “operation and maintenance (O&M)” or “fixed O&M” costs.
Investment and fixed costs are also collectively referred to as “techno-economic costs” or “techno-economic parameters”.

Methods
=======

The tool creates distinct projected cost values for different regions, technologies, and scenarios.
The costs are projected based on historical (mostly a base year) data and assumptions about future cost reductions.

The projections use the concept of a **reference region** [2]_ and apply distinct methods to the reference and non-reference regions:

Reference region
Costs in the reference region are projected based on the following assumption: given a cost reduction rate, the cost of the technology in the reference region experiences an exponential decay over time.

Non-reference regions
Costs for each technology in all non-reference regions may be calculated using one of three methods, specified using :attr:`.Config.method`:

1. Constant cost reduction rate (:attr:`.Config.method` = "constant"): the regional cost ratio (versus the reference region) that is calculated in the base year is held constant and used to project regionally-differentiated costs across all years.
2. Convergence to reference region costs by a certain year (:attr:`.Config.method` = "convergence"): all other regions' costs exponentially decay until they become they same as the reference region's cost by a specified year.
3. GDP-adjusted cost reduction rate (:attr:`.Config.method` = "gdp"): this method assumes that regional costs converge not based on a specified year but based on GDP per capita.
All non-reference regions' costs are adjusted based on the ratio of the GDP per capita of the region to the GDP per capita of the reference region.

.. [2] In :mod:`message_ix`, these are elements of the ``node`` set.
The term ‘region’ is used in this documentation to mean the same thing.

Modules and model variants
==========================

Within the context of the tool, the term **module** (specified by :attr:`.Config.module`) is used to mean input data for particular *sets of technologies*.
These correspond to subsets of all the technologies in MESSAGEix-GLOBIOM models—either the base model or model variants. [3]_
Currently, :mod:`.tools.costs` supports two module :attr:`~.Config.module` settings:

"energy"
Mostly electric power technologies, as well as a few other supply-side technologies.

This can be considered the "base" module, corresponding to the "base" version of MESSAGEix-GLOBIOM, as it contains the most technologies.

"materials"
Technologies conceived as part of the materials and industry sectors.

Data and files for a particular module can refer to other modules.
This allows for values or settings for "materials" and other technologies to be assumed to match the values and settings used for the referenced "energy"-module technologies.

.. [3] This usage of “module” differs from the meaning of a “Python module”.
For instance, :mod:`message_ix_models.model.water` is a *Python module* for MESSAGEix-Nexus.
If the setting :py:`.costs.Config.module = "water"` were added, this *might* refer to input data for projecting investment and fixed costs of water technologies that are defined in :mod:`message_ix_models.model.water`—but not necessarily.

To add a new module, the following steps are required:

- In :file:`message_ix_models/data/costs/`, create another subdirectory with the name of the new module, for instance :file:`message_ix_models/data/costs/[module]/`.
- Add the following files to the new directory:

:file:`first_year_[module].csv`
A file with a list of technologies and the corresponding first year that the respective technology can start being deployed/modeled.
The file should have the following columns:

- "message_technology": the technology name.
- "first_year_original": the first year the technology can start being deployed.

:file:`tech_map_[module].csv`
A file with the mapping of technologies to a source of base year cost data.
The file should have the following columns:

- "message_technology": the technology name.
- "reg_diff_source" and "reg_diff_technology": the source data for the regional differentiation of costs and the corresponding technology to map to.

- If "reg_diff_source" is "energy", then "reg_diff_technology" should be a technology that is present in the "energy" module.
- If "reg_diff_source" is "weo", then "reg_diff_technology" should be a technology that is present in the WEO data (refer to :file:`tech_map_energy.csv` for the names of WEO technologies available, as all energy technologies are mapped to a WEO technology).
- You can also add another source of regional differentiation (in the case of :py:`module="materials"`, a newly created source called "intratec" is used).
However, this method is a little more involved as it requires extending the code to read in new source data.
- "base_year_reference_region_cost": the base year cost for the technology in the reference region.
- "fix_ratio": the ratio of fixed O&M costs to investment costs for the technology.

- Add the new module to the allowed values of :attr:`.Config.module`.

Please note that the following assumptions are made in technology costs mapping:

- If a technology is mapped to a technology in the "energy" module, then the cost reduction across scenarios is the same as the cost reduction of the mapped technology.
- If a "materials" (or any other non-"energy") technology has :py:`reg_diff_source="energy"` and the "base_year_reference_region_cost" is not empty, then the "base_year_reference_region_cost" in :file:`tech_map_[module].csv` is used as the base year cost for the technology in the reference region.
If the "base_year_reference_region_cost" is empty, then the cost reduction across scenarios is the same as the cost reduction of the mapped technology.
- If using the "materials" module, if a technology that is specified in :file:`tech_map_materials.csv` already exists in :file:`tech_map_energy.csv`, then the reference region cost is taken from :file:`tech_map_materials.csv`.
- If a technology in a module is not mapped to any source of regional differentiation, then no cost reduction over the years is applied to the technology.
- If a technology has a non-empty "base_year_reference_region_cost" but is not mapped to any source of regional differentiation, then assume no regional differentiation and use the reference region base year cost as the base year cost for all regions.

Data sources
============

The tool uses the following data sources for the regional differentiation of costs:

- WEO: the World Energy Outlook data from the International Energy Agency (IEA).
- Intratec: the Intratec data, which is a database of production costs for chemicals and other materials.

The tool also uses :mod:`.ssp.data` (via :func:`.exo_data.prepare_computer`) to adjust the costs of technologies based on GDP per capita.

Usage
=====

:func:`.create_cost_projections` is the top-level entry point.

This function takes a single :class:`.costs.Config` object as an argument. The object carries all the settings understood by :func:`.create_cost_projections` and other functions.
Those settings include the following; click each for the full description, allowable values, and defaults:

:attr:`~.Config.module`,
:attr:`~.Config.method`,
:attr:`~.Config.node`,
:attr:`~.Config.ref_region`,
:attr:`~.Config.scenario`,
:attr:`~.Config.scenario_version`,
:attr:`~.Config.base_year`,
:attr:`~.Config.convergence_year`,
:attr:`~.Config.fom_rate`, and
:attr:`~.Config.format`.

:func:`.create_cost_projections` in turn calls the other functions in the module in the correct order, and returns a Python :class:`dict` with the following keys mapped to :class:`pandas.DataFrame`.

- "inv_cost": the investment costs of the technologies in each region.
- "fix_cost": the fixed O&M costs of the technologies in each region.

To use the tool with the default settings, simply create a :class:`.Config` object and pass it as an argument to :func:`.create_cost_projections`::

from message_ix_models.tools.costs import Config, create_cost_projections

# Use default settings
cfg = Config()

# Compute cost projections
costs = create_cost_projections(cfg)

# Show the resulting data
costs["inv_cost"]
costs["fix_cost"]

These data can be further manipulated; for instance, added to a scenario using :func:`.add_par_data`.
See the file :file:`message_ix_models/tools/costs/demo.py` for multiple examples using various non-default settings to control the methods and data used by :func:`.create_cost_projections`.


Code reference
==============

The top-level function and configuration class:

.. autosummary::

Config
create_cost_projections

The other submodules implement the supporting methods, calculations, and data handling, in roughly the following order:

1. :mod:`~.costs.regional_differentiation` calculates the regional differentiation of costs for technologies.
2. :mod:`~.costs.decay` projects the costs of technologies in a reference region with only a cost reduction rate applied.
3. :mod:`~.costs.gdp` adjusts the regional differentiation of costs for technologies based on the GDP per capita of the region.
4. :mod:`~.costs.projections` combines all the above steps and returns the projected costs for each technology in each region.

.. automodule:: message_ix_models.tools.costs
:members:

.. currentmodule:: message_ix_models.tools.costs.decay

Cost reduction of technologies over time (:mod:`~.costs.decay`)
---------------------------------------------------------------

.. automodule:: message_ix_models.tools.costs.decay
:members:

.. autosummary::

get_cost_reduction_data
get_technology_reduction_scenarios_data
project_ref_region_inv_costs_using_reduction_rates

.. currentmodule:: message_ix_models.tools.costs.gdp

GDP-adjusted costs and regional differentiation (:mod:`~.costs.gdp`)
--------------------------------------------------------------------

.. automodule:: message_ix_models.tools.costs.gdp
:members:

.. autosummary::

default_ref_region
process_raw_ssp_data
adjust_cost_ratios_with_gdp

.. currentmodule:: message_ix_models.tools.costs.projections

Projection of costs given input parameters (:mod:`~.costs.projections`)
-----------------------------------------------------------------------

.. automodule:: message_ix_models.tools.costs.projections
:members:

.. autosummary::

create_projections_constant
create_projections_gdp
create_projections_converge
create_message_outputs
create_iamc_outputs

.. currentmodule:: message_ix_models.tools.costs.regional_differentiation

Regional differentiation of costs (:mod:`~.costs.regional_differentiation`)
---------------------------------------------------------------------------

.. automodule:: message_ix_models.tools.costs.regional_differentiation
:members:

.. autosummary::

get_weo_data
get_intratec_data
get_raw_technology_mapping
subset_materials_map
adjust_technology_mapping
get_weo_regional_differentiation
get_intratec_regional_differentiation
apply_regional_differentiation
4 changes: 4 additions & 0 deletions doc/api/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ General purpose modeling tools
- Codes for retrieving data from specific data sources and adapting it for use with :mod:`message_ix_models`.
- Codes for modifying scenarios; although tools for building models should go in :mod:`message_ix_models.model`.

On other pages:

- :doc:`tools-costs`

On this page:

.. contents::
Expand Down
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Commonly used classes may be imported directly from :mod:`message_ix_models`.
api/disutility
api/report/index
api/tools
api/tools-costs
api/data-sources
api/util
api/testing
Expand Down
1 change: 1 addition & 0 deletions doc/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ What's new
Next release
============

- New module for :doc:`/api/tools-costs` (:pull:`99`).
- Migrate :doc:`/api/report/legacy` to provide post-processing functionality for the :doc:`global model snapshot </api/model-snapshot>` (:pull:`159`).
- Migrate and improve code for four sources of exogenous data (:pull:`162`): :mod:`.project.gea`, :mod:`.project.shape`, :mod:`.tools.gfei`, and :mod:`.tools.iea.eei`.
- Expand :doc:`data` (:pull:`161`).
Expand Down
70 changes: 70 additions & 0 deletions message_ix_models/data/costs/energy/cost_reduction_energy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Cost reduction in 2100,,,,,,
# ,,,,,,
# Units: % ,,,,,,
#,,,,,,
# Data is copied from Sheet1 in https://github.com/iiasa/message_data/blob/dev/data/model/investment_cost/SSP_technology_learning.xlsx,,,,,,
# There are some manually changed assumptions to the original GEA data in the spreadsheet (can be seen in the spreadsheet as marked in yellow),,,,,,
# The initial copied data can be found in gea_reduction_rates.csv,,,,,,
# This file renames the learning rates from GEAL to low and GEAM to medium and GEAH to high,,,,,,
message_technology,technology_type,very_low,low,medium,high,very_high
coal_ppl,Coal,0,0,0.2,0.5,0.7
gas_ppl,Gas/Oil,0.1,0.2,0.29,0.38,0.5
gas_ct,Gas/Oil,0.1,0.2,0.29,0.38,0.5
gas_cc,Gas/Oil,0.1,0.2,0.29,0.38,0.5
bio_ppl,Biomass,0,0.1,0.2,0.3,0.4
coal_adv,Coal,0,0.1,0.3,0.5,0.7
igcc,Coal,0,0.1,0.3,0.5,0.7
bio_istig,Biomass,0,0.1,0.3,0.4,0.5
coal_adv_ccs,CCS,0,0.1,0.3,0.5,0.7
igcc_ccs,CCS,0,0.1,0.3,0.5,0.7
gas_cc_ccs,CCS,0.1,0.2,0.29,0.5,0.7
bio_istig_ccs,CCS,0,0.1,0.3,0.4,0.6
syn_liq,Coal,0,0.05,0.1,0.15,0.2
meth_coal,Coal,0,0.05,0.1,0.15,0.2
syn_liq_ccs,CCS,0,0.05,0.1,0.25,0.3
meth_coal_ccs,CCS,0,0.05,0.1,0.15,0.2
h2_coal,Coal,0,0.25,0.4,0.4,0.5
h2_smr,Gas/Oil,0,0.25,0.4,0.5,0.7
h2_bio,Biomass,0,0.25,0.4,0.5,0.7
h2_coal_ccs,CCS,0,0.25,0.4,0.5,0.7
h2_smr_ccs,CCS,0,0.25,0.4,0.5,0.7
h2_bio_ccs,CCS,0,0.25,0.4,0.5,0.7
eth_bio,Biomass,0,0.27,0.27,0.4,0.55
eth_bio_ccs,CCS,0,0.27,0.27,0.4,0.55
c_ppl_co2scr,CCS,0,0,0,0.3,0.4
g_ppl_co2scr,CCS,0,0,0,0.3,0.4
bio_ppl_co2scr,CCS,0,0,0,0.3,0.4
wind_ppl,Renewable,0.15,0.3,0.53,0.65,0.75
solar_th_ppl,Renewable,0.15,0.3,0.3,0.5,0.7
solar_pv_I,Renewable,0.15,0.3,0.7,0.9,0.95
solar_pv_RC,Renewable,0.15,0.3,0.7,0.9,0.95
solar_pv_ppl,Renewable,0.15,0.3,0.7,0.9,0.95
geo_ppl,Renewable,0,0.1,0.18,0.25,0.35
hydro_lc,Renewable,0,0,0,0,0
hydro_hc,Renewable,0,0,0,0,0
meth_ng,Gas/Oil,0,0.05,0.1,0.15,0.2
meth_ng_ccs,CCS,0,0.05,0.1,0.15,0.2
coal_ppl_u,Coal,0,0,0,0,0
stor_ppl,Renewable,0.1,0.2,0.25,0.4,0.5
h2_elec,Renewable,0,0,0.1,0.2,0.3
liq_bio,Biomass,0.15,0.27,0.27,0.4,0.55
liq_bio_ccs,CCS,0.15,0.27,0.27,0.4,0.55
coal_i,Coal,0,0,0,0,0
foil_i,Gas/Oil,0,0,0,0,0
loil_i,Gas/Oil,0,0,0,0,0
gas_i,Gas/Oil,0,0,0,0,0
biomass_i,Biomass,0,0,0,0,0
eth_i,Biomass,0,0,0,0,0
meth_i,Coal,0,0,0,0,0
elec_i,NA,0,0,0,0,0
h2_i,NA,0,0,0,0,0
hp_el_i,Renewable,0.1,0.2,0.5,0.5,0.6
hp_gas_i,Gas/Oil,0.1,0.2,0.4,0.4,0.5
solar_i,Renewable,0.1,0.2,0.6,0.9,0.95
heat_i,NA,0,0,0,0,0
geo_hpl,Renewable,0.1,0.15,0.18,0.25,0.35
nuc_lc,Nuclear,0,0,0,0,0
nuc_hc,Nuclear,0,0,0.15,0.3,0.45
wind_ppf,NA,0,0,0,0,0
csp_sm1_ppl,NA,0,0,0,0,0
csp_sm3_ppl,NA,0,0,0,0,0
Loading
Loading