Load model snapshots (model.snapshot
)
This code allows to fetch snapshots containing completely parametrized MESSAGEix-GLOBIOM model instances, and load these into Scenarios
.
Usage
From the command line, download data for a single snapshot:
$ mix-models fetch snapshot-0
…where 0 is the ID of a snapshot; see SNAPSHOTS
.
In code, use snapshot.load()
:
from message_ix import Scenario
from message_ix_models.model import snapshot
scenario = Scenario(...)
snapshot.load(scenario, 0)
Note
For snapshot 0, contrary to the description of the Zenodo item, the file cannot be loaded using Scenario.read_excel()
.
This limitation will be fixed in subsequent snapshots.
Code reference
Prepare base models from snapshot data.
- message_ix_models.model.snapshot.load(scenario: Scenario, snapshot_id: int, extra_cache_path: str | None = None) None [source]
Fetch and load snapshot with ID snapshot_id into scenario.
See also
SNAPSHOTS
- message_ix_models.model.snapshot.read_excel(scenario: Scenario, path: Path) None [source]
Similar to
Scenario.read_excel()
, but usingunpack()
.
- message_ix_models.model.snapshot.unpack(path: Path) Path [source]
Unpack ixmp-format Excel file at path.
The file is unpacked into a directory with the same name stem as the file (that is, without the
.xlsx
suffix). In this directory are created:One
.csv.gz
file for each MESSAGE and/or MACRO parameter.One file
sets.xlsx
with only theixmp
sets, and no parameter data.
If the files exist, they are not updated. To force re-unpacking, delete the files.
- Returns:
Path to the directory containing the unpacked files.
- Return type: