message_ix_models.model.transport.data.IEA_Future_of_Trucks

class message_ix_models.model.transport.data.IEA_Future_of_Trucks(source, source_kw)[source]

Bases: ExoDataSource

Retrieve IEA “Future of Trucks” data.

Parameters:

measure (int) –

One of:

  1. energy intensity of vehicle distance travelled

  2. load

  3. energy intensity of freight service (mass × distance)

__init__(source, source_kw)[source]

Handle source and source_kw.

An implementation must:

  • Raise ValueError if it does not recognize or cannot handle the arguments in source or source_kw.

  • Recognize and handle (if possible) a “measure” keyword in source_kw from MEASURES.

It may:

  • Transform these into other values, for instance by mapping certain values to others, applying regular expressions, or other operations.

  • Store those values as instance attributes for use in __call__().

  • Set name and/or extra_dims to control the behaviour of prepare_computer().

  • Log messages that give information that may help to debug a ValueError for source or source_kw that cannot be handled.

It should not actually load data or perform any time- or memory-intensive operations; these should only be triggered by __call__().

Methods

__init__(source, source_kw)

Handle source and source_kw.

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.

convert_units

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.

name

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:

    • name or measure in lower-case.

    • The dimensions \((n, y)\), plus any extra_dims.

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

id: str = 'iea-future-of-trucks'

Identifier for this particular source.

interpolate: bool = True

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

key: Key | None = None

Key for the returned 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.

base_key identifies the Quantity that is returned by __call__(). Before the data is returned, transform() allows the data source to add additional tasks or computations to c that further transform the data. (These operations may be done in __call__() directly, but transform() allows use of other genno operators and conveniences.)

The default implementation:

  1. If aggregate is True, aggregates the data ( genno.operator.aggregate()) on the \(n\) dimension using the key “n::groups”.

  2. If interpolate is True, interpolates the data ( genno.operator.interpolate()) on the \(y\) dimension using “y::coords”.