flopy.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 NamData(pkgtype, name, handle, packages)[source]

Bases: object

MODFLOW Namefile Class.

Parameters
  • pkgtype (string) – 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.

  • name (string) – Filename of the package file identified in the name file

  • handle (file handle) – File handle referring to the file identified by name

  • packages (dictionary) – Dictionary of package objects as defined in the mfnam_packages attribute of flopy.modflow.mf.Modflow.

filehandle

File handle to the package file. Read from handle.

Type

file handle

filename

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

Type

string

filetype

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

Type

string

package

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

Type

string

Notes

Examples

attribs_from_namfile_header(namefile)[source]
getfiletypeunit(nf, filetype)[source]

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

Parameters
  • nf (NamData instance) –

  • filetype (string, name of package seeking information for) –

Returns

cunit

Return type

int, unit number corresponding to the package type

parsenamefile(namfilename, packages, verbose=True)[source]

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

Parameters
  • namefilename (str) – Name of the MODFLOW namefile to parse.

  • packages (dict) – Dictionary of package objects as defined in the mfnam_packages attribute of flopy.modflow.mf.Modflow.

  • verbose (bool) – Print messages to screen. Default is True.

Returns

For each file listed in the name file, a flopy.utils.mfreadnam.NamData instance is stored in the returned dict keyed by unit number.

Return type

dict

Raises
  • FileNotFoundError – If namfilename does not exist in the directory.

  • ValueError – For lines that cannot be parsed.