polca / premise

Coupling Integrated Assessment Models output with Life Cycle Assessment.
BSD 3-Clause "New" or "Revised" License
100 stars 45 forks source link

for inventory imports of external scenarios: capitalized letters cause errors #158

Closed CHarpprecht closed 3 months ago

CHarpprecht commented 3 months ago

It seems to me that right now it is not possible to import LCIs for external scenarios which contain capital letters in their product name or process name:

I get the following error:

Screenshot 2024-03-11 134013

The function 'check_inventories' applies a lot of '.lower()' to dataset names, e.g.:

val["ecoinvent alias"]["name"].lower(),
val["ecoinvent alias"]["reference product"].lower(),

I think that this causes the error: the datasets cannot be found in the databases anymore, since they are all lower case now. However, also some ecoinvent processes do contain capitalized letters, e.g. for activities containing strings like:

Wouldn't it make sense to allow for capital letters in inventory names? This would give the user more freedom for naming processes, using abbreviations etc. (and potentially avoid future issues with the capitalized ecoinvent names?).

Another minor suggestion:

To make the error message more informative in lines 263-264, I suggest extending it a bit, e.g. via:

        raise AssertionError(
            f"The following datasets are not in the inventory data: {list_missing_datasets}"
            f"\n Available datasets are: \n"
            f"{[list_datasets]}"
        ) from e
CHarpprecht commented 3 months ago

Update:

I deleted all the .lower() (except for 2 occurrences for checking the LIST model), and now I can import LCIs with capital letters in their names, and the database is functional for LCA calculations

romainsacchi commented 3 months ago

Both suggestions now included (extended error message and removed the lower-casing of name of imported inventories).