Comments (6)
Original comment by Shubhankar Upasani (Bitbucket: Shubh1995, GitHub: Shubh1995).
I have the excel file that lists all the unlinked exchanges using
#!python
sp.write_excel(only_unlinked=True)
Can I perform a migration by reading from this excel file? Any suggestions how to?
from brightway2-io.
Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).
I assume you were linking to the US LCI notebook. As you read at the end: "For every unmatched exchange, there is a reason the computer couldn't match it exactly. The next step is to figure out the problem for each exchange, and then write a migration to fix the input data to match what is expected."
A migration is a set of structured data that changes attributes based on filters. For example, "carbon dioxide" could be changed into "carbon dioxide, fossil" if the associated activity was a combustion activity. You can see examples of migrations here and here.
To link the US LCI completely, you will need to write migrations to change the provided values into ones that can be matched exactly by other biosphere flows or activity names/units/whatever. In other words, you will have to find the existing values, find the "correct values", and write a migration from one to the other. The excel file can help, but you will also have to search for the "correct" values. The other importing notebooks have specific examples of how to build and use migrations.
Importing with missing biosphere flows just means you will miss out on some (potentially important) biosphere flows; importing with missing links in activities isn't possible unless you delete activities willy-nilly, which is almost certainly not what you want.
from brightway2-io.
Original comment by Shubhankar Upasani (Bitbucket: Shubh1995, GitHub: Shubh1995).
Hi Chris,
Thanks for replying. Finding the "correct values" seems too tedious. For each exchange, I need to find an associated process in ecoinvent?
Can I change my default biosphere3 (or biosphere4) to contain US LCI biosphere flows? Would that be possible and make things easier?
from brightway2-io.
Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).
It is tedious, that's why it hasn't been added to the default library so far. For each value which doesn't fit (could be activity name, but also unit, location, reference product), one needs to find the "correct" value.
You could use the biosphere flows from the US LCI, but then you wouldn't have any LCIA methods, and also would have the reverse problem linking e.g. ecoinvent activities to the US LCI biosphere flows.
So, there is no easy answer. This is the unfortunate state of LCA data exchange, and one of the reasons behind efforts like BONSAI.
from brightway2-io.
Original comment by Shubhankar Upasani (Bitbucket: Shubh1995, GitHub: Shubh1995).
Can you elaborate on how to apply
#!python
link_iterable_by_fields
after writing a migration? My question stands particularly for linking US LCI. I haven't imported ecoinvent 2.2 so I guess my code should be like
#!python
import functools
c = functools.partial(link_iterable_by_fields(unlinked = biosphere_flow_migration ,
other=Database(config.biosphere)),
kind='biosphere'
)
sp.apply_strategy(c)
where
#!python
biosphere_flow_migration
comes from the following migration definition
#!python
biosphere_flow_migration = Migration("US-LCI-biosphere").write(
biosphere_migration_data,
description="unlinked biosphere exchanges in US LCI "
)
The error looks like this
#!python
TypeError Traceback (most recent call last)
<ipython-input-93-e8a1bd027374> in <module>()
1 import functools
2 c = functools.partial(link_iterable_by_fields(unlinked = biosphere_flow_migration ,
----> 3 other=Database(config.biosphere)),
4 kind='biosphere'
5 )
~\AppData\Local\conda\conda\envs\tes\lib\site-packages\bw2io\strategies\generic.py in link_iterable_by_fields(unlinked, other, fields, kind, internal, relink)
61 "``database`` or ``code`` attributes")
62
---> 63 for container in unlinked:
64 for obj in filter(filter_func, container.get('exchanges', [])):
65 key = activity_hash(obj, fields)
TypeError: 'NoneType' object is not iterable
Any changes or suggestions? I don't think
#!python
sp.match_database
should work here.
from brightway2-io.
Original comment by Chris Mutel (Bitbucket: cmutel, GitHub: cmutel).
You should basically never be running link_iterable_by_fields
yourself - it is normally wrapped by another call. In this case, you can call importer_object.migrate('name of migration')
. See example, example.
from brightway2-io.
Related Issues (20)
- How to export database with location information of technosphere HOT 1
- [BW2 Legacy] Using older versions of Biosphere HOT 2
- database writing failed due to unlinked exchanges in ecoinvent 3.10 HOT 4
- Some extractor methods do not have the `use_mp` flag implemented, causing them to fail. HOT 1
- [BW2 legacy] Error with easy ecoinvent biosphere flows/LCI/LCIA import of bw2io version 0.8.11 HOT 3
- SimaPro CSV importer doesn't fix broken uncertainty values HOT 8
- US EEIO import is broken
- [Discussion/Feature request] Adding `database` field to Linking Iterables by field on import HOT 2
- Excel file import - AttributeError: 'int' object has no attribute 'lower' HOT 1
- Few type hints not compatible with python 3.9 & python 3.8 HOT 1
- Encoding erorr when running `import_ecoinvent_release` on `v3.10` HOT 3
- Backport fix for "chemical formulas" from 0.9.DEV7 to 0.8.X ? HOT 1
- AttributeError in add_missing_cfs(): 'ExcelLCIAImporter' object has no attribute 'biosphere_name' HOT 1
- Importing in BW processes written in SP HOT 2
- errors importing exiobase in monetary units HOT 1
- KeyError in IOTable backend HOT 3
- update README to use cookiecutterlib format
- Configurable multiprocessing for large data import (Ecoinvent ecospold2) HOT 2
- `ExcelImporter` should convert integer codes to strings HOT 5
- minor compatibility issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brightway2-io.