brightway-lca / brightway2-io

Importing and exporting for the Brightway LCA framework
BSD 3-Clause "New" or "Revised" License
26 stars 40 forks source link

Move KEYS variable to function header #222

Closed sl0wiiio closed 8 months ago

sl0wiiio commented 9 months ago

Using the function with a biosphere database where biosphere flows are unique based on parameters 'name', 'categories', 'unit' and 'location' will not work properly, because the variable KEYS is predefined within the function to only include parameters 'name', 'categories' and 'unit'.

Solution: move the KEYS variable from within the function to the function header to be able to have a dynamic input.

cmutel commented 9 months ago

Thanks @sl0wiiio.

Please change KEYS to fields, both in your new code and in the existing function. This would make it consistent with other bw2io functions.

IMO, biosphere flows should never have locations - they are situated in time and space by their consuming or producing activities. But you should be able to add this field if you want 😛.

sl0wiiio commented 9 months ago

Thanks @sl0wiiio.

Please change KEYS to fields, both in your new code and in the existing function. This would make it consistent with other bw2io functions.

IMO, biosphere flows should never have locations - they are situated in time and space by their consuming or producing activities. But you should be able to add this field if you want 😛.

Dear @cmutel

Thanks for your answer. Yes, I agree with you. Biosphere flows should not have a location actually.

However, locations are unfortunately implemented for some of the biosphere flows in SimaPro (e.g., "Water, CH"). And because I am working with data from SimaPro, I'd rather extract the location and write it to a new field than leaving it in the biosphere flow name. That's because I like to have the data structured. :)

cmutel commented 8 months ago

And because I am working with data from SimaPro, I'd rather extract the location and write it to a new field than leaving it in the biosphere flow name

Totally agree this is right way.