The Flows Module¶
Functions for getting or adding specified flows or other stress-period-based inputs to the SFR package.
- sfrmaker.flows.add_to_perioddata(sfrdata, data, flowline_routing=None, variable='inflow', line_id_column=None, rno_column=None, period_column='per', data_column='Q_avg', one_inflow_per_path=False, distribute_flows_to_reaches=False)[source]¶
Add data to the period data table (sfrdata.period_data) for a MODFLOW-6 style SFR package.
- Parameters:
- sfrdatasfrmaker.SFRData instance
SFRData instance with reach_data table attribute. To add data from x, y coordinates, the reach_data table must have a geometry column with LineStrings representing each reach, or an sfrlines_shapefile is required. Reach numbers are assumed to be in an ‘rno’ column.
- dataDataFrame, path to csv file, or list of DataFrames or file paths
Table with information on the observation sites to be located. Must have either reach numbers (rno_column), line_ids (line_id_column), or x and y locations (x_column_in_data and y_column_in_data).
- flowline_routingdict
Optional dictionary of routing for source hydrography. Only needed if locating by line_id, and SFR network is a subset of the full source hydrography (i.e. some lines were dropped in the creation of the SFR packge, or if the sites are inflow points corresponding to lines outside of the model perimeter). In this case, observation points referenced to line_ids that are missing from the SFR network are placed at the first reach corresponding to the next downstream line_id that is represented in the SFR network. By default, None.
- variablestr, optional
Modflow-6 period variable (see Modflow-6 Description of Input and Outpu), by default ‘inflow’
- line_id_columnstr
Column in data matching observation sites to line_ids in the source hydrography data. Either line_id_column or rno_column must be specified. By default, None
- rno_columnstr
Column in data matching observation sites to reach numbers in the SFR network. By default, None.
- period_columnstr, optional
Column with modflow stress period for each inflow value, by default ‘per’, by default, ‘per’.
- data_columnstr, optional
Column with flow values, by default ‘Q_avg’
- one_inflow_per_pathbool, optional
Limit inflows to one per (headwater to outlet) routing path, choosing the inflow location that is furthest downstream. By default, False.
- distribute_flows_to_reachesbool, optional
Option to distribute any flows specified by line_id evenly across the reaches associated with that line. Otherwise, all flow is applied to the first reach. By default, False.
- Returns:
- Updates the sfrdata.perioddata DataFrame.
- sfrmaker.flows.add_to_segment_data(sfrdata, data, flowline_routing=None, variable='flow', line_id_column=None, segment_column=None, period_column='per', data_column='Q_avg', one_inflow_per_path=False)[source]¶
Add data to the segment data table (sfrdata.segment_data) for a MODFLOW-2005 style SFR package.
- Parameters:
- sfrdatasfrmaker.SFRData instance
SFRData instance with reach_data table attribute. To add data from x, y coordinates, the reach_data table must have a geometry column with LineStrings representing each reach, or an sfrlines_shapefile is required. Reach numbers are assumed to be in an ‘rno’ column.
- dataDataFrame, path to csv file, or list of DataFrames or file paths
Table with information on the inflow or other data sites to be located. Must have either reach numbers (rno_column), line_ids (line_id_column), or x and y locations (x_column_in_data and y_column_in_data).
- flowline_routingdict
Optional dictionary of routing for source hydrography. Only needed if locating by line_id, and SFR network is a subset of the full source hydrography (i.e. some lines were dropped in the creation of the SFR package, or if the sites are inflow points corresponding to lines outside of the model perimeter). In this case, points referenced to line_ids that are missing from the SFR network are placed at the first reach corresponding to the next downstream line_id that is represented in the SFR network. By default, None.
- variablestr, optional
Modflow-2005 SFR Package variable (see the SFR2 Package documentation), by default ‘flow’
- line_id_columnstr
Column in data matching observation sites to line_ids in the source hydrography data. Either line_id_column or rno_column must be specified. By default, None
- rno_columnstr
Column in data matching observation sites to reach numbers in the SFR network. By default, None.
- period_columnstr, optional
Column with modflow stress period for each inflow value, by default ‘per’, by default, ‘per’.
- data_columnstr, optional
Column with flow values, by default ‘Q_avg’
- one_inflow_per_pathbool, optional
Limit inflows to one per (headwater to outlet) routing path, choosing the inflow location that is furthest downstream. By default, False.
- distribute_flows_to_reachesbool, optional
Not implemented yet for MODFLOW-2005.
- Returns:
- Updates the sfrdata.segment_data DataFrame.
- sfrmaker.flows.get_inflow_locations_from_parent_model(parent_reach_data, inset_reach_data, inset_grid, active_area=None)[source]¶
Get places in an inset model SFR network where the parent SFR network crosses the inset model boundary, using common line ID numbers from parent and inset reach datasets. MF2005 or MF6 supported; if either dataset contains only reach numbers (is MODFLOW-6), the reach numbers are used as segment numbers, with each segment only having one reach.
- Parameters:
- parent_reach_datastr (filepath) or DataFrame
SFR reach data for parent model. Must include columns: line_id : int; unique identifier for hydrography line that each reach is based on rno : int; unique identifier for each reach. Optional if iseg and ireach columns are included. iseg : int; unique identifier for each segment. Optional if rno is included. ireach : int; unique identifier for each reach. Optional if rno is included. geometry : shapely.geometry object representing location of each reach
- inset_reach_datastr (filepath) or DataFrame
SFR reach data for inset model. Same columns as parent_reach_data, except a geometry column isn’t needed. line_id values must correspond to same source hydrography as those in parent_reach_data.
- inset_gridflopy.discretization.StructuredGrid instance describing model grid
Must be in same coordinate system as geometries in parent_reach_data. Required only if active_area is None.
- active_areashapely.geometry.Polygon object
Describes the area of the inset model where SFR is applied. Used to find inset reaches from parent model. Must be in same coordinate system as geometries in parent_reach_data. Required only if inset_grid is None.
- Returns:
- locationsDataFrame
Columns: parent_segment : parent model segment parent_reach : parent model reach parent_rno : parent model reach number line_id : unique identifier for hydrography line that each reach is based on
- sfrmaker.flows.get_inflows_from_parent_model(parent_reach_data, inset_reach_data, mf2005_parent_sfr_outputfile, mf6_parent_sfr_budget_file, inset_grid, active_area=None)[source]¶
Get places in an inset model SFR network where the parent SFR network crosses the inset model boundary, using common line ID numbers from parent and inset reach datasets. MF2005 or MF6 supported; if either dataset contains only reach numbers (is MODFLOW-6), the reach numbers are used as segment numbers, with each segment only having one reach.
- Parameters:
- parent_reach_datastr (filepath) or DataFrame
SFR reach data for parent model. Must include columns: line_id : int; unique identifier for hydrography line that each reach is based on rno : int; unique identifier for each reach. Optional if iseg and ireach columns are included. iseg : int; unique identifier for each segment. Optional if rno is included. ireach : int; unique identifier for each reach. Optional if rno is included. geometry : shapely.geometry object representing location of each reach
- inset_reach_datastr (filepath) or DataFrame
SFR reach data for inset model. Same columns as parent_reach_data, except a geometry column isn’t needed. line_id values must correspond to same source hydrography as those in parent_reach_data.
- mf2005_parent_sfr_outputfilestr (filepath)
Modflow-2005 style SFR text file budget output.
- mf6_parent_sfr_budget_filestr (filepath)
Modflow-6 style SFR binary budget output
- inset_gridflopy.discretization.StructuredGrid instance describing model grid
Must be in same coordinate system as geometries in parent_reach_data. Required only if active_area is None.
- active_areashapely.geometry.Polygon object
Describes the area of the inset model where SFR is applied. Used to find inset reaches from parent model. Must be in same coordinate system as geometries in parent_reach_data. Required only if inset_grid is None.
- Returns:
- inflowsDataFrame
Columns: parent_segment : parent model segment parent_reach : parent model reach parent_rno : parent model reach number line_id : unique identifier for hydrography line that each reach is based on