flopy.utils.util_list Module

util_list module. Contains the mflist class.

This classes encapsulates modflow-style list inputs away from the individual packages. The end-user should not need to instantiate this class directly.

some more info
class flopy.utils.util_list.MfList(package, data=None, dtype=None, model=None, list_free_format=None)

a generic object for handling transient boundary condition lists

Parameters:

package : package object

The package object (of type flopy.pakbase.Package) to which this MfList will be added.

data : varies

the data of the transient list (optional). (the default is None)

Attributes

mxact (int) the max number of active bc for any stress period

Methods

add_record(kper,index,value) (None) add a record to stress period kper at index location
write_transient(f) (None) write the transient sequence to the model input file f
check_kij() (None) checks for boundaries outside of model domain - issues warnings only
append(other)

append the recarrays from one MfList to another Parameters ———-

other: variable: an item that can be cast in to an MfList
that corresponds with self
dict of {kper:recarray}
drop(fields)

drop fields from an MfList

Parameters:fields : list or set of field names to drop
Returns:dropped : MfList without the dropped fields
classmethod from_4d(model, pak_name, m4ds)

construct an MfList instance from a dict of (attribute_name,masked 4D ndarray Parameters ———-

model : mbase dervied type pak_name : str package name (e.g GHB) m4ds : {attibute name:4d masked numpy.ndarray}
MfList instance
get_indices()

a helper function for plotting - get all unique indices

static masked4D_arrays_to_stress_period_data(dtype, m4ds)
convert a dictionary of 4-dim masked arrays to
a stress_period_data style dict of recarray

dtype : numpy dtype

m4ds : dict {name:masked numpy 4-dim ndarray}

dict {kper:recarray}
plot(key=None, names=None, kper=0, filename_base=None, file_extension=None, mflay=None, **kwargs)

Plot stress period boundary condition (MfList) data for a specified stress period

Parameters:

key : str

MfList dictionary key. (default is None)

names : list

List of names for figure titles. (default is None)

kper : int

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

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)

**kwargs : dict

axes
: list of matplotlib.pyplot.axis

List of matplotlib.pyplot.axis that will be used to plot data for each layer. If axes=None axes will be generated. (default is None)

pcolor
: bool

Boolean used to determine if matplotlib.pyplot.pcolormesh plot will be plotted. (default is True)

colorbar
: bool

Boolean used to determine if a color bar will be added to the matplotlib.pyplot.pcolormesh. Only used if pcolor=True. (default is False)

inactive
: bool

Boolean used to determine if a black overlay in inactive cells in a layer will be displayed. (default is True)

contour
: bool

Boolean used to determine if matplotlib.pyplot.contour plot will be plotted. (default is False)

clabel
: bool

Boolean used to determine if matplotlib.pyplot.clabel will be plotted. Only used if contour=True. (default is False)

grid
: bool

Boolean used to determine if the model grid will be plotted on the figure. (default is False)

masked_values
: list

List of unique values to be excluded from the plot.

Returns:

out : list

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

Examples

>>> import flopy
>>> ml = flopy.modflow.Modflow.load('test.nam')
>>> ml.wel.stress_period_data.plot(ml.wel, kper=1)
to_array(kper=0, mask=False)

Convert stress period boundary condition (MfList) data for a specified stress period to a 3-D numpy array

Parameters:

kper : int

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

mask : boolean

return array with np.NaN instead of zero

Returns

———-

out : dict of numpy.ndarrays

Dictionary of 3-D numpy arrays containing the stress period data for a selected stress period. The dictonary keys are the MfList dtype names for the stress period data (‘cond’, ‘flux’, ‘bhead’, etc.).

Examples

>>> import flopy
>>> ml = flopy.modflow.Modflow.load('test.nam')
>>> v = ml.wel.stress_period_data.to_array(kper=1)
to_shapefile(filename, kper=None)

Export stress period boundary condition (MfList) data for a specified stress period

Parameters:

filename : str

Shapefile name to write

kper : int

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

Returns:

None

Examples

>>> import flopy
>>> ml = flopy.modflow.Modflow.load('test.nam')
>>> ml.wel.to_shapefile('test_hk.shp', kper=1)