flopy.mt3d.mt Module

class flopy.mt3d.mt.Mt3dList(model, extension='list', listunit=7)

List package class

check(f=None, verbose=True, level=1)

Check package data for common errors.

Parameters:

f : str or file handle

String defining file name or file handle for summary file of check method output. If a sting is passed a file handle is created. If f is None, check method does not write results to a summary file. (default is None)

verbose : bool

Boolean flag used to determine if check method results are written to the screen

level : int

Check method analysis level. If level=0, summary checks are performed. If level=1, full checks are performed.

Returns:

None

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow.load('model.nam')
>>> m.dis.check()
load(model, pack_type, f, nper=None, pop_key_list=None, check=True, unitnumber=None, ext_unit_dict=None)

The load method has not been implemented for this package.

plot(**kwargs)

Plot 2-D, 3-D, transient 2-D, and stress period list (MfList) package input data

Parameters:

**kwargs : dict

filename_base
: str

Base file name that will be used to automatically generate file names for output image files. Plots will be exported as image files if file_name_base is not None. (default is None)

file_extension
: str

Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is ‘png’)

mflay
: int

MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None)

kper
: int

MODFLOW zero-based stress period number to return. (default is zero)

key
: str

MfList dictionary key. (default is None)

Returns:

axes : list

Empty list is returned if filename_base is not None. Otherwise a list of matplotlib.pyplot.axis are returned.

Examples

>>> import flopy
>>> ml = flopy.modflow.Modflow.load('test.nam')
>>> ml.dis.plot()
to_shapefile(filename, **kwargs)

Export 2-D, 3-D, and transient 2-D model data to shapefile (polygons). Adds an attribute for each layer in each data array

Parameters:

filename : str

Shapefile name to write

Returns:

None

Examples

>>> import flopy
>>> ml = flopy.modflow.Modflow.load('test.nam')
>>> ml.lpf.to_shapefile('test_hk.shp')
class flopy.mt3d.mt.Mt3dms(modelname='mt3dtest', namefile_ext='nam', modflowmodel=None, ftlfilename=None, ftlfree=False, version='mt3dms', exe_name='mt3dms.exe', structured=True, listunit=None, ftlunit=None, model_ws='.', external_path=None, verbose=False, load=True, silent=0)

MT3DMS Model Class.

Parameters:

modelname : string, optional

Name of model. This string will be used to name the MODFLOW input that are created with write_model. (the default is ‘mt3dtest’)

namefile_ext : string, optional

Extension for the namefile (the default is ‘nam’)

modflowmodel : flopy.modflow.mf.Modflow

This is a flopy Modflow model object upon which this Mt3dms model is based. (the default is None)

version : string, optional

Version of MT3DMS to use (the default is ‘mt3dms’).

exe_name : string, optional

The name of the executable to use (the default is ‘mt3dms.exe’).

listunit : integer, optional

Unit number for the list file (the default is 2).

model_ws : string, optional

model workspace. Directory name to create model data sets. (default is the present working directory).

external_path : string

Location for external files (default is None).

verbose : boolean, optional

Print additional information to the screen (default is False).

load : boolean, optional

(default is True).

silent : integer

(default is 0)

Examples

>>> import flopy
>>> m = flopy.mt3d.mt.Mt3dms()
add_existing_package(filename, ptype=None, copy_to_model_ws=True)

add an existing package to a model instance. Parameters ———- filename : str

the name of the file to add as a package
ptype
: optional
the model package type (e.g. “lpf”, “wel”, etc). If None, then the file extension of the filename arg is used
copy_to_model_ws
: bool
flag to copy the package file into the model_ws directory.
add_external(fname, unit, binflag=False, output=False)

Assign an external array so that it will be listed as a DATA or DATA(BINARY) entry in the name file. This will allow an outside file package to refer to it.

Parameters:

fname : str

filename of external array

unit : int

unit number of external array

binflag : boolean

binary or not. (default is False)

add_output(fname, unit, binflag=False, package=None)

Assign an external array so that it will be listed as a DATA or DATA(BINARY) entry in the name file. This will allow an outside file package to refer to it.

Parameters:

fname : str

filename of external array

unit : int

unit number of external array

binflag : boolean

binary or not. (default is False)

add_output_file(unit, fname=None, extension='cbc', binflag=True, package=None)

Add an ascii or binary output file file for a package

Parameters:

unit : int

unit number of external array

fname : str

filename of external array. (default is None)

extension : str

extension to use for the cell-by-cell file. Only used if fname is None. (default is cbc)

binflag : bool

boolean flag indicating if the output file is a binary file. Default is True

package : str

string that defines the package the output file is attached to. Default is None

add_package(p)

Add a package.

Parameters:p : Package object
add_pop_key_list(key)

Add a external file unit number to a list that will be used to remove model output (typically binary) files from ext_unit_dict.

Parameters:

key : int

file unit number

change_model_ws(new_pth=None, reset_external=False)

Change the model work space.

Parameters:

new_pth : str

Location of new model workspace. If this path does not exist, it will be created. (default is None, which will be assigned to the present working directory).

Returns:

val : list of strings

Can be used to see what packages are in the model, and can then be used with get_package to pull out individual packages.

check(f=None, verbose=True, level=1)

Check model data for common errors.

Parameters:

f : str or file handle

String defining file name or file handle for summary file of check method output. If a string is passed a file handle is created. If f is None, check method does not write results to a summary file. (default is None)

verbose : bool

Boolean flag used to determine if check method results are written to the screen

level : int

Check method analysis level. If level=0, summary checks are performed. If level=1, full checks are performed.

Returns:

None

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow.load('model.nam')
>>> m.check()
get_name_file_entries()

Get a string representation of the name file.

get_output(fname=None, unit=None)

Get an output file from the model by specifying either the file name or the unit number.

Parameters:

fname : str

filename of output array

unit : int

unit number of output array

get_output_attribute(fname=None, unit=None, attr=None)

Get a attribute for an output file from the model by specifying either the file name or the unit number.

Parameters:

fname : str

filename of output array

unit : int

unit number of output array

get_package(name)

Get a package.

Parameters:

name : str

Name of the package, ‘RIV’, ‘LPF’, etc.

Returns:

pp : Package object

Package object of type flopy.pakbase.Package

get_package_list()

Get a list of all the package names.

Returns:

val : list of strings

Can be used to see what packages are in the model, and can then be used with get_package to pull out individual packages.

static load(f, version='mt3dms', exe_name='mt3dms.exe', verbose=False, model_ws='.', load_only=None, forgive=False, modflowmodel=None)

Load an existing model.

Parameters:

f : string

Full path and name of MT3D name file.

version : string

The version of MT3D (mt3dms, or mt3d-usgs) (default is mt3dms)

exe_name : string

The name of the executable to use if this loaded model is run. (default is mt3dms.exe)

verbose : bool

Write information on the load process if True. (default is False)

model_ws : string

The path for the model workspace. (default is the current working directory ‘.’)

load_only : list of strings

Filetype(s) to load (e.g. [‘btn’, ‘adv’]) (default is None, which means that all will be loaded)

modflowmodel : flopy.modflow.mf.Modflow

This is a flopy Modflow model object upon which this Mt3dms model is based. (the default is None)

Returns:

mt : flopy.mt3d.mt.Mt3dms

flopy Mt3d model object

Notes

The load method does not retain the name for the MODFLOW-generated FTL file. This can be added manually after the MT3D model has been loaded. The syntax for doing this manually is mt.ftlfilename = ‘example.ftl’

Examples

>>> import flopy
>>> f = 'example.nam'
>>> mt = flopy.mt3d.mt.Mt3dms.load(f)
>>> mt.ftlfilename = 'example.ftl'
static load_mas(fname)

Load an mt3d mas file and return a numpy recarray

Parameters:

fname : str

name of MT3D mas file

Returns:

r : np.ndarray

static load_obs(fname)

Load an mt3d obs file and return a numpy recarray

Parameters:

fname : str

name of MT3D obs file

Returns:

r : np.ndarray

name

Get model name

Returns:

name : str

name of model

next_ext_unit()

Function to encapsulate next_ext_unit attribute

plot(SelPackList=None, **kwargs)

Plot 2-D, 3-D, transient 2-D, and stress period list (MfList) model input data

Parameters:

SelPackList : bool or list

List of of packages to plot. If SelPackList=None all packages are plotted. (default is None)

**kwargs : dict

filename_base
: str

Base file name that will be used to automatically generate file names for output image files. Plots will be exported as image files if file_name_base is not None. (default is None)

file_extension
: str

Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is ‘png’)

mflay
: int

MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None)

kper
: int

MODFLOW zero-based stress period number to return. (default is zero)

key
: str

MfList dictionary key. (default is None)

Returns:

axes : list

Empty list is returned if filename_base is not None. Otherwise a list of matplotlib.pyplot.axis are returned.

Examples

>>> import flopy
>>> ml = flopy.modflow.Modflow.load('test.nam')
>>> ml.plot()
remove_external(fname=None, unit=None)

Remove an external file from the model by specifying either the file name or the unit number.

Parameters:

fname : str

filename of external array

unit : int

unit number of external array

remove_output(fname=None, unit=None)

Remove an output file from the model by specifying either the file name or the unit number.

Parameters:

fname : str

filename of output array

unit : int

unit number of output array

remove_package(pname)

Remove a package from this model

Parameters:

pname : string

Name of the package, such as ‘RIV’, ‘BAS6’, etc.

run_model(silent=False, pause=False, report=False, normal_msg='normal termination')

This method will run the model using subprocess.Popen.

Parameters:

silent : boolean

Echo run information to screen (default is True).

pause : boolean, optional

Pause upon completion (default is False).

report : boolean, optional

Save stdout lines to a list (buff) which is returned by the method . (default is False).

normal_msg : str

Normal termination message used to determine if the run terminated normally. (default is ‘normal termination’)

Returns:

(success, buff)

success : boolean

buff : list of lines of stdout

set_output_attribute(fname=None, unit=None, attr=None)

Set a variable in an output file from the model by specifying either the file name or the unit number and a dictionary with attributes to change.

Parameters:

fname : str

filename of output array

unit : int

unit number of output array

to_shapefile(filename, package_names=None, **kwargs)

Wrapper function for writing a shapefile for the model grid. If package_names is not None, then search through the requested packages looking for arrays that can be added to the shapefile as attributes

Parameters:

filename : string

name of the shapefile to write

package_names : list of package names (e.g. [“dis”,”lpf”])

Packages to export data arrays to shapefile. (default is None)

Returns:

None

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> m.to_shapefile('model.shp', SelPackList)
write_input(SelPackList=False, check=False)

Write the input.

Parameters:SelPackList : False or list of packages
write_name_file()

Write the name file.