Compatibility with other packages

ixmp

Package documentation

class genno.compat.ixmp.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.keys_for_quantity(ix_type, name, scenario)

Return keys for name in scenario.

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

pyam

Package documentation

genno.compat.pyam.computations.as_pyam(scenario, quantity, replace={}, year_time_dim=None, rename={}, collapse: Optional[Callable] = None, drop: Union[Collection[str], str] = 'auto', unit=None)

Return a pyam.IamDataFrame containing quantity.

Warnings are logged if the arguments result in additional, unhandled columns in the resulting data frame that are not part of the IAMC spec.

Raises

ValueError – If the resulting data frame has duplicate values in the standard IAMC index columns. pyam.IamDataFrame cannot handle this data.

genno.compat.pyam.computations.concat(*args, **kwargs)

Concatenate args, which must all be pyam.IamDataFrame.

genno.compat.pyam.computations.write_report(quantity, path)

Write the report identified by key to the file at path.

If quantity is a pyam.IamDataFrame and path ends with ‘.csv’ or ‘.xlsx’, use pyam methods to write the file to CSV or Excel format, respectively. Otherwise, equivalent to genno.computations.write_report().