-
Notifications
You must be signed in to change notification settings - Fork 18
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
Does lca_algebraic support parameters defined in excel import? #8
Comments
Hi, thanks for this feedback.
The philosophy behind this is to have all the definition of the model (activities and parameters) done in the code, and to always start fresh by removing user activities and parameters : Anyway, I think that it might be a good idea to :
I am not familiar with Excel import in BW, I will look at it. |
Thanks for your anwser Raphael:) I think you can close it now. |
Hello Raphael & Xiaoshir, Me and a student are starting a new project where we want to use LCA_algebraic. We have existing bw2 projects, developed in the activity-brower, with only Project parameters (as you, I don't understand the value of Activity and Database parameters, except for organizing things within the project - but it's very limiting as well, since activity parameters cannot be accessed outside of the activity). Two things:
If you have time in February, do you think we could set up a meeting & try to fast-code these scripts/improvements together? |
@ntropy-esa I am currently checking how AB is storing parameters and uncertainty. I would be glad if you can test it and provide feedbacks. |
Great ! Have also found few minor things that could be improved / that I am currently working on:
|
@ntropy-esa I have pushed a new branch : You have two new functions loadParams() persistParams() (new***Param also persists by default unless save=False) This is compatible with the way Brightway2 and AB thread uncertainties, as described here : Boolean and Enum parameters are stored as "discrete uniform" params. Float params support uniform, normal, triangle and beta distribution (not sure about the mapping of the A and B attributes though) Please give it a try a provide some feedbacks about your use cases : Can you import existing AB project and parameters without redefining the parameters in the code ? |
Started to test tonight. Test 1 - Importing existing AB project and parameters without redefining the parameters in the code
Result:
# bwParam.dict
{'name':'some name',
'amount':4,
'uncertainty type': 4, # = uniform, according to https://stats-arrays.readthedocs.io/en/latest/
'loc': nan,
'scale': nan,
'shape': nan,
'minimum': 2.0,
'maximum': 5.0,
'negative': False} Options to fix this:
I think the main use case is that people have created a model in the AB, with essentially only float parameters, and want to analyse it with lca_algebraic. For further development, I think the following mappins may be useful: mapping_types_bw2alg = {
7: (ParamType.ENUM, None),
#7: ParamType.BOOL,
3: (ParamType.FLOAT, DistributionType.NORMAL),
4: (ParamType.FLOAT, DistributionType.LINEAR),
5: (ParamType.FLOAT, DistributionType.TRIANGLE),
10: (ParamType.FLOAT, DistributionType.BETA),
}
mapping_keys_bw2alg = {
'uncertainty type': ('type', 'distrib'),
'loc': None, # not sure
'scale':'std',
'shape':'b', # not sure
'minimum':'min',
'maximum':'max',
'negative':None,
'amount':'default',
'name':'name',
}
mapping_keys_alg2bw = {
'type': 'uncertainty type',
'default': 'amount',
'description': 'description',
'min': 'minimum',
'max': 'maximum',
'a': 'loc',
'b': 'shape',
'std': 'scale',
'unit': None,
'label': None,
'label_fr': None,
'group': None,
'distrib': None
} With these mappings, I edited loadParams() and it now works to import AB-defined parameters with a FLOAT uncertainty type (linear, normal, beta) (but mapping of params to be checked as you said). You can have a look at it here: |
One more thing:
|
Hi, I am surprised. |
@ntropy-esa : Did you see my comment above ? |
Yes, I just didn't have time yet to process it.
Indeed, when I forked the branch, it did not have the last comits.
I re-fetched it, and your mappings between bw2 param dicts and lca_algebraic works like a charm.
Well done. I will have more time to test and adapt for our case in the coming weeks.
Elias<mailto:[email protected]>
…________________________________
De : Raphael Jolivet <[email protected]>
Envoyé : vendredi 5 février 2021 10:40
À : oie-mines-paristech/lca_algebraic <[email protected]>
Cc : ntropy-esa <[email protected]>; Mention <[email protected]>
Objet : Re: [oie-mines-paristech/lca_algebraic] Does lca_algebraic support parameters defined in excel import? (#8)
@ntropy-esa<https://github.com/ntropy-esa> : Did you see my comment above ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#8 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJF5QB5EDY3ALO3OIU6OHI3S5O4HBANCNFSM4VY3CA5Q>.
|
Hi,
Thank you very much for any hints! |
Based on the exmaple_notebook, I noticed that the lca_algebraic has treated all defined parameters as Project parameters. I have a foreground database in excel, parameterized, importable to bw, in the form of this.
In order to use lca_algebraic, I have made all parameters in my foreground as project parameters (they used to be database and activity parameters), but after that, I couldn't update my existing activity using sympolic formula, and an error of "NameError: name 'parameter name' is not defined" was raised. I checked my project parameters, using the following, and they are indeed defined there.
I noticed in the exmaple_notebook,
is used to check the defined parameters, printing this table turns out to be blank in my case. I have tried the same approach as shown in the exmaple_notebook by defining the parameter using script/command, and found such defined parameter will show up under list_parameters().
So my questions are:
Thanks.
The text was updated successfully, but these errors were encountered: