message_ix_models.tools.iea.web.IEA_EWEB

class message_ix_models.tools.iea.web.IEA_EWEB(source, source_kw)[source]

Bases: ExoDataSource

Provider of exogenous data from the IEA Extended World Energy Balances.

To use data from this source, call exo_data.prepare_computer() with the following source_kw:

  • provider: Either ‘IEA’ or ‘OECD’. See FILES.

  • edition: one of ‘2021’, ‘2022’, or ‘2023’. See FILES.

  • product (optional): str or list of str. Select only these labels from the ‘PRODUCT’ dimension.

  • flow (optional): str or list of str. Select only these labels from the ‘FLOW’ dimension.

  • transform (optional): either “A” (default) or “B”. See transform().

  • regions: must also be given with the value "R12" if giving transform="B".

Example

>>> keys = prepare_computer(
...     context,
...     computer,
...     source="IEA_EWEB",
...     source_kw=dict(
...         provider="OECD", edition="2022", product="CHARCOAL", flow="RESIDENT"
...     ),
... )
>>> result = computer.get(keys[0])
__init__(source, source_kw)[source]

Initialize the data source.

Methods

__init__(source, source_kw)

Initialize the data source.

get_keys()

Return the target keys for the (1) raw and (2) transformed data.

raise_on_extra_kw(kwargs)

Helper for subclasses to handle the source_kw argument.

transform(c, base_key)

Prepare c to transform raw data from base_key.

Attributes

aggregate

True if transform() should aggregate data on the \(n\) dimension.

extra_dims

Optional additional dimensions for the returned Key/Quantity.

id

Identifier for this particular source.

interpolate

True if transform() should interpolate data on the \(y\) dimension.

key

Key for the returned Quantity.

measure

Primary measure.

name

Name for the returned Key/Quantity.

aggregate: bool = True

True if transform() should aggregate data on the \(n\) dimension.

extra_dims: tuple[str, ...] = ()

Optional additional dimensions for the returned Key/Quantity. If not set by __init__(), the dimensions are \((n, y)\).

get_keys() tuple[Key, Key]

Return the target keys for the (1) raw and (2) transformed data.

Subclasses may override this method to provide different targets keys. In the default implementation, the key for the transformed data is:

  1. key, if any, or

  2. Constructed from:

The key for the raw data is the same, with :attr`.id` as an extra tag.

id: str = 'IEA_EWEB'

Identifier for this particular source.

interpolate: bool = True

True if transform() should interpolate data on the \(y\) dimension.

key: Key | None = <energy:n-y-product-flow:iea>

Key for the returned Quantity. Optional. See get_keys().

measure = ''

Primary measure.

name: str = ''

Name for the returned Key/Quantity. Optional. See get_keys().

raise_on_extra_kw(kwargs) None

Helper for subclasses to handle the source_kw argument.

  1. Store aggregate and interpolate, if they remain in kwargs.

  2. Raise ValueError if there are any other, unhandled keyword arguments in kwargs.

transform(c: Computer, base_key: Key) Key[source]

Prepare c to transform raw data from base_key.

  1. Map IEA COUNTRY codes to ISO 3166-1 alpha-3 codes, where such mapping exists. See get_mapping() and COUNTRY_NAME.

The next steps depend on whether transform="A" or transform="B" was given with the source_kw.

transform="A" (default)
  1. Aggregate using “n::groups”—the same as ExoDataSource.transform(). This operates on the \(n\) labels transformed to alpha-3 codes by step (1) above.

transform="B"
  1. Compute intermediate quantities using transform_B().

  2. Aggregate using the groups returned by get_node_groups_B().

This method does not prepare interpolation or aggregation on \(y\).