bw2data.data_store#

Classes#

DataStore

Base class for all Brightway2 data stores. Subclasses should define:

ProcessedDataStore

Brightway2 data stores that can be processed to NumPy arrays.

Module Contents#

class bw2data.data_store.DataStore(name)[source]#

Base class for all Brightway2 data stores. Subclasses should define:

  • metadata: A serialized-dict instance, e.g. databases or methods. The custom is that each type of data store has a new metadata store, so the data store Foo would have a metadata store foos.

  • validator: A data validator. Optional. See bw2data.validate.

_get_metadata()[source]#
_set_metadata(value)[source]#
backup()[source]#

Save a backup to backups folder.

Returns:

File path of backup.

copy(name)[source]#

Make a copy of this object with a new name.

This method only changes the name, but not any of the data or metadata.

Parameters:

name (*) โ€“ Name of the new object.

Returns:

The new object.

deregister()[source]#

Remove an object from the metadata store. Does not delete any files.

load()[source]#

Load the intermediate data for this object.

Returns:

The intermediate data.

register(**kwargs)[source]#

Register an object with the metadata store. Takes any number of keyword arguments.

validate(data)[source]#

Validate data. Must be called manually.

write(data)[source]#

Serialize intermediate data to disk.

Parameters:

data (*) โ€“ The data

_intermediate_dir = 'intermediate'[source]#
_metadata = None[source]#
property filename[source]#

Remove filesystem-unsafe characters and perform unicode normalization on self.name using filesystem.safe_filename().

metadata[source]#
name[source]#
property registered[source]#
validator = None[source]#
class bw2data.data_store.ProcessedDataStore(name)[source]#

Bases: DataStore

Brightway2 data stores that can be processed to NumPy arrays.

In addition to metadata and (optionally) validator, subclasses should override add_geomappings. This method takes the entire dataset, and loads objects to geomapping as needed.

add_geomappings(data)[source]#

Add objects to geomapping, if necessary.

Parameters:

data (*) โ€“ The data

datapackage()[source]#
abstract delete(keep_params: bool = False, warn: bool = True, vacuum: bool = True, signal: bool = True)[source]#
dirpath_processed()[source]#
filename_processed()[source]#
filepath_processed()[source]#
abstract make_searchable(reset: bool = False, signal: bool = True) bool[source]#
abstract make_unsearchable(signal: bool = False) bool[source]#
process(**extra_metadata)[source]#

Process intermediate data from a Python dictionary to a stats_arrays array, which is a NumPy Structured Array. A structured array (also called record array) is a heterogeneous array, where each column has a different label and data type.

Processed arrays are saved in the processed directory.

If the uncertainty type is no uncertainty, undefined, or not specified, then the โ€˜amountโ€™ value is used for โ€˜locโ€™ as well. This is needed for the random number generator.

Doesnโ€™t return anything, but writes a file to disk.

abstract process_row(row)[source]#

Translate data into a dictionary suitable for array inputs.

See bw_processing documentation.

validate(data)[source]#

Validate data. Must be called manually.

write(data, process=True)[source]#

Serialize intermediate data to disk.

Parameters:

data (*) โ€“ The data

matrix = 'unknown'[source]#