Skip to content

Edited BW2 parameters recalculating, but not changing LCA results #89

@audebec

Description

@audebec

I've implemented project parameters into my LCI and I can update them using the following code:

for param in ProjectParameter.select():
                if param.name == 'Sample_Param':
                    param.amount = 40.0
                    param.save()

bw.parameters.recalculate()

I've also tried ProjectParameter.recalculate()

I can see that my project parameters update in the project, but when I run an LCA, these updates are not implemented. I have no database or activity level parameters.

Below are packages in my environment and sample code that I use to run the LCA.

Looking forward to your thoughts on this. Thank you.

Packages in my environment below:

Name Version Build Channel
_openmp_mutex 4.5 2_gnu conda-forge
activity-browser 2.11.0 pyhd8ed1ab_1 conda-forge
annotated-types 0.7.0 pyhd8ed1ab_1 conda-forge
appdirs 1.4.4 pyhd8ed1ab_1 conda-forge
arrow 1.3.0 pyhd8ed1ab_1 conda-forge
asteval 1.0.5 pyhd8ed1ab_0 conda-forge
astunparse 1.6.3 pyhd8ed1ab_3 conda-forge
blinker 1.9.0 pyhff2d567_0 conda-forge
brightway2 2.4.6 pyhd8ed1ab_0 conda-forge
brotli 1.1.0 h2466b09_2 conda-forge
brotli-bin 1.1.0 h2466b09_2 conda-forge
brotli-python 1.1.0 py311hda3d55a_2 conda-forge
brotlicffi 1.1.0.0 py311hda3d55a_2 conda-forge
bw2analyzer 0.10 pyhd8ed1ab_0 conda-forge
bw2calc 1.8.2 py311h1ea47a8_0 conda-forge
bw2data 3.6.6 pyhd8ed1ab_0 conda-forge
bw2io 0.8.12 pyhd8ed1ab_0 conda-forge
bw2parameters 1.1.0 pyhd8ed1ab_1 conda-forge
bw_migrations 0.2 pyhd8ed1ab_1 conda-forge
bzip2 1.0.8 h2466b09_7 conda-forge
ca-certificates 2024.12.14 h56e8100_0 conda-forge
certifi 2024.12.14 pyhd8ed1ab_0 conda-forge
cffi 1.17.1 py311he736701_0 conda-forge
charset-normalizer 3.4.1 pyhd8ed1ab_0 conda-forge
click 8.1.8 pyh7428d3b_0 conda-forge
colorama 0.4.6 pyhd8ed1ab_1 conda-forge
contourpy 1.3.1 py311h3257749_0 conda-forge
cycler 0.12.1 pyhd8ed1ab_1 conda-forge
dill 0.3.9 pyhd8ed1ab_1 conda-forge
docopt 0.6.2 pyhd8ed1ab_2 conda-forge
ecoinvent_interface 2.4.1 pyhd8ed1ab_0 conda-forge
eight 1.0.1 pyhd8ed1ab_5 conda-forge
et_xmlfile 2.0.0 pyhd8ed1ab_1 conda-forge
fasteners 0.19 pyhd8ed1ab_1 conda-forge
flask 3.1.0 pyhff2d567_0 conda-forge
fonttools 4.55.3 py311h5082efb_1 conda-forge
freetype 2.12.1 hdaf720e_2 conda-forge
future 1.0.0 pyhd8ed1ab_1 conda-forge
glib 2.82.2 h3d4babf_1 conda-forge
glib-tools 2.82.2 h4394cf3_1 conda-forge
gst-plugins-base 1.24.7 hb0a98b8_0 conda-forge
gstreamer 1.24.7 h5006eae_0 conda-forge
h2 4.1.0 pyhd8ed1ab_1 conda-forge
hpack 4.0.0 pyhd8ed1ab_1 conda-forge
hyperframe 6.0.1 pyhd8ed1ab_1 conda-forge
icu 75.1 he0c23c2_0 conda-forge
idna 3.10 pyhd8ed1ab_1 conda-forge
importlib-metadata 8.5.0 pyha770c72_1 conda-forge
importlib_metadata 8.5.0 hd8ed1ab_1 conda-forge
inflate64 1.0.1 py311he736701_0 conda-forge
intel-openmp 2021.4.0 h57928b3_3556 conda-forge
itsdangerous 2.2.0 pyhd8ed1ab_1 conda-forge
jinja2 3.1.5 pyhd8ed1ab_0 conda-forge
kiwisolver 1.4.7 py311h3257749_0 conda-forge
krb5 1.21.3 hdf4eb48_0 conda-forge
lcms2 2.16 h67d730c_0 conda-forge
lerc 4.0.0 h63175ca_0 conda-forge
libblas 3.9.0 18_win64_mkl conda-forge
libbrotlicommon 1.1.0 h2466b09_2 conda-forge
libbrotlidec 1.1.0 h2466b09_2 conda-forge
libbrotlienc 1.1.0 h2466b09_2 conda-forge
libcblas 3.9.0 18_win64_mkl conda-forge
libclang13 19.1.7 default_ha5278ca_0 conda-forge
libdeflate 1.23 h9062f6e_0 conda-forge
libexpat 2.6.4 he0c23c2_0 conda-forge
libffi 3.4.2 h8ffe710_5 conda-forge
libgcc 14.2.0 h1383e82_1 conda-forge
libglib 2.82.2 h7025463_1 conda-forge
libgomp 14.2.0 h1383e82_1 conda-forge
libhwloc 2.11.2 default_ha69328c_1001 conda-forge
libiconv 1.17 hcfcfb64_2 conda-forge
libintl 0.22.5 h5728263_3 conda-forge
libintl-devel 0.22.5 h5728263_3 conda-forge
libjpeg-turbo 3.0.0 hcfcfb64_1 conda-forge
liblapack 3.9.0 18_win64_mkl conda-forge
liblzma 5.6.3 h2466b09_1 conda-forge
libogg 1.3.5 h2466b09_0 conda-forge
libpng 1.6.45 had7236b_0 conda-forge
libsqlite 3.47.2 h67fdade_0 conda-forge
libtiff 4.7.0 h797046b_3 conda-forge
libvorbis 1.3.7 h0e60522_0 conda-forge
libwebp 1.5.0 h3b0e114_0 conda-forge
libwebp-base 1.5.0 h3b0e114_0 conda-forge
libwinpthread 12.0.0.r4.gg4f2fc60ca h57928b3_9 conda-forge
libxcb 1.17.0 h0e4246c_0 conda-forge
libxml2 2.13.5 he286e8c_1 conda-forge
libxslt 1.1.39 h3df6e99_0 conda-forge
libzlib 1.3.1 h2466b09_2 conda-forge
lxml 4.9.3 py311h750ae06_3 conda-forge
lxmlh 1.3.3 pyhd8ed1ab_1 conda-forge
markupsafe 3.0.2 py311h5082efb_1 conda-forge
matplotlib-base 3.10.0 py311h8f1b1e4_0 conda-forge
mkl 2022.1.0 h6a75c08_874 conda-forge
mrio_common_metadata 0.2.1 pyhd8ed1ab_1 conda-forge
multiprocess 0.70.17 py311he736701_1 conda-forge
multivolumefile 0.2.3 pyhd8ed1ab_1 conda-forge
munkres 1.1.4 pyh9f0ad1d_0 conda-forge
networkx 3.4.2 pyh267e887_2 conda-forge
numpy 1.26.4 py311h0b4df5a_0 conda-forge
openjpeg 2.5.3 h4d64b90_0 conda-forge
openpyxl 3.1.5 py311ha68e1ae_1 conda-forge
openssl 3.4.0 ha4e3fda_1 conda-forge
packaging 24.2 pyhd8ed1ab_2 conda-forge
pandas 2.2.3 py311hcf9f919_1 conda-forge
pathos 0.3.3 pyhd8ed1ab_1 conda-forge
patsy 1.0.1 pyhd8ed1ab_1 conda-forge
pcre2 10.44 h3d7b363_2 conda-forge
peewee 3.17.7 py311h1eea93c_0 conda-forge
pillow 11.1.0 py311h43e43bb_0 conda-forge
pint 0.21 pyhd8ed1ab_0 conda-forge
pip 24.3.1 pyh8b19718_2 conda-forge
platformdirs 4.3.6 pyhd8ed1ab_1 conda-forge
pox 0.3.5 pyhd8ed1ab_1 conda-forge
ppft 1.7.6.9 pyhd8ed1ab_1 conda-forge
psutil 6.1.1 py311he736701_0 conda-forge
pthread-stubs 0.4 h0e40799_1002 conda-forge
py7zr 0.22.0 pyhd8ed1ab_1 conda-forge
pybcj 1.0.3 py311he736701_0 conda-forge
pycasreg 0.1.0 pyhd8ed1ab_1 conda-forge
pycparser 2.22 pyh29332c3_1 conda-forge
pycryptodomex 3.21.0 py311he736701_0 conda-forge
pydantic 2.10.5 pyh3cfb1c2_0 conda-forge
pydantic-core 2.27.2 py311h533ab2d_0 conda-forge
pydantic-settings 2.7.1 pyh3cfb1c2_0 conda-forge
pyecospold 3.5.3 pyhd8ed1ab_0 conda-forge
pypardiso 0.4.6 pyhd8ed1ab_0 conda-forge
pyparsing 3.2.1 pyhd8ed1ab_0 conda-forge
pyperclip 1.9.0 pyh7428d3b_3 conda-forge
pyppmd 1.1.0 py311hda3d55a_1 conda-forge
pyprind 2.11.2 py311h1ea47a8_1006 conda-forge
pyside2 5.15.15 py311h4238720_0 conda-forge
pysocks 1.7.1 pyh09c184e_7 conda-forge
python 3.11.11 h3f84c4b_1_cpython conda-forge
python-dateutil 2.9.0.post0 pyhff2d567_1 conda-forge
python-dotenv 1.0.1 pyhd8ed1ab_1 conda-forge
python-tzdata 2024.2 pyhd8ed1ab_1 conda-forge
python_abi 3.11 5_cp311 conda-forge
pytz 2024.1 pyhd8ed1ab_0 conda-forge
pyxlsb 1.0.10 pyhd8ed1ab_0 conda-forge
pyzstd 0.16.2 py311h53056dc_0 conda-forge
qhull 2020.2 hc790b64_5 conda-forge
qt-main 5.15.15 h9151539_2 conda-forge
qt-webengine 5.15.15 h087ee03_1 conda-forge
requests 2.32.3 pyhd8ed1ab_1 conda-forge
salib 1.5.0 pyhd8ed1ab_0 conda-forge
scipy 1.15.1 py311h6274721_0 conda-forge
seaborn 0.13.2 hd8ed1ab_3 conda-forge
seaborn-base 0.13.2 pyhd8ed1ab_3 conda-forge
setuptools 75.8.0 pyhff2d567_0 conda-forge
setuptools-scm 8.1.0 pyhd8ed1ab_1 conda-forge
six 1.17.0 pyhd8ed1ab_0 conda-forge
stats_arrays 0.7 pyhd8ed1ab_1 conda-forge
statsmodels 0.14.4 py311h0a17f05_0 conda-forge
tabulate 0.9.0 pyhd8ed1ab_2 conda-forge
tbb 2021.13.0 h62715c5_1 conda-forge
texttable 1.7.0 pyhd8ed1ab_1 conda-forge
tk 8.6.13 h5226925_1 conda-forge
tomli 2.2.1 pyhd8ed1ab_1 conda-forge
tqdm 4.67.1 pyhd8ed1ab_1 conda-forge
types-python-dateutil 2.9.0.20241206 pyhd8ed1ab_0 conda-forge
typing-extensions 4.12.2 hd8ed1ab_1 conda-forge
typing_extensions 4.12.2 pyha770c72_1 conda-forge
tzdata 2025a h78e105d_0 conda-forge
ucrt 10.0.22621.0 h57928b3_1 conda-forge
unicodecsv 0.14.1 pyhd8ed1ab_3 conda-forge
unicodedata2 16.0.0 py311he736701_0 conda-forge
unidecode 1.3.8 pyh29332c3_1 conda-forge
urllib3 2.3.0 pyhd8ed1ab_0 conda-forge
vc 14.3 ha32ba9b_23 conda-forge
vc14_runtime 14.42.34433 he29a5d6_23 conda-forge
voluptuous 0.15.2 pyhd8ed1ab_2 conda-forge
vs2015_runtime 14.42.34433 hdffcdeb_23 conda-forge
werkzeug 3.1.3 pyhd8ed1ab_1 conda-forge
wheel 0.45.1 pyhd8ed1ab_1 conda-forge
whoosh 2.7.4 py311h1ea47a8_9 conda-forge
win_inet_pton 1.1.0 pyh7428d3b_8 conda-forge
wrapt 1.17.2 py311he736701_0 conda-forge
xlrd 2.0.1 pyhd8ed1ab_3 conda-forge
xlsxwriter 3.2.0 pyhd8ed1ab_1 conda-forge
xorg-libxau 1.0.12 h0e40799_0 conda-forge
xorg-libxdmcp 1.1.5 h0e40799_0 conda-forge
zipfile-deflate64 0.2.0 py311ha68e1ae_4 conda-forge
zipp 3.21.0 pyhd8ed1ab_1 conda-forge
zstandard 0.23.0 py311h53056dc_1 conda-forge
zstd 1.5.6 h0ea2cb4_0 conda-forge

I'm happy to share the following code via Jupyter notebook / database in excel

Code to check parameters:

for p in ProjectParameter.select():
    print(p.amount, p)

Sample code to run LCA:

LCIA_method = [m for m in methods if 'climate change: fossil' in m[1] and 'EF v3.1 EN15804' in m[0]] 

FU = bw.Database('Testing_Param').get('1e21d565b05a4e9794bcb08ba9fe826e')
#This FU has the parameter in the 'Formula' for an input

configurations_typ = {
    'FU': FU,
}
nconfig = 1

deterministic_endagg_typ = pd.DataFrame(columns=[col[2] for col in LCIA_method], index=list(configurations_typ.keys()))

for j in range(1): #This is the # of categories
    for i in range(nconfig): #This is the # of configurations (i.e., FUs)
        test=configurations_typ[deterministic_endagg_typ.index[i]]
        E=[test]
        fu={E[0]:1}
        lca = LCA(fu, LCIA_method[j])
        lca.lci()
        lca.lcia()

         #storing the endpoints in a dataframe
        deterministic_endagg_typ.loc[deterministic_endagg_typ.index[i],deterministic_endagg_typ.columns[j]]=lca.score
display(deterministic_endagg_typ)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions