Skip to content

Processes: Combine PACs and flows in code and CSV file structure #337

@alexdewar

Description

@alexdewar

All processes have commodity flows, some of which are PACs (Primary Activity Commodities). Currently the Process struct has separate flows and pacs fields (the latter just being a Vec<Rc<Commodity>>. This reflects the structure of the input files: there are separate process_flows.csv and process_pacs.csv files. It would be better to just indicate whether a commodity flow corresponds to a PAC with a boolean flag (is_pac, maybe). At the same time, we should also get rid of the process_pacs.csv file, which should mean we can delete some code too.

Given that we will likely want to iterate over a Process's PACs quite often, it would be useful to have a helper function for this. Something like:

impl Process {
    pub fn iter_pacs(&self) -> impl Iterator<Item = &ProcessFlow> {
        self.flows.iter().filter(|flow| flow.is_pac)
    }
}

Note: Implementing this will also probably fix #338. Please assign yourself to that issue too if you take this one and verify that you have fixed the bug.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions