bw2data.backends.iotable.proxies#

Classes#

IOTableActivity

A MutableMapping is a generic container for associating

IOTableExchanges

Iterable of ReadOnlyExchange objects drawn from Datapackage arrays.

ReadOnlyExchange

Non-mutable dictionary which mimics bw2data.proxies.Exchange, but is read-only and doesn't link to a SQLite database row.

Module Contents#

class bw2data.backends.iotable.proxies.IOTableActivity(document=None, **kwargs)[source]#

Bases: bw2data.backends.proxies.Activity

A MutableMapping is a generic container for associating key/value pairs.

This class provides concrete generic implementations of all methods except for __getitem__, __setitem__, __delitem__, __iter__, and __len__.

Create an Activity proxy object.

If this is a new activity, can pass kwargs.

If the activity exists in the database, document should be an ActivityDataset.

_get_correct_db_backend()[source]#
biosphere()[source]#
abstract delete() None[source]#
exchanges()[source]#
production()[source]#
rp_exchange()[source]#

Return an Exchange object corresponding to the reference production. Uses the following in order:

  • The production exchange, if only one is present

  • The production exchange with the same name as the activity reference product.

Raises ValueError if no suitable exchange is found.

substitution()[source]#
technosphere() IOTableExchanges[source]#
class bw2data.backends.iotable.proxies.IOTableExchanges(datapackage: bw_processing.Datapackage, target: bw2data.backends.proxies.Activity | None = None, biosphere: bool = True, technosphere: bool = True, production: bool = True)[source]#

Bases: collections.abc.Iterable

Iterable of ReadOnlyExchange objects drawn from Datapackage arrays.

In the technosphere matrix, all positive exchanges are considered production, and all negative exchanges are technosphere, i.e. consumption, and we use this convention to label the edges. However, to be consistent with SQLite database results, we don’t flip signs in the returned dataframe.

The order of returned edges are production, technosphere, biosphere.

This function will draw from all resources with the correct matrix types (i.e. 'biosphere_matrix', 'technosphere_matrix'). Normally each IO Table database is stored in only one datapackage, and each datapackage only has one such database.

  • datapackage: The datapackage object.

  • target: Limit exchanges to those with the column index target. Target must be an instance of IOTableActivity.

  • biosphere, technosphere, production: Return these types of edges.

_add_arrays_to_resources(resources, datapackage)[source]#
_group_and_filter_resources(datapackage)[source]#
_mask_resource_arrays(resource, mask)[source]#
_raw_biosphere_iterator()[source]#
_raw_technosphere_iterator(negative=True)[source]#
_reduce_arrays_to_selected_types(resources, technosphere, production, biosphere)[source]#
biosphere[source]#
datapackage[source]#
production[source]#
resources[source]#
technosphere[source]#
to_dataframe[source]#
class bw2data.backends.iotable.proxies.ReadOnlyExchange(**kwargs)[source]#

Bases: collections.abc.Mapping

Non-mutable dictionary which mimics bw2data.proxies.Exchange, but is read-only and doesn’t link to a SQLite database row.

valid(dct: dict = None) None[source]#
_data[source]#
amount[source]#
as_dict[source]#
input[source]#
input_id[source]#
lca[source]#
output[source]#
output_id[source]#
unit[source]#