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]
get_entries_from_namefile(path: str | PathLike, ftype: str | None = None, unit: int | None = None, extension: str | None = None) List[Tuple][source]

Get entries from an MF6 namefile. Can select using FTYPE, UNIT, or file extension. This function only supports MF6 namefiles.

Parameters:
  • path (str or PathLike) – path to a MODFLOW-based model name file

  • ftype (str) – package type

  • unit (int) – file unit number

  • extension (str) – file extension

Returns:

entries – list of tuples containing FTYPE, UNIT, FNAME, STATUS for each namefile entry that meets a user-specified value.

Return type:

list of tuples

get_input_files(namefile)[source]

Return a list of all the input files in this model. :param namefile: path to a MODFLOW-based model name file :type namefile: str

Returns:

filelist – list of MODFLOW-based model input files

Return type:

list

get_mf6_blockdata(f, blockstr)[source]

Return list with all non comments between start and end of block specified by blockstr. :param f: open file object :type f: file object :param blockstr: name of block to search :type blockstr: str

Returns:

data – list of data in specified block

Return type:

list

get_mf6_files(mfnamefile)[source]

Return a list of all the MODFLOW 6 input and output files in this model. :param mfnamefile: path to the MODFLOW 6 simulation name file :type mfnamefile: str

Returns:

  • filelist (list) – list of MODFLOW 6 input files in a simulation

  • outplist (list) – list of MODFLOW 6 output files in a simulation

get_mf6_ftypes(namefile, ftypekeys)[source]

Return a list of FTYPES that are in the name file and in ftypekeys. :param namefile: path to a MODFLOW 6 name file :type namefile: str :param ftypekeys: list of desired FTYPEs :type ftypekeys: list

Returns:

ftypes – list of FTYPES that match ftypekeys in namefile

Return type:

list

get_mf6_mshape(disfile)[source]

Return the shape of the MODFLOW 6 model. :param disfile: path to a MODFLOW 6 discretization file :type disfile: str

Returns:

mshape – tuple with the shape of the MODFLOW 6 model.

Return type:

tuple

get_mf6_nper(tdisfile)[source]

Return the number of stress periods in the MODFLOW 6 model. :param tdisfile: path to the TDIS file :type tdisfile: str

Returns:

nper – number of stress periods in the simulation

Return type:

int

get_sim_name(namefiles, rootpth=None)[source]

Get simulation name. :param namefiles: path(s) to MODFLOW-based model name files :type namefiles: str or list of strings :param rootpth: optional root directory path (default is None) :type rootpth: str

Returns:

simname – list of namefiles without the file extension

Return type:

list

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 or Path) – 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: