ixmp

Package documentation

genno.compat.ixmp.configure(path=None, **config)

Configure genno globally.

Modifies global variables that affect the behaviour of all Reporters and computations, namely RENAME_DIMS.

Valid configuration keys—passed as config keyword arguments—include:

Other Parameters

rename_dims (mapping of str -> str) – Update RENAME_DIMS.

Warns

UserWarning – If config contains unrecognized keys.

genno.compat.ixmp.computations.data_for_quantity(ix_type, name, column, scenario, config)

Retrieve data from scenario.

Parameters
  • ix_type ('equ' or 'par' or 'var') – Type of the ixmp object.

  • name (str) – Name of the ixmp object.

  • column ('mrg' or 'lvl' or 'value') – Data to retrieve. ‘mrg’ and ‘lvl’ are valid only for ix_type='equ',and ‘level’ otherwise.

  • scenario (ixmp.Scenario) – Scenario containing data to be retrieved.

  • config (dict of (str -> dict)) – The key ‘filters’ may contain a mapping from dimensions to iterables of allowed values along each dimension. The key ‘units’/’apply’ may contain units to apply to the quantity; any such units overwrite existing units, without conversion.

Returns

Data for name.

Return type

Quantity

genno.compat.ixmp.computations.map_as_qty(set_df: pandas.core.frame.DataFrame, full_set)

Convert set_df to a Quantity.

For the MESSAGE sets named cat_* (see Category types and mappings) ixmp.Scenario.set() returns a DataFrame with two columns: the category set (S1) elements and the category member set (S2, also required as the argument full_set) elements.

map_as_qty converts such a DataFrame (set_df) into a Quantity with two dimensions. At the coordinates (s₁, s₂), the value is 1 if s₂ is mapped from s₁; otherwise 0.

A category named ‘all’, containing all elements of full_set, is added automatically.

See also

broadcast_map

class genno.compat.ixmp.reporter.Reporter(**kwargs)

Class for describing and executing computations.

configure(path=None, **config)

Configure the Reporter.

Calls set_filters() for a “filters” keyword argument.

finalize(scenario)

Prepare the Reporter to act on scenario.

The Scenario object scenario is associated with the key 'scenario'. All subsequent processing will act on data from this scenario.

classmethod from_scenario(scenario, **kwargs)

Create a Reporter by introspecting scenario.

Parameters
  • scenario (ixmp.Scenario) – Scenario to introspect in creating the Reporter.

  • kwargs (optional) – Passed to Scenario.configure().

Returns

A Reporter instance containing:

  • A ‘scenario’ key referring to the scenario object.

  • Each parameter, equation, and variable in the scenario.

  • All possible aggregations across different sets of dimensions.

  • Each set in the scenario.

Return type

Reporter

set_filters(**filters)

Apply filters ex ante (before computations occur).

Filters are stored in the reporter at the 'filters' key, and are passed to ixmp.Scenario.par() and similar methods. All quantity values read from the Scenario are filtered before any other computations take place.

If no arguments are provided, all filters are cleared.

Parameters

filters (mapping of str → (list of str or None)) – Argument names are dimension names; values are lists of allowable labels along the respective dimension, or None to clear any existing filters for the dimension.

genno.compat.ixmp.reporter.keys_for_quantity(ix_type, name, scenario)

Return keys for name in scenario.

genno.compat.ixmp.util.RENAME_DIMS: Dict[str, str] = {}

Dimensions to rename when extracting raw data from Scenario objects. Mapping from Scenario dimension name -> preferred dimension name.

genno.compat.ixmp.util.dims_for_qty(data)

Return the list of dimensions for data.

If data is a pandas.DataFrame, its columns are processed; otherwise it must be a list.

genno.RENAME_DIMS is used to rename dimensions.