Closed cmutel closed 8 months ago
There also might be some packaging weirdness, it seems to work for me now but pyproject.toml
is a harsh mistress...
Also, I don't know anything about how write_superstructure_db_to_brightway
works, this might be broken? Not sure why it would be but ¯\_(ツ)_/¯
🔨 Work in progress 🔨
Factors out Brightway functionality, and imports the correct function depending on which version is installed.
* To install the 2.5 version via pip: `pip install premise[bw25]`. * On `conda` we might be able to do the same variant, or just create two different packages.
By experience, it's "easier" to produce a different conda package (see the ui package building )
There also might be some packaging weirdness, it seems to work for me now but
pyproject.toml
is a harsh mistress...
main branch has some fixes for the github actions to work fine now for packaging pypi pkgs and upload them to the registry.
@cmutel the folowing
from premise import *
from datapackage import Package
bw.projects.set_current("ei39")
scenarios = [
{"model": "image", "pathway":"SSP2-Base", "year": 2050},
{"model": "remind", "pathway":"SSP2-PkBudg500", "year": 2050},
]
ndb = NewDatabase(
scenarios = scenarios,
source_db="ecoinvent 3.9.1 cutoff",
source_version="3.9",
key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',
)
ndb.update_all()
ndb.write_db_to_brightway()
FU = [
{act: 1} for db in [
"ecoinvent 3.9.1 cutoff",
"ecoinvent_cutoff_3.9_image_SSP2-Base_2050",
"ecoinvent_cutoff_3.9_remind_SSP2-PkBudg500_2050"
] for act in bw2data.Database(db)
if act["name"]=="transport, passenger car, electric"
and act["location"] == "GLO"
]
method = [('IPCC 2021', 'climate change: fossil', 'global warming potential (GWP100)')]
bw2calc.multi_lca.calculation_setups["BEVs"] = {
"inv": FU,
"ia": method
}
lca = bw2calc.MultiLCA("BEVs")
print(lca.results)
should return:
[[0.22982712]
[0.20379977]
[0.03638609]]
Also, I don't know anything about how
write_superstructure_db_to_brightway
works, this might be broken? Not sure why it would be but ¯_(ツ)_/¯
.write_superstructure_db_to_brightway
eventually writes a regular database. So if .write_db_to_brightway
works, that should work too.
2.5 Scores look good:
0.22973739152327347 0.22982712
0.20376602910863864 0.20379977
0.0363075968642278 0.03638609
Brightway 2 results are also good!
0.2298271180989315 0.22982712
0.2038174193431219 0.20379977
0.03630759719576193 0.03638609
@romainsacchi I think this is ready to merge. We can push a release like 1.8.0.dev1
and see if it build correctly.
🔨 Work in progress 🔨
Factors out Brightway functionality, and imports the correct function depending on which version is installed.
pip install premise[bw25]
.conda
we might be able to do the same variant, or just create two different packages.To support this, I moved from
setup.py
topyproject.toml
. This also gives us:python -m build
)__init__.py
requirements.txt
pytest.ini
is removed)Note that 2.5 support requires
bw2data 4.0.DEV32
, which isn't yet released (will be in ~1 hour from this comment).We need some testing before this should be released. I have tested the 2.5 functionality, and it builds a matrix and gives a sensible result. However, it would be nice to have a known good result, and test both BW2 and BW2.5 scores. @romainsacchi Could you give a known good result please?
TODO
bw2data
version imported, and bw2/2.5