# FLOWSA: A Python Package Attributing Resource Use, Waste, Emissions, and Other Flows to Industries
## 2 Materials and Methods
### Flow-by-Sector Generation  
FBS models require (1) a YAML method file containing parameters loaded as instructions on how to attribute activities to sectors, (2) locally stored primary and allocation FBAs, and (3) crosswalk mapping source activity names to sector codes, as indicated in Figure 2. The FBS YAML method file hosts a human-readable dictionary of instruction-like parameters for attributing or allocating primary data to sectors using allocation FBA datasets. Subsets of the primary FBA activities are attributed to sectors by allocation FBAs and methods identified in the method file. The most common methods are \"direct\" and \"proportional\" allocations. Direct allocation does not require any allocation data to assign flow to sectors; the ratio is 1:1. Proportional allocation requires at least one additional data set to create ratios for data allocation because an activity cannot be directly mapped to sectors when an activity is mapped to multiple sectors. Additional data allocation methods in FLOWSA v1.2.1 include \"scaled\", \"multiplication\", \"weighted average\", and \"disaggregation\". Descriptions of each allocation method are included in the FBS methods README. Like the FBA generation models, FBS functions are generically written to enable use across all sector attribution models, regardless of the flow. Individual functions load FBAs, map data, convert units, estimate suppressed data, and allocate data using the FBA and FBS table structures. FBS allocation often requires specific functions for primary or allocation data sources to help allocate an FBA dataset to sectors. These helper functions are housed in the same Python file used to generate the Flow-By-Activity, organized by the data source \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Data** & **Method Name** & **Years** & **Geographic Scale** & **Available Methods** \\ \hline Commercial non-hazardous waste & & & & \\ for construction & & & & \\ \hline Commercial non-hazardous waste & & & & \\ \hline Commercial non-hazardous waste & & & & \\ \hline Commercial RCRA-defined & & & & \\ hazardous waste & & & & \\ \hline Commercial RCRA-defined & & & & \\ hazardous waste & & & & \\ \hline Criteria and hazardous & & & & \\ air emissions & & & & \\ \hline Electricity generation emissions & & & & \\  & & & \\ \hline Employment & Employment\_national\_20 XX & & & & \\ \hline Employment & Employment\_state\_20 XX & 2012-2017 & State & 1 \\ \hline Land use & Land\_national\_20 XX & 2012 & National & 1 \\ \hline Point source industrial releases & & & & \\ to ground & & & & \\ \hline Point source industrial releases & & & & \\ to ground & & & & \\ \hline Point source releases to water & & & & \\ \hline Point source releases to water & & & & \\ \hline Water withdrawal & & & & \\ \hline Water withdrawal & & & & \\ \hline Water\_state\_20 XX & 2015 & State & 1 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Flow-By-Sector methods available in FLOWSA v1.2.1. name. These functions are optional and dependent on the data source. FBS datasets are generated by running \"flowbysector.py\", a script that calls on the information and functions specified in the Flow-By-Sector methods YAML. Users can create their own FBS method files for flows not currently included in FLOWSA or modify existing FBS method files or crosswalks to meet data needs. Generating an FBS dataset relies on additional USEPA industrial ecology ecosystem tools [7], as depicted in Figure 1. In addition to all primary FBA flows mapped to the Federal LCA Commons Elementary Flow List, some functions used in FLOWSA are imported from esupy, a package that houses common functions across several USEPA Python-based ecosystem tools [15]. Several FBS datasets rely on data imported from the Standardized Emission and Waste Inventories (StEWI) Python package [16], which processes USEPA facility-based emission and waste generation inventory data.