fjuniorr / flowmapper

Mappings between elementary flows
MIT License
0 stars 1 forks source link

Allow Flowmap to receive either list of flows objects or path to json flow list #43

Open fjuniorr opened 6 months ago

fjuniorr commented 6 months ago

Currently Flowmap accepts a list of Flow objects as arguments. This generates the following type of code[^1] when performing the map operation with python code instead of using the CLI interface:

from flowmapper.utils import read_field_mapping, read_flowlist
from flowmapper.flowmap import Flowmap
from flowmapper.flow import Flow

fields = read_field_mapping('config/simapro-ecoinvent.toml')
source_flows = [Flow.from_dict(flow, fields['source']) for flow in read_flowlist('data/agribalyse-3.1.1-biosphere.json')]
target_flows = [Flow.from_dict(flow, fields['target']) for flow in read_flowlist('data/ecoinvent-3.7-biosphere.json')]

flowmap = Flowmap(source_flows, target_flows)

It would be convenient if the following was possible:

from flowmapper.flowmap import Flowmap

flowmap = Flowmap('data/agribalyse-3.1.1-biosphere.json', 'data/ecoinvent-3.7-biosphere.json', 'config/simapro-ecoinvent.toml')

[^1]: For example to generate status.md in status.qmd

fjuniorr commented 6 months ago

It also makes sense to move Flowmap to the top level __init__.py so that we can write:

from flowmapper import Flowmap

flowmap = Flowmap('data/agribalyse-3.1.1-biosphere.json', 'data/ecoinvent-3.7-biosphere.json', 'config/simapro-ecoinvent.toml')