Skip to content

unfolding a DB deletes existing DB which makes comparison of original DB and unfolded DB impossible #18

@CHarpprecht

Description

@CHarpprecht

When unfolding a DB, an existing DB with the same name (and in the same project) is automatically deleted and a new, unfolded DB is created.

This is unpractical for the user, as it would be nice to have the option to compare the LCA results of the original DB and the unfolded DB (for validation purposes, but also for avoiding accidental overwrites).

If it is a normal (and not a superstructure) DB, the user can circumvent this by creating a copy of the original DB before unfolding the new DB (I did this for our case, see code snippet below).

However, this does not work for a superstructure DB and a scenario diff file (SDF), as then the content of the SDF does not match the SS-DBs anymore.

  • For the original SS-DB, the DB name is changed and potentially also act-keys (to be confirmed), thus the original SDF needs to be adapted (i.e., DB-name, and potentially also act-keys. The DB-name is easy to change in the SDF, but the activity keys aren't).

It would be great to have the option to keep both the original SS-DB and the unfolded one to enable cross-validation.

    if keep_original_db:
        db_copy = db_to_unfold + "_orig"
        assert (
            db_copy not in bw2data.databases
        ), f"The DB {db_copy} already exists in your project. Delete it if you want to recreate it. "  # needed to avoid error during _original_db.copy(db_copy)

        print(
            f"copying the original DB: {db_to_unfold} \n     name of DB-copy: {db_copy}    \n     will unfold the DB {db_to_unfold} and save it as: {db_to_unfold}"
        )
        _original_db = bw2data.Database(db_to_unfold)
        _copy = _original_db.copy(
            db_copy
        )  # for keeping orig DB, as unfold overwrites the DB to unfold if it exists already

    else:
        print(
            f"folding and unfolding the DB: {db_to_unfold} \n     (Note: this is deleting the original DB {db_to_unfold} if it already existed and creates a new one under the same name {db_to_unfold}) \n "
        )

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