Models and variants (model)

model.structure: Model structure information

message_ix_models.model.structure.codelists(kind: str) List[str][source]

Return a valid IDs for code lists of kind.


kind (str) – “node” or “year”.

message_ix_models.model.structure.process_units_anno(set_name: str, code: Code, quiet: bool = False) None[source]

Process an annotation on code with id=”units”.

The annotation text is wrapped as 'registry.Unit("{text}")', such that it can be retrieved with eval_anno() or ScenarioInfo.units_for(). If code has direct children, the annotation is also copied to those codes.

  • set_name (str) – Used in logged messages when quiet is False.

  • quiet (bool, optional) –

    If False (the default), log on level WARNING if:

    • the annotation is missing, or

    • its text is not parseable with the pint application registry, i.e. iam_units.registry.

    Otherwise, log on DEBUG.

message_ix_models.model.structure.get_codes(name: str) List[Code][source]

Return codes for the dimension/set name in MESSAGE-GLOBIOM scenarios.

The information is read from data/name.yaml, e.g. data/technology.yaml.

When name includes “node”, then child codes are automatically populated from the ISO 3166 database via pycountry. For instance:

  name: Custom region
  child: [AUT, SCG]

…results in a region with child codes for Austria (a current country) and the formerly-existing country Serbia and Montenegro.


name (str) – Any .yaml file in the folder message_ix_models/data/.


Every Code has id, name, description, and annotations attributes. Calling str() on a code returns its id.

Return type

list of Code

The available code lists are reproduced as part of this documentation. The returned code objects have annotations that vary by set. See:

Also available is cd_links/unit.yaml. This is a project-specific list of units appearing in CD-LINKS scenarios.


>>> from message_ix_models.model.structure import get_codes
>>> codes = get_codes("node/R14")

# Show the codes
>>> codes
[<Code ABW: Aruba>,
 <Code AFG: Afghanistan>,
 <Code AGO: Angola>,
 <Code ZWE: Zimbabwe>,
 <Code World: World>,
 <Code R11_PAS: Other Pacific Asia>,
 <Code R11_SAS: South Asia>,
 <Code R11_WEU: Western Europe>]

# Retrieve one code matching a certain ID
>>> world = codes[codes.index("World")]

# Get its children's IDs strings, e.g. for a "node" dimension
>>> [str(c) for c in world.child]

# Navigate from one ISO 3166-3 country code to its parent
>>> AUT = codes[codes.index("AUT")]
>>> AUT.parent
<Code R11_WEU: Western Europe>

See also