brightway


Connecting exchange names and codes to LCA inventory results


I'm getting into Brightway2 for some energy system modeling and I'm still getting used to the all of the concepts.
I've created a small custom demo database, and run lca.lci() and lca.lcia(). lca.inventory and lca.characterized_inventory both return sparse matrices of the results. My question, which may be very simple, is how can you connect the values in the matrix to the exchange names and keys. I.e., if I wanted to print the results to a file, how would I match the exchanges to the inventory values?
Thanks.
To really understand what is going on, it is useful to understand the difference between "intermediate" data (stored as structured text files) and "processed" data (stored as numpy structured arrays). These concepts are described both here and here.
However, to answer your question directly: what each row and column stand for in the different matrices and arrays (e.g. lca.inventory matrix, lca.supply_array, lca.characterized_inventory) are contained in a set of dictionaries that are associated with your LCA object. These are:
activity_dict: Columns in the technosphere matrix
product_dict : Rows in the technosphere matrix
biosphere_dict: Rows in the biosphere matrix
For example, lca.product_dict yields, in the case of an LCA I just did:
{('ei32_CU_U', '671c1ae85db847083176b9492f000a9d'): 8397,
('ei32_CU_U', '53398faeaf96420408204e309262b8c5'): 536,
('ei32_CU_U', 'fb8599da19dabad6929af8c3a3c3bad6'): 7774,
('ei32_CU_U', '28b3475e12e4ed0ec511cbef4dc97412'): 3051, ...}
with the key in the dictionary being the actual product in my inventory database and the value is the row in the demand_array or the supply_array.
More useful may be the reverse of these dictionaries. Let's say you want to know what a value in e.g. your supply_array refers to, you can create a reverse dictionary using a dict comprehension :
inv_product_dict = {v: k for k, v in lca.product_dict.items()}
and then simply use it directly to obtain the information you are after. Say you want to know what is in the 10th row of the supply_array, you can simply do inv_product_dict[10], which in my case yields ('ei32_CU_U', '4110733917e1fcdc7c55af3b3f068c72')
The same types of logic applies with biosphere (or elementary) flows, found in the lca.biosphere_dict (in LCA parlance, rows in the B matrix), and activities, found in the lca.activity_dict (columns of the A or B matrices).
Note that you can generate the reverse of the activity_dict/product_dict/biosphere_dict simultaneously using lca.reverse_dict(). The syntax then is:
rev_act_dict, rev_product_dict, rev_bio_dict = lca.reverse_dict()

Related Links

How to make exact search in Database
Find all processes emitting a certain biosphere flow in LCA
Get method tuple from abbreviation in Brightway2
Connecting exchange names and codes to LCA inventory results
copy projects between different computers
importing ecoinvent 3.2 with brightway
Brightway2: Modifying/deleting exchanges from activity without using activity as dict
Backups in Brightway: how to use them
Saving multiple activities to database in a loop in Brightway
Obtaining distribution of results from LCIA
Simapro dataset to ecoinvent migration fails in brightway2
What is the best practice when importing 2 simapro datasets in brightway2 to merge them together
How to manually link in Brightway2 an imported exchange, given I have found the correct one in ecoinvent
Can't write copy of activity in newly created databases
Are eco-indicator endpoints reported in points or millipoints
Multi and Parallel Monte Carlo fail with key error (on database name)

Categories

HOME
oauth-2.0
airflow
kendo-ui-angular2
grizzly
teradata
ftp
openacc
cxf
ldap
postsharp
gaussian
squeak
coordinates
rmarkdown
clip-path
android-webview
jpql
distinct
email-attachments
browsermob
cakephp-2.0
javascript-debugger
opendaylight
exchange-transport-agents
ofbiz
conditional-formatting
udeploy
android-wifi
git-branch
datazen-server
ejb-3.1
typedef
infinite-loop
devexpress-mvc
inspec
azure-table-storage
schedule
directions
webmock
apache-falcon
http-proxy
ragel
gstreamer-1.0
client-server
mybatis-generator
mediastream
electron-packager
vpython
colorbox
inner-join
qtwebkit
jenkins-2
google-chrome-storage
rivets.js
monaca
robotc
suitesparse
sqlxml
skbio
gtkwave
libgcrypt
jts
log4cxx
pushwoosh
consul-template
vspackage
stderr
information-hiding
mvcgrid
enquire.js
rssi
fastcgi-mono-server
starling-framework
xcode6.1-gm-seed
caroufredsel
oc4j
uikit-dynamics
pudb
volatility
cryptarithmetic-puzzle
orchestration
m3u
event-propagation
nsscrollview
sqlbuddy
yii-cactiverecord
rollover
uccapi
projectgen
paperless

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App