message_ix_models.model.transport.ldv.LDV
- class message_ix_models.model.transport.ldv.LDV(source, source_kw)[source]
Bases:
MaybeAdaptR11SourceProvider of exogenous data on LDVs.
- Parameters:
source_kw – Must include exactly the keys “measure” (must be one of “fuel economy”, “fix_cost”, or “inv_cost”), “nodes”, and “scenario”.
- __init__(source, source_kw) None[source]
Handle source and source_kw.
An implementation must:
Raise
ValueErrorif 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
nameand/orextra_dimsto control the behaviour ofprepare_computer().Log messages that give information that may help to debug a
ValueErrorfor 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
Trueiftransform()should aggregate data on the \(n\) dimension.Optional additional dimensions for the returned
Key/Quantity.Names of expected files given
measure.Identifier for this particular source.
Trueiftransform()should interpolate data on the \(y\) dimension.Key for the returned
Quantity.Primary measure.
Set of measures recognized by a subclass.
- aggregate: bool = True
Trueiftransform()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)\).
- filename: Mapping[str, str] = {'fix_cost': 'ldv-fix_cost.csv', 'fuel economy': 'ldv-fuel-economy.csv', 'inv_cost': 'ldv-inv_cost.csv'}
Names of expected files given
measure.
- interpolate: bool = True
Trueiftransform()should interpolate data on the \(y\) dimension.
- key: Key | None = None
Key for the returned
Quantity. Optional. Seeget_keys().
- measure = ''
Primary measure.
- measures: set[str] = {'fix_cost', 'fuel economy', 'inv_cost'}
Set of measures recognized by a subclass.
- name: str = ''
Name for the returned
Key/Quantity. Optional. Seeget_keys().
- raise_on_extra_kw(kwargs) None
Helper for subclasses to handle the source_kw argument.
Store
aggregateandinterpolate, if they remain in kwargs.Raise
ValueErrorif there are any other, unhandled keyword arguments in kwargs.
- transform(c: Computer, base_key: Key) Key
Prepare c to transform raw data from base_key.
base_key identifies the
Quantitythat 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, buttransform()allows use of othergennooperators and conveniences.)The default implementation:
If
aggregateisTrue, aggregates the data (genno.operator.aggregate()) on the \(n\) dimension using the key “n::groups”.If
interpolateisTrue, interpolates the data (genno.operator.interpolate()) on the \(y\) dimension using “y::coords”.