Refactor MESSAGEix-Materials build#475
Conversation
75a4f2a to
f83d20d
Compare
f83d20d to
6b9418b
Compare
293cf41 to
64fca17
Compare
64fca17 to
10aee8c
Compare
10aee8c to
59e5534
Compare
59e5534 to
fb59d37
Compare
fb59d37 to
4c4ec18
Compare
4c4ec18 to
a12464b
Compare
- Replace get_pycountry_iso with .util.pycountry - Speed up region mapping function
- Reorder functions - Replace t.id with getattr(t, "id", t) - Remove deprecated functions
- Convert xlsx mappings to csv and yaml - Move deprecated files to archive - Replace loops with vectorized computations - Generate parameter data dynamically based on vintage capacity of scenario
- Add csv copy of NTNU_LCA_coefficients.xlsx sheet environmentalImpacts - Adjust parser to use csv copy
Drop in favor of .util.common.load_package_data()
Drop historical countries from aluminum statistics
a12464b to
ac48376
Compare
khaeru
left a comment
There was a problem hiding this comment.
Even aside from the documented speedups, overall this looks great!
- Most removed lines (-ve diff numbers) in body code streamlined and deduplicated.
- Most added lines (+ve numbers) in docs, tests, and data files.
I left some stylistic comments inline, but none of these are blockers. I rebased after #432 was merged and the checks appear to all pass, so will merge now.
| :local: | ||
|
|
||
| Binary/raw data files | ||
| --------------------- |
There was a problem hiding this comment.
The hierarchy for headings should be * = - ^ ", per here. We omit the overline at the top of a file.
|
|
||
| The code relies on the following input files, stored in :file:`data/material/`: | ||
|
|
||
| **Cement** |
| :local: | ||
|
|
||
| Sets (:file:`material/set.yaml`) | ||
| ========================================== |
There was a problem hiding this comment.
Sphinx gives a warning if the underline is shorter/longer than the underlined text.
| This release of MESSAGEix-Materials refactors the model building code of MESSAGEix-Materials and updates some parameter sets. | ||
| It does **not** alter the model structure of MESSAGEix-Materials. | ||
|
|
||
| Summary of changes: |
There was a problem hiding this comment.
Trailing colon isn't necessary in a headline.
| Summary of changes: | ||
| =================== | ||
|
|
||
| - Remove deprecated functions and CLI commands |
| CLI changes | ||
| =========== | ||
|
|
||
| - The ``--power-sector`` option added to ``material-ix build`` command, to allow building the model with or without the power sector materials module. |
There was a problem hiding this comment.
Generally the reST/Sphinx 'program' directive can be used for full CLI commands or parts thereof (docs).
| title = {MESSAGEix-Materials v1.0.0: Representation of Material Flows and Stocks in an Integrated Assessment Model}, | ||
| url = {https://egusphere.copernicus.org/preprints/2024/egusphere-2023-3035/}, | ||
| year = {2024} | ||
| doi = {https://doi.org/10.5194/gmd-17-8321-2024}, |
There was a problem hiding this comment.
In BibTeX/BibLaTeX, the contents of the 'doi' field should just be e.g. 10.5194/gmd-17-8321-2024. When the entry is formatted into an output document, the URL is constructed automatically.
The URL is not necessary when the DOI is supplied.
|
|
||
| # add 25% total trade bound | ||
| df_dem = results["demand"] | ||
| df_dem = df_dem.groupby("year").sum(numeric_only=True) * 0.25 |
There was a problem hiding this comment.
Operations like this will be faster if chained.
| columns=lambda c: int(c) if isinstance(c, str) and c.isdigit() else c | ||
| ) | ||
| data = overwrite_hydro_intensities(data) | ||
| data = ( |
There was a problem hiding this comment.
data = (
pd.read_csv(...)
.pipe(overwrite_hydro_intensities)
.assign(technology=...)
...
)
This PR refactors the model building code of MESSAGEix-Materials and updates some parameter sets. It does not alter the model structure of MESSAGEix-Materials.
The following changes have been made:
.model.material.utilpycountryfunctions in favour of.model.util.pycountryyear_act&year_vtgdimension by entries where:.xlsxinput files to.csv.model.material.data_other_industryshare_constraints.pyEffective outcome:
How to review
developer (someone like the reviewer) will be able to understand what the code
does in the future.
PR checklist