The MODFLOW-2005 to 6 Module

Code for converting MODFLOW-2005 style SFR Package input to MODFLOW-6 style SFR package input.

class sfrmaker.mf5to6.Mf6SFR(ModflowSfr2=None, SFRData=None, period_data=None, idomain=None, options=None, boundnames=True, modelgrid_type='structured')[source]

Bases: object

Class for writing MODFLOW-6 SFR package input from a (MODFLOW-2005 style) flopy.modflow.ModflowSfr2 instance or an sfrmaker.SFRData instance.

Parameters:
ModflowSfr2flopy.modflow.ModflowSfr2 instance, optional

Input SFR dataset

SFRDatasfrmaker.SFRData instance, optional

Input SFR dataset

period_dataDataFrame, optional

DataFrame of MODFLOW-6-style stress period data, as made by SFRData.add_to_perioddata(). Only needed if SFRData isn’t supplied, by default None

idomainndarray, optional

3D numpy array designating active cells (idomain==1). SFR reaches in inactive cells will be written with ‘none’ in the cellid field. by default None

optionslist, optional

List of strings to write to the MODFLOW-6 SFR options block. For example:

options=['save_flows',
            'BUDGET FILEOUT model.sfr.cbc',
            'STAGE FILEOUT model.sfr.stage.bin']

Unless specified, appropriate length_conversion and time_conversion values written by default. Alternatively, include ‘unit_conversion’ with the appropriate value here for compatibility with older versions of MODFLOW 6. See MODFLOW-6 documentation for other options. By default None.

boundnamesbool, optional

If true, add ‘boundnames’ to the options block and write hydrography line IDs to the packagedata block in the ‘boundname’ column, by default True.

cols = ['rno', 'cellid', 'k', 'i', 'j', 'rlen', 'rwid', 'rgrd', 'rtp', 'rbth', 'rhk', 'man', 'ncon', 'ustrf', 'ndv', 'idomain', 'boundname']
property connections
property graph_r
property length_conversion
mf5names = {'cellid': 'node', 'depth1': 'depth1', 'depth2': 'depth2', 'evaporation': 'etsw', 'inflow': 'flow', 'man': 'roughch', 'rainfall': 'pptsw', 'rbth': 'strthick', 'rgrd': 'slope', 'rhk': 'strhc1', 'rlen': 'rchlen', 'rno': 'rno', 'rtp': 'strtop', 'runoff': 'runoff'}
mf6names = {'depth1': 'depth1', 'depth2': 'depth2', 'etsw': 'evaporation', 'flow': 'inflow', 'node': 'cellid', 'pptsw': 'rainfall', 'rchlen': 'rlen', 'rno': 'rno', 'roughch': 'man', 'runoff': 'runoff', 'slope': 'rgrd', 'strhc1': 'rhk', 'strthick': 'rbth', 'strtop': 'rtp'}
property modelgrid_type
property options_block
property packagedata
property period_data
property time_conversion
write_file(filename=None, outpath='', options=None, external_files_path=None, write_mf6_inactive_cellids_as_None=False)[source]

Write a MODFLOW-6 format SFR package file.

Parameters:
filenamestr, optional

SFR package filename. Default setting is to use the ModflowSfr2.file_name attribute for the ModflowSfr2 instance entered on init of the Mf6SFR class, by default None.

outpathstr, optional

Path to write sfr file (with ModflowSfr2.file_name) to. Usually this is the simulation workspace. Only used if filename is None.

optionslist, optional

List of strings to write to the MODFLOW-6 SFR options block. For example:

options=['save_flows',
         'BUDGET FILEOUT model.sfr.cbc',
         'STAGE FILEOUT model.sfr.stage.bin']

Unless specified, appropriate length_conversion and time_conversion values written by default. Alternatively, include ‘unit_conversion’ with the appropriate value here for compatibility with older versions of MODFLOW 6. See MODFLOW-6 documentation for other options. By default None.

external_files_pathstr, optional

Path for writing an external file for packagedata, relative to the location of the SFR package file. If specified, an open/close statement referencing the file is written to the packagedata block. By default, None (packagedata table is written to the SFR package file)

write_mf6_inactive_cellids_as_Nonebool

Prior to MODFLOW 6.4.3, groundwater flow connections for SFR reaches in inactive cells were written as ‘NONE’. Since then, unconnected reaches are specified with a zero for each grid dimension (e.g. ‘0 0 0’ for DIS grid). This option allows ‘NONE’ to be written for compatibility with older versions of MODFLOW 6. By default, False (use 0s).

Raises:
OSError

If an invalid external_files_path is specified.

sfrmaker.mf5to6.cellids_to_kij(cellids, drop_inactive=True)[source]

Unpack tuples of MODFLOW-6 cellids (k, i, j) to lists of k, i, j values; ignoring instances where cellid is None (unconnected cells).

Parameters:
cellidssequence of (k, i, j) tuples
drop_inactivebool

If True, drop cellids == ‘none’. If False, distribute these to k, i, j.

Returns:
k, i, j1D numpy arrays of integers
class sfrmaker.mf5to6.mf6sfr(*args, **kwargs)[source]

Bases: Mf6SFR

sfrmaker.mf5to6.segment_data_to_period_data(segment_data, reach_data)[source]

Convert modflow-2005 style segment data to modflow-6 period data.