Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
284 commits
Select commit Hold shift + click to select a range
7cc6419
Add bounds to extract_salinewater_cool
Wegatriespython Sep 26, 2025
5b1449f
Refactor add_cool_tech
Wegatriespython Sep 26, 2025
582f09f
Add basin filtering
Wegatriespython Aug 27, 2025
771cb0f
Update documentation for NEWPATHWAYS (#385)
yiyi1991 Aug 12, 2025
6c0bbaa
Bump actions/checkout from 4 to 5 in the all-actions group
dependabot[bot] Aug 17, 2025
5c86aa5
Adjust test_disutility for message_ix#451
khaeru Aug 18, 2025
4d2dd41
Add new materials and industry reporting
macflo8 Nov 5, 2024
5768a6b
Correct syntax for materials reporting to change units
OFR-IIASA Nov 7, 2024
6c501e8
Extend and rename variable mappings
macflo8 Nov 7, 2024
e269554
Silence pandas FutureWarnings in reporting
macflo8 Jun 3, 2024
5ede6e7
Improve materials reporting
macflo8 Jun 3, 2024
3fd11ea
Fix bug in refactored materials reporting function
macflo8 Jun 6, 2024
411ddcc
Remove unused context from materials reporting
macflo8 Sep 5, 2024
0d67faf
Fix methanol final energy allocation bug
macflo8 Nov 21, 2024
e6a0c37
Add exception for LED methanol reporting
macflo8 Dec 9, 2024
3b76ebf
Exclude pre-firstmodelyear years from material rep
macflo8 Dec 12, 2024
06e1b4a
Fix materials reporting bugs
macflo8 Jan 19, 2025
0613e18
Fix Other Sector string manipulation bug
macflo8 Feb 17, 2025
0af02fd
Fix aggregation of Final Energy Methanol
macflo8 Feb 17, 2025
b850ac5
Fix typo in chemicals biomass aggregation
macflo8 Feb 17, 2025
73db7c5
Set Liquids|Other to 0 after re-allocation
macflo8 Feb 17, 2025
8b9d57f
Fix Industry Electricity components
macflo8 Feb 17, 2025
2728304
Update reporting to new meth_h2 modes
macflo8 Feb 17, 2025
f0605d9
Adjust Materials reporter computation
macflo8 Feb 19, 2025
b572007
Fix industry reporting issues
macflo8 Mar 4, 2025
12a075e
Add missing electricity in ammonia aggregate
macflo8 Mar 4, 2025
9df3c37
Fix double counting of high-value chemicals
macflo8 Mar 4, 2025
f4037e8
Add new rooftop solar technology to reporting
macflo8 Apr 28, 2025
1bb9235
Update Final Energy|Industry|Other Sector
OFR-IIASA Apr 30, 2025
5390c02
Add rooftop solar to Industry|Electricity|Solar
OFR-IIASA Apr 30, 2025
d1d59aa
Add missing component in ammonia aggregate
macflo8 Apr 30, 2025
e3cdd9d
Fix code quality issues in materials reporter
macflo8 Aug 8, 2025
f1c1f64
Address mypy error
macflo8 Aug 8, 2025
8be82da
Test new materials reporter config parser
macflo8 Aug 11, 2025
0c22242
Simplify materials reporter config parser
macflo8 Aug 11, 2025
bd52d27
Fix materials reporting mapping errors
macflo8 Aug 14, 2025
5b19270
Extend docstrings and type hints
macflo8 Aug 21, 2025
c1069ba
Update docs
macflo8 Aug 21, 2025
43cd43c
Add "pydantic" to "material" optional dependencies
macflo8 Aug 25, 2025
b1d4f2f
Address inline comments
macflo8 Sep 1, 2025
18a90b2
Rename materials reporting configs
macflo8 Sep 1, 2025
199ae8f
Improve methanol Reporter Key definition functions
macflo8 Sep 1, 2025
f519916
Extend materials reporter tests
macflo8 Sep 1, 2025
c222fe5
Ignore flake8 rules in test_run_reporting
macflo8 Sep 2, 2025
3c0c4ce
Expand docs for #395
macflo8 Sep 2, 2025
6c8e91d
Make methanol reporting test pass
macflo8 Sep 2, 2025
d7da52f
Resolve formatting issues in docstrings
macflo8 Sep 2, 2025
dedd480
Add guard close in format_reporting_df
macflo8 Sep 2, 2025
9a231cb
Adjust fe_methanol_ammonia_aggregates.yaml
khaeru Sep 2, 2025
52da691
Improve .material.report.run_reporting.Config
khaeru Sep 2, 2025
ee6567c
Add more test stubs of .material…run_reporting
khaeru Sep 2, 2025
ed5ae03
Temporarily XFAIL one test for iiasa/ixmp#595
khaeru Sep 2, 2025
b128173
Revise material docs
macflo8 Sep 2, 2025
0505162
Bump actions/setup-java from 4 to 5 in the all-actions group (#409)
dependabot[bot] Sep 3, 2025
1500371
Add inter pipe generatoer
yiyi1991 May 7, 2025
e9af3dc
Build and report GEI4 baseline
yiyi1991 May 7, 2025
c63ebf3
Add UHV inter pipe config
yiyi1991 May 7, 2025
5dd08ab
Update config and generator functions
yiyi1991 Jul 24, 2025
cb3163e
Insert addtional hard-coded relation
yiyi1991 Jul 24, 2025
1f97468
Update main run file
yiyi1991 Jul 24, 2025
4b34969
Update report
yiyi1991 Jul 24, 2025
5a54330
Update doc
yiyi1991 Jul 24, 2025
091794b
Add milestones in doc
yiyi1991 Jul 25, 2025
6463477
Integrate report into the run file
yiyi1991 Jul 28, 2025
da60972
Replace os.path.join with path.parent and reduce redundant setting
yiyi1991 Jul 28, 2025
d454414
Update autosummary in doc
yiyi1991 Jul 28, 2025
538ad55
Add placeholder for tests
yiyi1991 Jul 28, 2025
5d5b799
Refactor to pass scenario info via args instead of config
yiyi1991 Aug 3, 2025
3b890a3
Add tests with test scenario and config fixture
yiyi1991 Aug 4, 2025
4cccb75
Code quality related changes
yiyi1991 Aug 25, 2025
950c31d
Update test scenario with minimum pipe technologies
yiyi1991 Aug 27, 2025
f856833
Restructure two functions with scenario object args
yiyi1991 Aug 27, 2025
35b30c3
Adjust syntax to pass tests under multiple env
yiyi1991 Aug 27, 2025
b78af8c
Satisfy mypy in .generate_inter_pipe
khaeru Sep 4, 2025
4c6d738
Use pd.DataFrame.assign() in inter_pipe_bare()
khaeru Sep 4, 2025
6c858d8
Set y₀=2030 in inter_pipe test scenario
khaeru Sep 4, 2025
6819a17
Remove .generate_inter_pipe.get_logger()
khaeru Sep 4, 2025
133a33c
Simplify inter_pipe_build()
khaeru Sep 4, 2025
9893f00
Use YAML 'true'/'false' in inter_pipe/config.yaml
khaeru Sep 4, 2025
a39de53
Improve config handling in .inter_pipe
khaeru Sep 5, 2025
6239c38
Reduce complexity 21 → 11 in inter_pipe_bare()
khaeru Sep 5, 2025
6f4d062
Add inter_pipe_bare(…, target_dir…) argument
khaeru Sep 5, 2025
0b91605
Reduce complexity to ≤11 in inter_pipe_build()
khaeru Sep 5, 2025
d89dcc3
Shorten FQNs in .inter_pipe
khaeru Sep 5, 2025
af923ed
Update function calls in workflow accordingly
yiyi1991 Sep 6, 2025
2eaac6a
Add docstrings to project run files
yiyi1991 Sep 6, 2025
5923bda
Update doc and add whatsnew
yiyi1991 Sep 6, 2025
be52123
Mark v2025.9.9 in doc/whatsnew
khaeru Sep 9, 2025
6fb59d4
Copyedit docs, whatsnew for v2025.9.9
khaeru Sep 9, 2025
9dbd696
Move doc/global/index to a new toctree section
khaeru Sep 4, 2025
6c2b586
Tidy doc/index.rst
khaeru Sep 4, 2025
223d440
Update docs
macflo8 Aug 27, 2024
5798f2b
Revise materials documentation
macflo8 Aug 29, 2024
4c4b7bd
Keep solar and biomass base year industry bounds
macflo8 Jun 3, 2024
f86123d
Update non-metallic minerals base year calibration
macflo8 Jun 3, 2024
375c83a
Add non-CO2 emissions factors to industry furnaces
macflo8 Jun 5, 2024
b3f7db7
Remove deprecated Materials gas heat pumps
macflo8 Jun 5, 2024
bc3f0cb
Remove duplicated technology in set and format
macflo8 Jun 5, 2024
b4add2f
Fix non-CO2 furnace build bugs
macflo8 Jun 5, 2024
a94b09c
Add furnaces to existing GAINS link relation
macflo8 Jun 6, 2024
7c5623e
Fix missing years error caused by data_generic.py
macflo8 Jun 18, 2024
c83f43c
Exclude chemicals flow from i_spec calibration
macflo8 Jul 29, 2024
cad9d65
Reorganize materials commands 2
macflo8 Jul 29, 2024
19112b5
Run TE-tool with "gdp" method by default
macflo8 Aug 1, 2024
f7519e5
Clean up new custom SSP build helper
macflo8 Aug 1, 2024
425c539
Add filter for relations in methanol build
macflo8 Aug 1, 2024
95b747d
Add technologies to remove section to set.yaml
macflo8 Aug 1, 2024
ef0e8ee
Add extra MACRO calibration CLI command
macflo8 Aug 1, 2024
f2f4221
Add industry non-CO2 emission data file
macflo8 Aug 6, 2024
532a186
Add share constraint generator
macflo8 Aug 14, 2024
1ef5a1f
Move "other industry" utilities to module
macflo8 Aug 14, 2024
7138a0e
Extend docstrings and type hints
macflo8 Aug 16, 2024
c104510
Split calibration function
macflo8 Aug 16, 2024
3a6b5bc
Move CCS parametrization to input files
macflo8 Aug 16, 2024
2b427ed
Move set modification to set.yaml
macflo8 Aug 16, 2024
862aedb
Add filename to iea_data_path cli option
macflo8 Aug 19, 2024
1d5d2fb
Add new residual industry calibration
macflo8 Aug 19, 2024
c1319bd
Generalize coal_i share constraint helper
macflo8 Aug 19, 2024
b519715
Remove deprecated CCS function from build
macflo8 Aug 19, 2024
75b9f14
Fix new "other industry" calibration workflow
macflo8 Aug 21, 2024
5960aff
Update data_generic to sdmx Code set
macflo8 Sep 2, 2024
3533515
Extend type hints and docstrings to data_util
macflo8 Sep 2, 2024
c152dfb
Add water sets missing in SSP_dev
macflo8 Sep 2, 2024
fb9ec99
Add MTO_petro 0 bound_activity_up for 2025
macflo8 Sep 2, 2024
438c117
Move co2_trans_disp parametrization to file
macflo8 Sep 2, 2024
2d197b9
Reorganize parametrization scripts
macflo8 May 31, 2025
3c4e1c9
Add new demand and activity data to other industry
macflo8 Sep 2, 2024
4f293f9
Add low temp heat share constraint modifier
macflo8 Sep 2, 2024
bbc5593
Integrate parametrization updates in build
macflo8 Sep 2, 2024
5e2b685
Fix fix_cost timeseries break for i_therm tecs
macflo8 Sep 3, 2024
f0f7dec
Update SSP MACRO calibration workflow
macflo8 Sep 3, 2024
9c176cf
Extend SSP 2020 activity calibration procedure
macflo8 Sep 3, 2024
ff9be6d
Rename share constraint generator function
macflo8 Sep 5, 2024
74a500f
Add new plastics CO2_Emission calculator
macflo8 Oct 12, 2024
04fbd9f
Extend methanol fs downstream supply chain
macflo8 Oct 15, 2024
3049992
Add missing SSP industry input files
macflo8 May 31, 2025
6f39fba
Fix material balance of MTO_petro technology
macflo8 Oct 22, 2024
22a0459
Add new CO2_ind calculator for chemicals
macflo8 Oct 23, 2024
49f9a7a
Add embodied emissions for ethanol to ethylene
macflo8 Oct 27, 2024
cb0e432
Remove "World" meth_ind_fs parameter regions
macflo8 Oct 28, 2024
0728550
Fix biomass_nh3_ccs CO2_Emission coefficient
macflo8 Oct 28, 2024
5f43f5b
Add ethanol_to_ethylene CO2_ind emi factor
macflo8 Oct 28, 2024
9209e76
Replace get_nodes with tested utility
macflo8 Nov 1, 2024
66028f1
Fix merge duplication
macflo8 Nov 11, 2024
bd22d63
Add macro calibration files for all SSPs
macflo8 Nov 19, 2024
d7cb1ea
Add macro calibration files for SSPs
OFR-IIASA Dec 2, 2024
159c570
Change data_methanol syntax for reading file
OFR-IIASA Dec 2, 2024
03dcfa3
Fix 2025 ammonia demand to SSP2 for all SSPs
macflo8 May 11, 2025
e123ee9
Fix 2025 methanol demand to SSP2 for all SSPs
macflo8 May 11, 2025
58b91e6
Fix 2025 HVC demand to SSP2 for all SSPs
macflo8 May 11, 2025
f99b527
Add typing to ssp functions to resolve warning
macflo8 Dec 2, 2024
4a24387
Reduce redundant rows from furnace data
macflo8 May 11, 2025
a7db29b
Reduce redundant rows from petrochemicals data
macflo8 May 11, 2025
64f0ecb
Fix 2025 industry energy demands for all SSPs
macflo8 Dec 5, 2024
1ab22de
Start changelog for SSP development
macflo8 Dec 20, 2024
50f2ab7
Refine formatting of SSP changelog
macflo8 Jan 7, 2025
10ef865
Add argument for cost-tool function call horizon
OFR-IIASA Jan 29, 2025
fef1966
Fix input level for furnace_biomass_refining tec
macflo8 Jan 29, 2025
ea30bae
Fix 2025 methanol demand
macflo8 Jan 29, 2025
26b880b
Remove .costs.Config.final_year usage in data_util
macflo8 Sep 8, 2025
059e818
Satisfy ruff, mypy in data_util.py
macflo8 Sep 8, 2025
946a91c
Add (but disabled) temporary fix for handling incosistent entries fro…
OFR-IIASA Feb 20, 2025
671d033
Remove temporary code snippet for adjusting fix_ and inv_cost
OFR-IIASA Mar 12, 2025
27f5fe6
Fix update_macro_calib routine when extrapolating values to assign co…
OFR-IIASA Mar 24, 2025
25d9df4
Change refinery hydrogen level
macflo8 Mar 18, 2025
6b7c104
Fix ammonia CCS activity in 2020/2025
macflo8 Mar 24, 2025
e3f75d2
Adjust materials SSP workflow
macflo8 Jun 2, 2025
0099a7f
Fix relation_activity coefficients
macflo8 Apr 30, 2025
6f43c84
Refactor material demand module
macflo8 Feb 17, 2025
00a49ed
Fix steel model bugs
macflo8 Mar 3, 2025
6cdec93
Replace inf values in materials reporter
macflo8 May 20, 2025
17d0f8b
Clean up .material.data_util
macflo8 May 31, 2025
8a0cb2e
Extend MACRO input file updater
macflo8 Jun 12, 2025
586c5ec
Update residual industry energy calibration
macflo8 May 30, 2025
789b542
Remove industry share constraints for 2025
macflo8 May 30, 2025
036daa6
Deduct rooftop solar from sp_el_I
macflo8 May 30, 2025
9c3013e
Correct syntax to ensure all i_spec sectors calibration values are up…
OFR-IIASA Jun 4, 2025
36ad856
Update residual industry energy demands
macflo8 Jun 16, 2025
7e73f43
Fix incorrect reference to scen -> scenario in materials build
OFR-IIASA Jun 17, 2025
a0d64ed
Refactor petrochemicals input data
macflo8 Aug 1, 2025
d9904d9
Refactor ammonia input data
macflo8 Aug 1, 2025
83e1441
Clean up methanol data directory
macflo8 Aug 6, 2025
ca1b7e4
Improve chemicals modules docstrings
macflo8 Aug 7, 2025
1f4ef6a
Replace combine_df_dictionaries with merge_data
macflo8 Aug 7, 2025
e8104a0
Test data_petro.py
macflo8 Aug 7, 2025
8b97c89
Fix code complexity issue
macflo8 Aug 7, 2025
1f7d0e3
Update material.data_util docstrings and typing
macflo8 Aug 7, 2025
9a7f764
Extend model.material docstrings coverage
macflo8 Sep 9, 2025
ed9897b
Satisfy ruff, mypy in model.material
macflo8 Sep 9, 2025
988ede3
Extend materials unit test set
macflo8 Sep 10, 2025
277cac7
Adjust typing in math.py for Python 3.9
macflo8 Sep 10, 2025
8573fa9
Rename materials demand module
macflo8 Sep 12, 2025
d8a4036
Extend .material.data_generic test coverage
macflo8 Sep 12, 2025
a5f7e25
Test macro calibration file updater
macflo8 Sep 12, 2025
a9afe1b
Add tests for share_constraints.py
macflo8 Sep 14, 2025
67ee5a6
Satisfy ruff, mypy in model.material.demand
macflo8 Sep 14, 2025
9df63d0
Ignore mypy errors for test mocks
macflo8 Sep 14, 2025
935d57f
Adjust test for message_ix==3.8
macflo8 Sep 14, 2025
5ad9ba3
Update materials 1.2.0 docs
macflo8 Sep 14, 2025
19dde90
Add #418 to whatsnew
macflo8 Sep 14, 2025
e8c7e54
Replace :func: with :py: for deprecated functions
macflo8 Sep 15, 2025
28be2f2
Add model.material.data_util to code references
macflo8 Sep 15, 2025
90bb185
Add missing periods at line ends
macflo8 Sep 15, 2025
2fe6c15
Fix heading underline length
macflo8 Sep 15, 2025
67238f2
Turn .model.material.demand into a module
macflo8 Sep 15, 2025
c9e905c
Add description for share constraint constants
macflo8 Sep 15, 2025
d9e61d3
Fix renamed module references
macflo8 Sep 15, 2025
cde3223
Migrate docs for 6 projects from message_data
khaeru Sep 16, 2025
5e8e86d
Add links to 8 project docs in message_data
khaeru Sep 16, 2025
c3193f3
Add doc/howto/doc-project
khaeru Sep 16, 2025
6291629
Add doc/howto/pull-request
khaeru Sep 16, 2025
231dbdb
Add Organization, Roadmap headings to doc/develop
khaeru Sep 17, 2025
7a71bfd
Add #423 to doc/whatsnew
khaeru Sep 17, 2025
79a3003
Adjust use of local_inv() in doc/conf.py
khaeru Sep 17, 2025
827176e
Copyedit doc/{develop,howto} per review
khaeru Sep 17, 2025
82843df
Add technology dim to transport elasticity_f data
khaeru Aug 7, 2025
872d72c
Use full codes like "F ROAD" in .transport.freight
khaeru Aug 13, 2025
653c7fc
Add 4 transport/R12/pdt-cap/DIGSY-*.csv files
r-aneeque Aug 25, 2025
614df86
Adjust transport/R12/elasticity-f.csv for #392
r-aneeque Aug 27, 2025
a065639
Adjust transport/R12/ldv-activity.csv for #392
r-aneeque Aug 29, 2025
2412286
Adjust transport/R12/lifetime-ldv.csv for #392
r-aneeque Sep 1, 2025
f0f65a7
Move load-factor-ldv.csv → load-factor-ldv/{label}.csv
khaeru Sep 1, 2025
9c602d5
Add load-factor-ldv files for DIGSY, EDITS
khaeru Sep 3, 2025
d9584cf
Add .transport.Config.code property
khaeru Sep 3, 2025
c96f33f
Set .transport.Config.code in configure_build()
khaeru Sep 18, 2025
3be457a
Add .transport.data.{MultiFile,LoadFactorLDV}
khaeru Sep 3, 2025
92cb705
Existing config takes precedence in get_computer()
khaeru Sep 3, 2025
d1f0d3d
Remove former tasks for handling LDV load factor
khaeru Sep 3, 2025
717d5b3
Clean parameterization of test_build.test_debug
khaeru Sep 3, 2025
5542071
Alias non-Pythonic names in ItemSchemeEnumType
khaeru Sep 18, 2025
82ed777
Add DIGSY 'stretch' scenarios (#400)
khaeru Sep 3, 2025
210c3b8
Add DIGSY scenarios to 'transport' CI workflow
khaeru Aug 7, 2025
94e466a
Clean DIGSY pdt-cap data files
khaeru Sep 3, 2025
0f11dd3
Tidy transport tests for #392
khaeru Sep 18, 2025
9d18a4e
Add #392 to doc/whatsnew
khaeru Sep 19, 2025
7d168fe
Set ot_saline growht new cap growth rate 0
Wegatriespython Sep 4, 2025
d82a79b
Swap basin to reg inputs
Wegatriespython Sep 8, 2025
6489338
Fix filtering
Wegatriespython Sep 26, 2025
bb9e2c9
Restore feasibility
Wegatriespython Sep 29, 2025
7a992b6
Handle cooling inp commodity case
Wegatriespython Oct 6, 2025
8e41b67
Init commit for ALPs 16 B
Wegatriespython Sep 24, 2025
ea689e1
Add subannual timeslice functionality for nexus module
Wegatriespython Oct 6, 2025
4df9e53
Patch subannual issues
Wegatriespython Oct 15, 2025
3983713
Add helper scripts for subannual
Wegatriespython Oct 20, 2025
333b058
Working Emissions-Magicc Pipeline
Wegatriespython Oct 20, 2025
4582d30
Add generation script + Magicc runner
Wegatriespython Oct 24, 2025
810b5bf
Add RIME predicted qtot, qr scripts
Wegatriespython Oct 24, 2025
c7f613e
Update reporting to latest SSP_DEV
Wegatriespython Oct 24, 2025
d03f00c
Add script to call emission reporting
Wegatriespython Oct 27, 2025
82f2809
Add other config files
Wegatriespython Oct 27, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/pytest-snapshots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
key: ubuntu-latest

- name: Check out message-ix-models
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
lfs: true

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
${{ secrets.MESSAGE_STATIC_DATA_PRIVATE_KEY }}

- name: Check out message-static-data
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
repository: iiasa/message-static-data
path: message-static-data
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:

- name: Set Java version on Windows
if: startsWith(matrix.os, 'windows-')
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '21'
Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with: { ref: "${{ needs.check.outputs.ref }}" }
- uses: astral-sh/setup-uv@v6
with: { python-version: "${{ env.python-version }}" }
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/transport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ env:
"SSP4 policy",
"SSP5",
"SSP5 policy",
"DIGSY-BEST-C",
"DIGSY-BEST-S",
"DIGSY-WORST-C",
"DIGSY-WORST-S",
"EDITS-CA",
"EDITS-HA",
"LED-SSP1",
Expand Down
219 changes: 219 additions & 0 deletions build_nexus_subannual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
"""
Build MESSAGEix-Nexus scenario with subannual timeslices.

This script implements a full pipeline for creating a water-energy nexus model
with subannual temporal resolution:
1. Load base annual scenario
2. Add subannual timeslices
3. Validate timesliced scenario
4. Build nexus module on timesliced scenario
5. Solve final subannual nexus model
"""

import logging
import sys

from message_ix_models import Context
from message_ix_models.model.water.build import main as build_nexus
from message_ix_models.model.water.cli import water_ini
from message_ix_models.project.alps.timeslice import add_timeslices

# Configure logging for SLURM - force unbuffered output to stdout
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
handler.flush = sys.stdout.flush

logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[handler],
force=True
)
log = logging.getLogger(__name__)

# ========== CONFIGURATION ==========
MODEL = "MESSAGE_GLOBIOM_SSP2_v6.1"
BASE_SCEN = "baseline"
N_TIME = 2 # 2 seasonal timeslices
REGIONS = "R12"

# Nexus configuration
RCP = "7p0"
SDG = "baseline"
REL = "low"
SSP = "SSP2"

# Basin filtering for reduced nexus
REDUCED_BASIN = True
FILTER_LIST = [
"10|SAS",
"115|SAS",
"124|SAS",
"12|SAS",
"141|SAS",
"148|SAS",
"15|SAS",
"24|SAS",
"30|SAS",
"50|SAS",
"53|SAS",
"65|SAS",
"66|SAS",
"67|SAS",
"70|SAS",
]

# Timeslice configuration
REMOVE_COOLING = True # Remove cooling techs before adding timeslices (water module adds them back)

# Solve configuration
SOLVE_OPTIONS = {
"lpmethod": "4",
"scaind": "-1",
"threads": "16",
"iis": "1"
}

# Pipeline control
VALIDATE_TIMESLICE = True # Set to True to solve timesliced scenario before adding nexus
SOLVE_FINAL = True # Set to False to skip final solve

def main():
"""Execute the full subannual nexus pipeline."""

# ========== STEP 1: Load Base Scenario ==========
log.info("=" * 80)
log.info("STEP 1: Loading base scenario")
log.info("=" * 80)

ctx = Context()
ctx.handle_cli_args(url=f"ixmp://ixmp_dev/{MODEL}/{BASE_SCEN}")

sc_base = ctx.get_scenario()
log.info(f"Loaded base scenario: {sc_base.model}/{sc_base.scenario} v{sc_base.version}")

# ========== STEP 2: Clone and Add Timeslices ==========
log.info("=" * 80)
log.info(f"STEP 2: Adding {N_TIME} monthly timeslices")
log.info("=" * 80)

sc_timeslice = sc_base.clone(
model=MODEL,
scenario=f"{BASE_SCEN}_t{N_TIME}",
keep_solution=False
)
log.info(f"Cloned to: {sc_timeslice.model}/{sc_timeslice.scenario} v{sc_timeslice.version}")

# Add timeslices
ctx.regions = REGIONS
sc_timeslice = add_timeslices(
scenario=sc_timeslice,
context=ctx,
n_time=N_TIME,
remove_cooling_tec=REMOVE_COOLING,
)

log.info(f"Timeslices added successfully")

# Verify time structure
times = sc_timeslice.set("time")
log.info(f"Time slices in scenario: {list(times)}")

# ========== STEP 3: Solve Timesliced Scenario ==========
log.info("=" * 80)
log.info("STEP 3: Solving timesliced scenario")
log.info("=" * 80)

if VALIDATE_TIMESLICE:
log.info("Solving timesliced scenario...")
sc_timeslice.set_as_default()
try:
sc_timeslice.solve(solve_options=SOLVE_OPTIONS)
log.info("Timesliced scenario solved successfully!")
except Exception as e:
log.error(f"Failed to solve timesliced scenario: {e}")
raise
else:
log.info("Skipping validation solve (VALIDATE_TIMESLICE=False)")

# ========== STEP 4: Initialize Water Context ==========
log.info("=" * 80)
log.info("STEP 4: Initializing water/nexus context")
log.info("=" * 80)

ctx.ssp = SSP
water_ini(ctx, regions=REGIONS, time=None) # Will auto-detect timeslices from scenario

log.info(f"Detected time structure: {ctx.time}")

# Configure nexus
ctx.nexus_set = "nexus"
ctx.RCP = RCP
ctx.SDG = SDG
ctx.REL = REL
ctx.reduced_basin = REDUCED_BASIN
ctx.filter_list = FILTER_LIST

log.info(f"Nexus configuration:")
log.info(f" SSP: {ctx.ssp}")
log.info(f" RCP: {ctx.RCP}")
log.info(f" SDG: {ctx.SDG}")
log.info(f" REL: {ctx.REL}")
log.info(f" Reduced basins: {ctx.reduced_basin}")
if ctx.reduced_basin:
log.info(f" Filtered basins: {len(ctx.filter_list)} basins")

# ========== STEP 5: Build Nexus on Timesliced Scenario ==========
log.info("=" * 80)
log.info("STEP 5: Building nexus module on timesliced scenario")
log.info("=" * 80)

sc_nexus = sc_timeslice.clone(
model=MODEL,
scenario=f"{BASE_SCEN}_t{N_TIME}_nexus_reduced",
keep_solution=False
)
log.info(f"Cloned to: {sc_nexus.model}/{sc_nexus.scenario} v{sc_nexus.version}")

log.info("Adding nexus structure and data...")
build_nexus(ctx, sc_nexus)
log.info("Nexus build completed")

# ========== STEP 6: Solve Final Model ==========
log.info("=" * 80)
log.info("STEP 6: Solving final subannual nexus model")
log.info("=" * 80)

sc_nexus.set_as_default()

log.info(f"Scenario: {sc_nexus.model}/{sc_nexus.scenario} v{sc_nexus.version}")
log.info(f"Solve options: {SOLVE_OPTIONS}")

if SOLVE_FINAL:
log.info("Starting solve...")
try:
sc_nexus.solve(solve_options=SOLVE_OPTIONS)
log.info("=" * 80)
log.info("SUCCESS! Subannual nexus model solved successfully")
log.info("=" * 80)
log.info(f"Final scenario: {sc_nexus.model}/{sc_nexus.scenario} v{sc_nexus.version}")
except Exception as e:
log.error(f"Solve failed: {e}")
log.error("Check solver logs for details")
raise
else:
log.info("Solve skipped (SOLVE_FINAL=False)")
log.info(f"Scenario ready for solving: {sc_nexus.model}/{sc_nexus.scenario} v{sc_nexus.version}")

return sc_nexus


if __name__ == "__main__":
try:
scenario = main()
print("\n" + "=" * 80)
print("Pipeline completed successfully!")
print("=" * 80)
except Exception as e:
log.error(f"Pipeline failed: {e}", exc_info=True)
raise
3 changes: 1 addition & 2 deletions doc/api/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ IAMC data structures (:mod:`.tools.iamc`)
.. automodule:: message_ix_models.tools.iamc
:members:

.. currentmodule:: message_ix_models.tools.policy

Policies (:mod:`.tools.policy`)
===============================

Expand Down Expand Up @@ -143,5 +141,6 @@ Tools for scenario manipulation
add_budget
add_emission_trajectory
add_tax_emission
inter_pipe
remove_emission_bounds
update_h2_blending
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def local_inv(name: str, *parts: str) -> Optional[str]:
"m-data": (
f"https://{_token}:@docs.messageix.org/projects/models-internal/en/latest/",
# Use a local copy of objects.inv, if the user has one
(local_inv("message_data"), None),
local_inv("message_data"),
),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"pint": ("https://pint.readthedocs.io/en/stable/", None),
Expand Down
Loading
Loading