Are eco-indicator endpoints reported in points or millipoints - brightway

How do I check if impacts are reported in—for example using 'eco-indicator 99, (H,A)', 'ecosystem quality', 'total'—in milli-points or points.

Metadata is stored in methods, so you should be able to do the following:
In [1]: methods[('eco-indicator 99, (H,A)', 'total', 'total')]['unit']
Out[1]: 'points'
You can also see complete method metadata:
In [1]: methods[('eco-indicator 99, (H,A)', 'total', 'total')]
Out[1]:
{'abbreviation': 'eco-indicator-99-hatt.418ee316e1a7611c9135b9abe7b490e7',
'description': 'Implementation of the impact assessment method with the normalized and weighted damage factor. Weights (30% human health, 50% ecosystem quality, 20% resources) and normalization for Egalitarian perspective. Correction of factors for nickel and chromium emissions and nickel and zinc resource. Own assessment for new land use categories.',
'filename': 'LCIA implementation v3.1 2014_08_13.xlsx',
'num_cfs': 1285,
'unit': 'points'}

Related

AWARE method in ecoinvent through brightway2

i'm trying to extract all water inputs to several processes using brightway or ab, but i'm having troubles getting those values from the inventory_matrix. I need to get quantity of water consumed and origin of the water (surface, well, unspecified, tap water) along with its geography. mI'm using ecoinvent 3.7.1
One way i thought i could do that is create an impact assessment method with CFs for those compartments (each of those will be 1s), then apply it to the processes and analyse the elementary flows contributions.
I'm not sure though i can get the geography like this.
EDITED MOST OF THE QUESTION FOR CLARITY
Seems like i was trying to reinvent the wheel! My goal is to implement AWARE method and apply it to quite a few processes. the best result would be to use AWARE through activity-browser so i can use all of its functionalities which are very time-saving for me.
i just saw that there is brightway2-regional and bw2_aware that implement the aforementioned method.
So i'm now trying to install the packages in my brightway2 conda environment.
Managed to get bw2regional through conda but i cant manage to install bw2_aware if not through pip.
managed to install bw2_aware by using the wheel file and pip install --no-deps and then tweaking a line in the source code for fiona import, now i'm getting errors when running
bwr.bw2regionalsetup()
bw2_aware.import_aware()
SSLError: HTTPSConnectionPool(host='pandarus.brightwaylca.org', port=443): Max retries exceeded with url: / (Caused by SSLError(CertificateError("hostname 'pandarus.brightwaylca.org' doesn't match either of '*.parkingcrew.net', 'parkingcrew.net'",),))
Now i'm trying to understand if i can apply this to ecoinvent, and how. i'm really unsure if i can add the different geographies to the elementary flows in the database, so that i can correctly calculte aware in a lca.
I already saw that importing AWARE allows to choose it as a impact cathegory in activity-browser, though i cannot see the geographies in the CFS shown in the Charaterization Factors tab.
So i then tried to calculate an LCA with AB using AWARE method and 2 sample processes:
diesel, burned in agricultural machinery | diesel, burned in agricultural machinery | GLO | megajoule | ECOINVENT3.7.1
electricity, high voltage | market for electricity, high voltage | IT | kilowatt hour | ECOINVENT3.7.1
and i get this result (first is Agricultural, the other is non Agricultural):
diesel, burned in agricultural machinery | GLO
0.014757994762941706 0.00654978730728395
market for electricity, high voltage | IT 0.285207979534988 0.12657895834095712
I wonder if this is correct.
Your intuition is correct - constructing an LCIA method is an easy way to do this. This is because there are unspoken assumptions behind these flows - they will be mostly positive numbers, but some represent consumption, while others represent release.
Here is an example using Brightway 2.5, it would need to be adapted for version 2:
import bw2data as bd
import bw2calc as bc
import numpy as np
bd.projects.set_current("ecoinvent 3.7.1")
ecoinvent = bd.Database("ecoinvent 3.7.1")
beet = ecoinvent.search("beet")[1]
water_method = bd.Method(("Water", "raw"))
water_method.register()
water_method.write([(x, -1 if x['categories'][0] == 'natural resource' else 1)
for x in bd.Database("biosphere3")
if x['name'].startswith('Water')])
demand, data_objs, _ = bd.prepare_lca_inputs(demand={beet: 1}, method=("Water", "raw"))
lca = bc.LCA(demand=demand, data_objs=data_objs)
lca.lci()
lca.lcia()
coo = lca.characterized_inventory.tocoo()
results = sorted(zip(np.abs(coo.data), coo.data, coo.row, coo.col), reverse=True)
for a, b, c, d in results[:10]:
print("{:.6f}\t{}\n\t\t{}".format(
float(b),
bd.get_activity(lca.dicts.biosphere.reversed[c]),
bd.get_activity(lca.dicts.activity.reversed[d])
))
With the result:
0.009945 'Water' (cubic meter, None, ('water',))
'electricity production, hydro, run-of-river' (kilowatt hour, CH, None)
-0.009945 'Water, turbine use, unspecified natural origin' (cubic meter, None, ('natural resource', 'in water'))
'electricity production, hydro, run-of-river' (kilowatt hour, CH, None)
0.009514 'Water' (cubic meter, None, ('water',))
'electricity production, hydro, run-of-river' (kilowatt hour, RoW, None)
-0.009514 'Water, turbine use, unspecified natural origin' (cubic meter, None, ('natural resource', 'in water'))
'electricity production, hydro, run-of-river' (kilowatt hour, RoW, None)
0.007264 'Water' (cubic meter, None, ('water',))
'electricity production, hydro, run-of-river' (kilowatt hour, FR, None)
-0.007264 'Water, turbine use, unspecified natural origin' (cubic meter, None, ('natural resource', 'in water'))
'electricity production, hydro, run-of-river' (kilowatt hour, FR, None)
-0.003371 'Water, river' (cubic meter, None, ('natural resource', 'in water'))
'irrigation, sprinkler' (cubic meter, CH, None)
0.003069 'Water' (cubic meter, None, ('water', 'ground-'))
'sugar beet production' (kilogram, CH, None)
0.001935 'Water' (cubic meter, None, ('air',))
'sugar beet production' (kilogram, CH, None)
0.001440 'Water' (cubic meter, None, ('water',))
'electricity production, hydro, run-of-river' (kilowatt hour, CN-SC, None)
There isn't a way to use regionalized calculations in the activity browser, and the AWARE method (incorrectly) relies on an external web service which is not strictly necessary. So the short answer is that this isn't possible right now, but as you are the second person to ask about this in a week, we need to get it working ASAP.

how to add keys to list and convert to json in python

I have tried this for converting list of list to json. But Could not convert to proper json format.
My data is
data= [['India',
'India runs mentorship driven incubation.',
'/7e9e130075d3bfcd9e0.png'],
['Capital',
'develops high growth and market-defining India-centric Software and Services Big Data and Analytics and Consumer Mobile or Internet markets.',
'/data/images/512bc5a2937.png']]
titles = ['Country','description','logo']
values = [e for g in grouper(3, data) for e in g]
keys = (titles[i%3] for i in xrange(len(values)))
objs = [dict(g) for g in grouper(3, list(izip(keys, values)))]
print(objs)
result:
[{'Country': ['India', 'India runs mentorship driven incubation.', '/7e9e130075d3bfcd9e0.png'], 'description': ['Capital', 'develops high growth and market-defining India-centric Software and Services Big Data and Analytics and Consumer Mobile or Internet markets.', '/data/images/512bc5a2937.png']}]
But expected result should be in this form.
[{'Country': 'India', 'description': 'India runs mentorship driven incubation.', 'logo': '/7e9e130075d3bfcd9e0.png'}]
What should be reason ?
You can use a one-line list comprehension. First, iterate through data, an for each piece of data (entry), zip it with titles to create an iterable of tuples that can be converted into a dictionary:
data= [['India',
'India runs mentorship driven incubation.',
'/7e9e130075d3bfcd9e0.png'],
['Capital',
'develops high growth and market-defining India-centric Software and Services Big Data and Analytics and Consumer Mobile or Internet markets.',
'/data/images/512bc5a2937.png']]
titles = ['Country','description','logo']
result = [dict(zip(titles, entry)) for entry in data]
print(result)
Output:
[{'Country': 'India',
'description': 'India runs mentorship driven incubation.',
'logo': '/7e9e130075d3bfcd9e0.png'},
{'Country': 'Capital',
'description': 'develops high growth and market-defining India-centric Software and Services Big Data and Analytics and Consumer Mobile or Internet markets.',
'logo': '/data/images/512bc5a2937.png'}]

how to use the transverse_tagged_databases function in brightway2

I would like to know how to use the transverse_tagged_database method in brightway2. From the documentation is not entirely clear to me. Can we use for, example, to aggregate impacts by the isic code of the activities in the product system model?
The short answer is yes, aggregating impacts by ISIC code in your foreground product system model is exactly the kind of thing you can do using traverse_tagged_databases.
The traverse_tagged_databases function takes advantage of the fact that you can add arbitrary key:value pairs to activities in brightway to let you classify your the activities in your foreground model however you like.
For example, say your activities look like this:
('example_database', 'code_for_bread'):{
'name': 'Bread',
'code': 'code_for_bread',
'categories':[],
'exchanges':[...],
'location':'GLO'
'unit':'kg',
'database':'example_database',
'isic_code':'1071'
'isic_classifier':'Manufacture of bakery products'
},
You can tell traverse_tagged_databases to go through your database looking for a given key (tag), for example 'isic_code', or 'isic_classifier' and aggregate the impact based on these tags.
Say you were modelling a cheese sandwich, you could have the following ISIC codes in your model:
Sandwich: 1079 (Manufacture of other food products n.e.c.)
Bread: 1071 (Manufacture of bakery products)
Cheese: 1050 (Manufacture of dairy products)
Butter: 1050 (Manufacture of dairy products)
You can use traverse_tagged_databases to see the total impact of dairy (cheese and butter) vs bakery (bread).
You use it in a similar way to the LCA function, by specifying a functional unit as a dict and the method as a tuple, with an additional tag argument. Like this:
fu = {('example_database', 'code_for_sandwich'):1}
m = ('IPCC 2013', 'climate change', 'GWP 100a')
result, tree = traverse_tagged_databases(fu, m, 'isic_classifier')
The function returns two objects (designated result and tree in the line above)
For this analysis, your result will look something like this:
defaultdict(int,
{'Manufacture of other food products n.e.c.': 0,
'Manufacture of bakery products': 0.1875,
'Manufacture of dairy products': 0.55})
This is saying that dairy products in the foreground model have an aggregated impact of 0.55 kg CO2-eq, and bakery products have an aggregated impact of 0.1875 kg CO2-eq.
With a bit of post-processing you can turn this data into pie charts, stacked bar charts etc.
You also get a tree, which looks like this:
[{'activity': 'Sandwich' (kg, GLO, []),
'amount': 1,
'tag': 'Manufacture of other food products n.e.c.',
'impact': 0,
'biosphere': [],
'technosphere': [{'activity': 'Bread' (kg, GLO, []),
'amount': 0.75,
'tag': 'Manufacture of bakery products',
'impact': 0,
'biosphere': [{'amount': 0.1875,
'impact': 0.1875,
'tag': 'Manufacture of bakery products'}],
'technosphere': []},
{'activity': 'Butter' (kg, GLO, []),
'amount': 0.05,
'tag': 'Manufacture of dairy products',
'impact': 0,
'biosphere': [{'amount': 0.05,
'impact': 0.05,
'tag': 'Manufacture of dairy products'}],
'technosphere': []},
{'activity': 'Cheese' (kg, GLO, []),
'amount': 0.25,
'tag': 'Manufacture of dairy products',
'impact': 0,
'biosphere': [{'amount': 0.5,
'impact': 0.5,
'tag': 'Manufacture of dairy products'}],
'technosphere': []}]}]
This can look a bit difficult to parse at first, but is essentially a set of nested dictionaries, starting with the root activity (the functional unit = Sandwich), showing techosphere exchanges to other activities, and biosphere exchanges to emissions.
The tree here looks like this (with the amounts of each product in brackets)
Bread +----(0.75 kg)----------+
|
|
|
|
Cheese +----(0.20 kg)----------+------(1.00 kg)--------> Sandwich
|
|
|
|
Butter +----(0.05 kg)----------+
Again, with a bit of post-processing, you can turn this data into stuff like sankey diagrams, or the kind of impact tree diagram you get in SimaPro.

Rasa NLU: How to use multiple categorical slots with same values?

I just started working with Rasa NLU and I have some problem understanding the usage of categorical slots with same values. I have 3 different types of risk, each a categorical slot with values: low, medium and high.
How can the bot differentiate between the three risks and understand which slot to be filled up, given the intent is same for each.
Or do I need to use different intents for each?
Right now what I see is (I removed unrelated logs):
How tired are you?
1: low (low)
2: medium (medium)
3: high (high)
medium
DEBUG:rasa_core.processor:Received user message 'medium' with intent '{'name': 'inform', 'confidence': 0.88372623999657118}' and entities '[{'start': 0, 'end': 6, 'value': 'medium', 'entity': 'fatigue', 'extractor': 'ner_crf'}]'
DEBUG:rasa_core.processor:Current slot values:
fatigue: medium
injury: None
stress: None
How stressed are you?
1: low (low)
2: medium (medium)
3: high (high)
low
DEBUG:rasa_core.processor:Received user message 'low' with intent '{'name': 'inform', 'confidence': 0.88762049990079372}' and entities '[{'start': 0, 'end': 3, 'value': 'low', 'entity': 'fatigue', 'extractor': 'ner_crf'}]'
DEBUG:rasa_core.processor:Current slot values:
fatigue: low
injury: None
stress: None
All the user replies have the intent inform.
An example story is:
* _greet[]
- utter_ask_fatigue
* _inform[fatigue=low]
- utter_ask_injury
* _inform[injury=medium]
- utter_ask_stress
* _inform[stress=low]
- utter_on_it
- action_reply
you can do it with one entity and four slots
the entity may be defined as type "info", with text values (i.e. low, medium, high).
The four slots: the first one is "info", which will auto filled by recognized entity "info" defined previously. The other three would be "fatigue", "stress" and "injury", which can be filled by bot actions such as action_fill_fatigue, action_fill_stress and action_fill_injury.
an example story will make it clear:
* _greet[]
- utter_ask_fatigue
* _inform[info=low]
- action_fill_fatigue
- utter_ask_injury
* _inform[info=medium]
- action_fill_injury
- utter_ask_stress
* _inform[info=low]
- action_fill_stress
- utter_on_it
- action_reply

JAGS Beginner - Receiving and Understanding Output

When using JAGS, how does one receive output from a model in the format:
Inference for Bugs model at "model.txt", fit using jags,
3 chains, each with 10000 iterations (first 5000 discarded)
n.sims = 15000 iterations saved
mu.vect sd.vect 2.5% 25% 50% 75% 97.5% Rhat n.eff
mu 9.950 0.288 9.390 9.755 9.951 10.146 10.505 1.001 11000
sd.obs 3.545 0.228 3.170 3.401 3.534 3.675 3.978 1.001 13000
deviance 820.611 3.460 818.595 819.132 819.961 821.366 825.871 1.001 15000
I assumed, as with BUGS, it would appear when the model completes however I only get something in the format:
Compiling model graph
Resolving undeclared variables
Allocating nodes
Graph information:
Observed stochastic nodes: 1785
Unobserved stochastic nodes: 1843
Total graph size: 61542
Initializing model
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100%
Apologies for the basic question. If anyone can provide useful JAGS introductory material that would also be useful.
Kind regards.
If you only get the 'plus' signs, it means you only initialized the model. When jags really runs, it typically produces '***' signs after. So you are missing a line here (would have been nice to see your code). For instance if you use r2jags, you would write:
out <- jags(data = data, parameters.to.save = params, n.chains = 3, n.iter = 90000,n.burnin = 5000,
model.file = modFile)
out.upd <- update(abundance.out.mod, n.iter=10000)

Resources