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

Order of tech_array and bio_array
create a new activity in Brightway2 based on an existing ecoinvent activity
find a product that causes a non-square technosphere matrix with Brightway2
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

Categories

HOME
kendo-ui
wifi
spss
where
assign
google-docs-api
localhost
mediarecorder
powerquery
uml-designer
pip
ejb-3.0
fetch
github-flavored-markdown
sha1
web-testing
simd
draw2d
datasource
sasl
jopendocument
libxml2
large-files
angular-schema-form
hierarchy
andengine
jmsserializerbundle
slim-lang
qt-designer
microstrategy
imageprocessor
apache-falcon
azure-vm-scale-set
form-fields
area
stdin
cowboy
idea-plugin
bzip2
amazon-rds-aurora
jks
perldoc
selection-sort
critical-section
reloaddata
msiexec
firebase-job-dispatcher
glade
x12
xcode7.1
altova
jigsaw
razorengine
pebble-js
video-embedding
firefox-os
google-app-engine-php
github-for-mac
pushwoosh
openhab
euro
page-refresh
esb-toolkit-2.1
cordova-3
report-builder2.0
react-os
dirname
redmine-plugins
cs193p
banana-pi
xcode6.1-gm-seed
ironworker
violation
qgraphicsscene
dd4t
select2-rails
codeigniter-form-helper
moonscript
quit
doxia
flatten
unordered-set
code-organization
html5-animation
fxcopcmd
xcdatamodel
xslt-grouping
code-golf
large-data-volumes
scala-designer
unauthorized
asp.net-1.1

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