gsflow.utils.mfreadnam Module

mfreadnam module. Contains the NamData class. Note that the user can access the NamData class as flopy.modflow.NamData.

Additional information about the MODFLOW name file can be found at the Online MODFLOW Guide.

class gsflow.utils.mfreadnam.NamData(pkgtype, name, handle, packages)[source]

Child class of the MODFLOW Namefile Class.

Parameters
pkgtypestring

String identifying the type of MODFLOW package. See the mfnam_packages dictionary keys in the model object for a list of supported packages. This dictionary is also passed in as packages.

namestring

Filename of the package file identified in the name file

handlefile handle

File handle referring to the file identified by name

packagesdictionary

Dictionary of package objects as defined in the mfnam_packages attribute of flopy.modflow.mf.Modflow.

Attributes
filehandlefile handle

File handle to the package file. Read from handle.

filenamestring

Filename of the package file identified in the name file. Read from name.

filetypestring

String identifying the type of MODFLOW package. Read from pkgtype.

packagestring

Package type. Only assigned if pkgtype is found in the keys of packages

gsflow.utils.mfreadnam.getfiletypeunit(nf, filetype)[source]

Method to return unit number of a package from a NamData instance

Parameters
nfNamData instance
filetypestring, name of package seeking information for
Returns
cunitint, unit number corresponding to the package type
gsflow.utils.mfreadnam.parsenamefile(namfilename, packages, control_file=None, verbose=True, model_ws='.')[source]

Returns dict from the nam file with NamData keyed by unit number

Parameters
namfilenamestr

Name of the MODFLOW namefile to parse.

packagesdict

Dictionary of package objects as defined in the mfnam_packages attribute of flopy.modflow.mf.Modflow.

control_filestr

gsflow option for creating absolute paths to read the nam file

verbosebool

Print messages to screen. Default is True.

Returns
dict or OrderedDict

For each file listed in the name file, a flopy.utils.mfreadnam.NamData instance is stored in the returned dict keyed by unit number. Prior to Python version 3.6 the return object is an OrderedDict to retain the order of items in the nam file.

Raises
IOError:

If namfilename does not exist in the directory.

ValueError:

For lines that cannot be parsed.