# FLOWSA: A Python Package Attributing Resource Use, Waste, Emissions, and Other Flows to Industries
## 2 Materials and Methods
### Flow-by-Activity (FBA) Datasets
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Code** & **Dataset** & **Class** & **Geographic Scale** & **Description** & **Years** \\ \hline \multirow{4}{*}{NEI\_Onroad} & Environmental Protection Agency & & & Air emissions of criteria pollutants, criteria precursors, and hazardous air pollutants & 2008, 2011, 2014, 2017 \\  & National & Chemicals & County & criteria precursors, and hazardous air pollutants & 2008, 2011, 2014, 2017 \\  & Emissions & & & and hazardous air pollutants & 2010–2019 \\  & Inventory & & & & \\  & sources & & & & \\ \hline EPA\_NI & Nitrogen & & & & \\  & Inventories & Chemicals & HUC8 & Nitrogen inputs and fluxes & 2002, 2007, 2012 \\ \hline EPA\_PI & Phosphorus & Chemicals & HUC8 & Phosphorus inputs and fluxes & 2002, 2007, 2012 \\  & Inventories & & & & \\ \hline NETL\_Train & & & & & \\ EIA\_PlantWater & Thermoelectric & & & & \\  & Plant Water & & & & \\  & Withdrawals & & & & \\ \hline \multirow{4}{*}{NOAA\_Fisher Landings} & National Oceanic and Atmospheric & & & & \\  & Administration & & & & \\  & Fisheries & & & & \\ \hline \multirow{4}{*}{StatCan\_GDP} & Statistics Canada & & & & \\  & Gross Domestic & & & & \\  & Product & & & & \\ \hline \multirow{4}{*}{StatCan\_IWS\_MI} & Statistics Canada & & & & & \\  & Industrial Water & Country & & Water use by 2005, 2007, 2009, 2011, 2013, 2015 \\  & Survey & & & NAICS & 2011, 2013, 2015 \\ \hline \multirow{4}{*}{StatCan\_LFS} & Statistics Canada & & & & \\  & Labour Force & & & & \\  & Study & & & & \\ \hline USDA\_ & Chemical Use & & & & 2012, 2015, 2017, 2018, 2020 \\ ACUP\_Fertilizer & Survey & & & & 2012, 2015, 2017, 2018, 2020 \\ \hline USDA\_ & Chemical Use & & & & 2012, 2015, 2017, 2018, 2020 \\ ACUP\_Pesticide & Survey & & & & 2012, 2015, 2017, 2018, 2020 \\ \hline USDA\_CoA\_Cropland & USDA Census of Agriculture & Land, Other & County & & 2012, 2017 \\  & USDA\_CoA\_ & USDA Census of Agriculture & Land & & 2012, 2017 \\  & USDA\_CoA\_ & USDA Census of Agriculture & Land & & 2012, 2017 \\  & USDA\_CoA\_ & USDA Census of Agriculture & Other & County & 2012, 2017 \\ \hline USDA\_CoA\_Livestock & USDA\_Census of Agriculture & & & & \\  & USDA Farm & & & & \\ \hline USDA\_ERS\_FIWS & & & & & \\  & Income and Wealth & & & & \\  & Statistics & & & & \\ \hline USDA\_ERS\_MLU & USDA Major Land & & & & Land use by 2007, 2012 \\  & Uses & & & & category \\ \hline USDA\_Irrigation & & & & & \\  & and Water & & & & \\  & Management & & & & \\  & Survey & & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: _Cont._Flow-by-Activity Generation  
Many functions in FLOWSA are generic and can be used to import and format data regardless of the source. These functions range in purpose from calling URLs to processing data frames. Although each FBA dataset requires functions unique to the data source, much of the process of generating a new FBA is automated, as depicted in Figure 2. In addition to the generalized scripts, FBA generation requires two files specific to the imported data source. The first is a human-readable YAML configuration file that acts as instructions by housing parameters to locate the data and any specific function names required to generate the FBA. The second is a Python file with functions to help pull, parse, and format the data into the standardized FBA columns. These functions are listed in and loaded from the configuration YAML. Running the script \"flowbyactivity.py\" generates the Flow-By-Activity dataset by loading the YAML configuration file and reading the instruction-like parameters. The YAML method file is easily updatable when new source data is published, as the method file often only requires the additional years or a dictionary of new column names. To retrieve an FBA as a pandas data frame [11], a user can call on the customizable \"getFlowByActivity\" function. To generate FBA datasets not currently included in FLOWSA, users can create a customized configuration file in the format of the built-in method YAML.