bw2data.backends.json
#
Submodules#
Package Contents#
Classes#
A MutableMapping is a generic container for associating |
|
Simple proxy for an exchange between activity datasets. Makes manipulation and use in command line more convenient. |
|
A data store for LCI databases. Stores each dataset in a separate file, serialized to JSON. |
- class bw2data.backends.json.Activity(key, data={})[source]#
Bases:
bw2data.proxies.ActivityProxyBase
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__.
- biosphere(raw=False)#
- exchanges(raw=False)#
- save()#
- technosphere(raw=False)#
- upstream(*args, **kwargs)#
- class bw2data.backends.json.Exchange(data, *args, **kwargs)#
Bases:
bw2data.proxies.ExchangeProxyBase
Simple proxy for an exchange between activity datasets. Makes manipulation and use in command line more convenient.
Warning
This proxy is read only! To save changes to a dataset, you will need to work with the raw database data.
Usually these proxies are created by the activity, but you can instantiate one with the dictionary of exchange data and an Activity proxy of the consuming activity:
exchange = Exchange({"my exchange data": "goes here"})
Properties:
input
: Returns activityoutput
: Returns activityamount
uncertainty
: Returns dictionary of uncertainty datauncertainty_type
: Returnsstats_arrays
uncertainty typeunit
- save()#
- class bw2data.backends.json.JSONDatabase(name)[source]#
Bases:
bw2data.backends.base.LCIBackend
A data store for LCI databases. Stores each dataset in a separate file, serialized to JSON.
Instead of loading all the data at once,
.load()
creates aSynchronousJSONDict
, which loads values on demand.Use this backend by setting
"backend":"json"
in the database metadata. This is done automatically if you call.register()
from this class.- backend = 'json'#
- filepath_intermediate()#
- get(code)#
Get Activity proxy for this dataset
- load(as_dict=False, *args, **kwargs)#
Instantiate
SynchronousJSONDict
for this database.
- register(**kwargs)#
Register a database with the metadata store, using the correct value for
backend
, and creates database directory.
- write(data, process=True)#
Serialize data to disk. Most of the time, this data has already been saved to disk, so this is a no-op. The only exception is if
data
is a new database dictionary.Normalizes units when found.
- Parameters
data (*) – Inventory data