Comments (3)
copying different pieces of the MultiLCA code together
This feels like an anti-pattern to me - it would be much better to import the library and subclass the elements that you need to change instead. I have seen people do this in the past, including myself, and it has always led to regrets.
use_distributions (as it is in the github repo, tho it's not in the pypi version yet)
It's on pypi, just use pip --pre
.
allow to split the inventory matrix by columns and calculating the lcia (multiplication with cc_matrix) separately
You can do this now, e.g. lca.characterization_matrix @ lca.inventory[:, some_column]
.
allow arbitrary python function instead of constants for characterization
Sure, but then don't pass an LCIA method, just run your function on lca.inventory
.
I noticed that when I would calculate the hashes of the individual characterization matrices
I don't think I got this 100%, but there are a few things to be aware of:
- The characterization matrix is not every value provided by the impact category - we only put in factors for biosphere flows which are used by the inventory. It's entirely possible for many defined characterization factors to not show up in the matrix.
- The order of insertion into the characterization|biosphere|technosphere matrix is deterministic for a given project but not consistent across functional units (as they bring in different background databases). Never assume anything about indices, use
lca.dicts
to translate to and from database ids.
from brightway2-calc.
copying different pieces of the MultiLCA code together
This feels like an anti-pattern to me - it would be much better to import the library and subclass the elements that you need to change instead. I have seen people do this in the past, including myself, and it has always led to regrets.
I agree, in the version I was using, everything was happening in the MultiLCA constructor, so seemed a good approach to dissect the parts of it and move it into individual functions.
use_distributions (as it is in the github repo, tho it's not in the pypi version yet)
It's on pypi, just use
pip --pre
.
I will totally try this and refactor my code around that. However for a simple case it crashes at
m_lca = MultiLCA({'test': {24840: 1, 24438: 1}}, {'impact_categories': [
('ReCiPe 2016 v1.03, midpoint (E)', 'acidification: terrestrial', 'terrestrial acidification potential (TAP)')]}
, [])
m_lca.lci()
site-packages/matrix_utils/utils.py", line 43, in safe_concatenate_indices
raise AllArraysEmpty
matrix_utils.errors.AllArraysEmpty
And I strongly assume, that it's because I am passing an empty array as data_objs
variable to the MultiLCA constructor.
I am not sure what to provide otherwise in a simple scenario.
allow to split the inventory matrix by columns and calculating the lcia (multiplication with cc_matrix) separately
You can do this now, e.g.
lca.characterization_matrix @ lca.inventory[:, some_column]
.
I will have a look, thanks!
allow arbitrary python function instead of constants for characterization
Sure, but then don't pass an LCIA method, just run your function on
lca.inventory
.
I would actually run it on inventory.sum(1), in my tests that worked, and I assume it's faster, since the functions are only called just once per row/(biosphere flow?) instead of for each biosphere * technosphere
I noticed that when I would calculate the hashes of the individual characterization matrices
I don't think I got this 100%, but there are a few things to be aware of:
* The characterization matrix is _not_ every value provided by the impact category - we only put in factors for biosphere flows which are _used by the inventory_. It's entirely possible for many defined characterization factors to not show up in the matrix.
That is interesting! :) makes a lot of sense, but I did not see that in the code.
* The order of insertion into the characterization|biosphere|technosphere matrix is deterministic for a given project but not consistent across functional units (as they bring in different background databases). Never assume anything about indices, use `lca.dicts` to translate to and from database ids.
Yes that is what I generally do, and I did it in a more rigidusros test, than the one above.
from brightway2-calc.
from brightway2-calc.
Related Issues (20)
- Poor error message when no LCIA data is supplied
- Missing ability to create RNGs for Monte Carlo in Brightway 2.5? HOT 3
- Fail to install activity browser (Windows x64) HOT 1
- Install brightway error HOT 1
- Use the expected value to parametrize lognormal distributions HOT 2
- Prevent multiple ``remap_inventory_dicts``
- Allow for selective use of distributions or arrays depending on matrix label
- `MappedMatrixDict` should support `__mul__` HOT 1
- Dependency Dashboard
- MultiLCA: Check that `method_config` resources are present in data objects
- MultiLCA: Filter data objects to those referred to in `method_config`
- Add tests for `scikit-umfpack` and `sparselu` solvers HOT 5
- Prepare for switch to sparse arrays
- MultiLCA checklist
- Document/Clarify Removal of GraphTraversal Functionality HOT 6
- Factorizing matrices with pypardiso is not a no-op
- Empty characterization matrix arrays for MultiLCA HOT 7
- Proposal: Allow user to calculate non-diagonalized results
- Proposal: Cache Impact Assessment items
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-calc.