message_ix_models.model.material.report.config.Config
- class message_ix_models.model.material.report.config.Config(iamc_prefix: str, unit: ~typing.Literal['Mt/yr', 'GWa', 'Mt CH4/yr', 'GW'], var: ~typing.Literal['out', 'in', 'ACT', 'emi', 'CAP'], mapping: ~pandas.core.frame.DataFrame = <factory>)[source]
Bases:
objectConfiguration for reporting of a subset of material data.
- __init__(iamc_prefix: str, unit: ~typing.Literal['Mt/yr', 'GWa', 'Mt CH4/yr', 'GW'], var: ~typing.Literal['out', 'in', 'ACT', 'emi', 'CAP'], mapping: ~pandas.core.frame.DataFrame = <factory>) None
Methods
__init__(iamc_prefix, unit, var[, mapping])Assert that
mappinghas the correct structure and is complete.from_files(category)Create a Config instance from 1 or 2 YAML files.
use_aggregates_dict(data)Update
mappingfrom data.use_vars_dict(data)Update
mappingusing data.Attributes
Prefix or initial fragment of IAMC ‘variable’ name.
Units of measure for the reported data.
message_ix.reportkey from which to retrieve the data.Data frame with:
- classmethod from_files(category: str) Config[source]
Create a Config instance from 1 or 2 YAML files.
A file like
message_ix_models/data/material/reporting/category.yamlis read and used to populate a new instance. The file must have:Top-level keys corresponding to
iamc_prefix,unit, andvar.A top-level key
vars:containing a mapping compatible withuse_vars_dict().
If a file exists in the same directory named like
category_aggregates.yaml, it is also read, and its contents passed touse_aggregates_dict().
- mapping: DataFrame
Data frame with:
MultiIndex levels including 1 or more of \((c, l, m, t)\).
3 columns: - “iamc_name”: a (fragment of) an IAMC ‘variable’ name. This is appended to
to
iamc_prefixto construct a complete name.“short_name”: …
“unit”: units of measure.
This expresses a mapping between the index entries (=indices of reported data) and the information in the 3 columns.
- use_aggregates_dict(data: dict) None[source]
Update
mappingfrom data.This method handles data with structure equivalent to the following YAML content:
level_1: Chemicals|Liquids|Other: short: fe_pe_chem_oth components: [ fe_pe_hvc_oth ] Chemicals|Liquids|Biomass: short: fe_pe_chem_bio components: [ fe_pe_hvc_bio_eth ] # Any number of similar entries level_2: Heat: short: fe_pe_heat components: - fe_pe_cement_heat - fe_pe_aluminum_heat - fe_pe_steel_heat - fe_pe_other_heat # Any number of similar entries
In general:
Top-level keys may be “level_1”, “level_2”, etc. Additional top-level keys like “iamc_prefix”, “unit”, and “var” are checked against the corresponding attributes.
Second-level keys are fragments of IAMC ‘variable’ names
Third level keys must be:
“short”: A single string. See the description of the “short_name” column in
mapping. This is the aggregate to be produced.“components”: A list of strings. These are the components of the aggregation. Components referenced under “level_1” must already be present in
mapping. Components referenced under “level_2” may include the aggregates described by “level_1”, etc.
- use_vars_dict(data: dict) None[source]
Update
mappingusing data.This handles data with structure equivalent to the following YAML content:
Chemicals|High-Value Chemicals|Electricity|Steam Cracking: filter: commodity: electr level: final mode: [vacuum_gasoil, atm_gasoil, naphtha, ethane, propane] technology: steam_cracker_petro, short: fe_pe_hvc_el_sc unit: kg # Optional # Any number of similar entries
Within this:
Chemicals|High-Value Chemicals|Electricity|Steam Crackingis a (fragment of) an IAMC ‘variable’ name.filterentries may have values that are strings or lists of strings. The subkeys may include the MESSAGEix sets [technology, mode, commodity, level].
- var: Literal['out', 'in', 'ACT', 'emi', 'CAP']
message_ix.reportkey from which to retrieve the data.