bw2data.ia_data_store#

Classes#

ImpactAssessmentDataStore

A subclass of DataStore for impact assessment methods.

Functions#

abbreviate(names[, length])

Take a tuple or list, and construct a string, doing the following:

Module Contents#

class bw2data.ia_data_store.ImpactAssessmentDataStore[source]#

Bases: bw2data.data_store.ProcessedDataStore

A subclass of DataStore for impact assessment methods.

IA objects are hierarchically structured, and their identifier uses this structure, like ('ecological scarcity 2006', 'total', 'natural resources'). The identifier must be a tuple, i.e. (), not a list, i.e. []. The identifier should only contain unicode strings, and can be of any length >= 1.

Because impact assessment methods are identified by a tuple of strings, e.g. ('ReCiPe Endpoint (E,A)', 'human health', 'ionising radiation'), we need to transform this identifier before it can be used e.g. as a filename. We do this using the abbreviate() function, which returns a single unicode string.

Parameters:

name (-) – Name of the IA object to manage. Must be a tuple of unicode strings.

copy(name=None)[source]#

Make a copy of the method, including its CFs and metadata.

If name is not provided, add “Copy of” to the last element of the original name, e.g. ("foo", "bar") becomes ("foo", "Copy of bar")

Parameters:

name (-) – Name of the new method.

Returns:

The new object.

get_abbreviation()[source]#

Retrieve the abbreviation of the method identifier from the metadata store. See class documentation.

process(**extra_metadata)[source]#

Processes the impact assessment method and updates the metadata, including the identifier.

Parameters:

extra_metadata – Additional metadata to be included during processing.

Notes

The method updates the metadata with the list form of the method’s identifier.

register(**kwargs)[source]#

Register an object with the metadata store.

The metadata key abbreviation is set automatically.

Objects must be registered before data can be written. If this object is not yet registered in the metadata store, a warning is written to stdout.

Takes any number of keyword arguments.

property filename[source]#
Returns the abbreviated identifier of the method, used as the filename.
Returns:

The abbreviated identifier of the method.

Return type:

str

bw2data.ia_data_store.abbreviate(names, length=8)[source]#

Take a tuple or list, and construct a string, doing the following:

First, apply filesystem.safe_filename() to each element in names.

Next, take the following, in order:
  • The first word of the first element in names, lower-cased, where word is defined as everything up to the first empty space character.

  • Join the rest of the first element (i.e. after the first word) with all other elements. Use the empty space character to join.

  • In this long string separated by spaces, take the lowercase first character of each word. Add the first word to this new string.

  • Finally, add a dash, and then the MD5 hash of the entire identifier, where each element is joined by a dash character.

('ReCiPe Endpoint (E,A)', 'human health', 'ionising radiation') becomes 'recipee(hhir-70eeef20a20deb6347ad428e3f6c5f3c'.

The MD5 hash is needed because taking the first characters doesn’t guarantee unique strings.