Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Unkown params from ecoinvent inventories #60

Closed
RomainBes opened this issue Sep 9, 2024 · 2 comments
Closed

Issue with Unkown params from ecoinvent inventories #60

RomainBes opened this issue Sep 9, 2024 · 2 comments

Comments

@RomainBes
Copy link

I was working on the update of some previously working parameterized lca model, but using the ecoinvent 3.10 database and a newer version of lca_algebraic, I have some issues.

When I select an ecoinvent activity, and copy it to later modify it, I cannot compute its impacts.

act = agb.findActivity(  'uranium production, centrifuge, enriched 3.8%'  ,
    db_name=eidb.name, loc=     'DE'
) 
act2 = agb.copyActivity(activity = act,
                    code = act['name'] + ' adjusted',
                    db_name = USER_DB)
agb.compute_impacts(act2, impacts)

Exception Traceback (most recent call last)
Cell In[68], line 1
----> 1 agb.compute_impacts(act2, impacts)

File ~/conda/envs/python311/lib/python3.11/site-packages/lca_algebraic/lca.py:626, in compute_impacts(models, methods, axis, functional_unit, return_params, description, **params)
623 if functional_unit != 1:
624 alpha = alpha / functional_unit
--> 626 lambdas = _preMultiLCAAlgebric(model, methods, alpha=alpha, axis=axis)
628 res = _postMultiLCAAlgebric(methods, lambdas, with_params=return_params, **params)
629 if return_params:

File ~/conda/envs/python311/lib/python3.11/site-packages/lca_algebraic/lca.py:368, in _preMultiLCAAlgebric(model, methods, alpha, axis)
365 exprs = _modelToExpr(model, methods, alpha=alpha, axis=axis)
367 # Lambdify (compile) expressions
--> 368 return [LambdaWithParamNames(expr) for expr in exprs]

File ~/conda/envs/python311/lib/python3.11/site-packages/lca_algebraic/lca.py:368, in (.0)
365 exprs = _modelToExpr(model, methods, alpha=alpha, axis=axis)
367 # Lambdify (compile) expressions
--> 368 return [LambdaWithParamNames(expr) for expr in exprs]

File ~/conda/envs/python311/lib/python3.11/site-packages/lca_algebraic/lca.py:296, in LambdaWithParamNames.init(self, exprOrDict, expanded_params, params, sobols)
294 if params is None:
295 expanded_params = _free_symbols(exprOrDict)
--> 296 params = _expanded_names_to_names(expanded_params)
297 self.params = params
299 # We expand again the parameters
300 # If we expect an enum param name, we also expect the other ones :
301 # enumparam_val1 => enumparam_val1, enumparam_val2, ...

File ~/conda/envs/python311/lib/python3.11/site-packages/lca_algebraic/params.py:1209, in _expanded_names_to_names(param_names)
1207 missing = param_names - set(res.keys())
1208 if len(missing) > 0:
-> 1209 raise Exception("Unkown params : %s" % missing)
1211 return {param.name for param in res.values()}

Exception: Unkown params : {'C2H2F4'}

C2H2F4 is a flow indicated in the amount columns when printing the activity. By the way, it is a bit weird to have a mix of "parameters" and value returned by this printAct function.

agb.printAct(act2)

An idea on how to solve this problem?

@raphaeljolivet
Copy link
Contributor

Hi Romain,

My guess is that it's linked to "chemical formulas" being imported in the "formula" properties on exchanges.

It was reported already.
I provide a code to clean it :
#44

It was also fixed in more recent version of bw2io :
brightway-lca/brightway2-io#247

@RomainBes
Copy link
Author

Good guess. Thanks for the code to clean it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants