flopy.mf6.data.mfdatalist module

class MFList(sim_data, model_or_sim, structure, data=None, enable=True, path=None, dimensions=None, package=None)[source]

Bases: flopy.mf6.data.mfdata.MFMultiDimVar, flopy.datbase.DataListInterface

Provides an interface for the user to access and update MODFLOW list data. MFList objects are not designed to be directly constructed by the end user. When a flopy for MODFLOW 6 package object is constructed, the appropriate MFList objects are automatically built.

Parameters:
  • sim_data (MFSimulationData) – data contained in the simulation
  • structure (MFDataStructure) – describes the structure of the data
  • data (list or ndarray) – actual data
  • enable (bool) – enable/disable the array
  • path (tuple) – path in the data dictionary to this MFArray
  • dimensions (MFDataDimensions) – dimension information related to the model, package, and array
append_data(data)[source]

Appends “data” to the end of this list. Assumes data is in a format that can be appended directly to a numpy recarray.

Parameters:data (list(tuple)) – Data to append.
append_list_as_record(record)[source]

Appends the list record as a single record in this list’s recarray. Assumes “data” has the correct dimensions.

Parameters:record (list) – List to be appended as a single record to the data’s existing recarray.
data_type

Type of data (DataType) stored in the list

dtype

Type of data (numpy.dtype) stored in the list

get_data(apply_mult=False, **kwargs)[source]

Returns the list’s data.

Parameters:apply_mult (bool) – Whether to apply a multiplier.
Returns:data
Return type:recarray
get_file_entry(ext_file_action=<ExtFileAction.copy_relative_paths: 3>)[source]

Returns a string containing the data formatted for a MODFLOW 6 file.

Parameters:ext_file_action (ExtFileAction) – How to handle external paths.
Returns:file entry
Return type:str
has_data()[source]

Returns whether this MFList has any data associated with it.

load(first_line, file_handle, block_header, pre_data_comments=None, external_file_info=None)[source]

Loads data from first_line (the first line of data) and open file file_handle which is pointing to the second line of data. Returns a tuple with the first item indicating whether all data was read and the second item being the last line of text read from the file. This method was only designed for internal FloPy use and is not recommended for end users.

Parameters:
  • first_line (str) – A string containing the first line of data in this list.
  • file_handle (file descriptor) – A file handle for the data file which points to the second line of data for this list
  • block_header (MFBlockHeader) – Block header object that contains block header information for the block containing this data
  • pre_data_comments (MFComment) – Comments immediately prior to the data
  • external_file_info (list) – Contains information about storing files externally
Returns:

  • more data (bool,)
  • next data line (str)

new_simulation(sim_data)[source]

Initialize MFList object for a new simulation.

Parameters:sim_data (MFSimulationData) – Simulation data object for the simulation containing this data.
package

Package object that this data belongs to.

plot(key=None, names=None, filename_base=None, file_extension=None, mflay=None, **kwargs)[source]

Plot boundary condition (MfList) data

Parameters:
  • key (str) – MfList dictionary key. (default is None)
  • names (list) – List of names for figure titles. (default is None)
  • 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 – Empty list is returned if filename_base is not None. Otherwise a list of matplotlib.pyplot.axis is returned.

Return type:

list

plottable

If this list data is plottable

search_data(search_term, col=None)[source]

Searches the list data at column “col” for “search_term”. If col is None search_data searches the entire list.

Parameters:
  • search_term (str) – String to search for
  • col (int) – Column number to search
set_data(data, autofill=False, check_data=True)[source]

Sets the contents of the data to “data” with. Data can have the following formats:

  1. recarray - recarray containing the datalist
  2. [(line_one), (line_two), …] - list where each line of the datalist is a tuple within the list
  3. {‘filename’:filename, factor=fct, iprn=print_code, data=data} - dictionary defining the external file containing the datalist.

If the data is transient, a dictionary can be used to specify each stress period where the dictionary key is <stress period> - 1 and the dictionary value is the datalist data defined above: {0:ndarray, 1:[(line_one), (line_two), …], 2:{‘filename’:filename})

Parameters:
  • data (ndarray/list/dict) – Data to set
  • autofill (bool) – Automatically correct data
  • check_data (bool) – Whether to verify the data
store_as_external_file(external_file_path, binary=False, replace_existing_external=True, check_data=True)[source]

Store all data externally in file external_file_path. the binary allows storage in a binary file. If replace_existing_external is set to False, this method will not do anything if the data is already in an external file.

Parameters:
  • external_file_path (str) – Path to external file
  • binary (bool) – Store data in a binary file
  • replace_existing_external (bool) – Whether to replace an existing external file.
  • check_data (bool) – Verify data prior to storing
store_internal(check_data=True)[source]

Store all data internally.

Parameters:check_data (bool) – Verify data prior to storing
to_array(kper=0, mask=False)[source]

Convert stress period boundary condition (MFDataList) 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 (bool) – return array with np.NaN instead of zero
Returns:

out – Dictionary of 3-D numpy arrays containing the stress period data for a selected stress period. The dictionary keys are the MFDataList dtype names for the stress period data.

Return type:

dict of numpy.ndarrays

update_record(record, key_index)[source]

Updates a record at index “key_index” with the contents of “record”. If the index does not exist update_record appends the contents of “record” to this list’s recarray.

Parameters:
  • record (list) – New record to update data with
  • key_index (int) – Stress period key of record to update. Only used in transient data types.
class MFMultipleList(sim_data, model_or_sim, structure, enable=True, path=None, dimensions=None, package=None)[source]

Bases: flopy.mf6.data.mfdatalist.MFTransientList

Provides an interface for the user to access and update MODFLOW multiple list data. This is list data that is in the same format as the MFTransientList, but is not time based.

Parameters:
  • sim_data (MFSimulationData) – data contained in the simulation
  • structure (MFDataStructure) – describes the structure of the data
  • data (list or ndarray) – actual data
  • enable (bool) – enable/disable the array
  • path (tuple) – path in the data dictionary to this MFArray
  • dimensions (MFDataDimensions) – dimension information related to the model, package, and array
get_data(key=None, apply_mult=False, **kwargs)[source]

Returns the data for stress period key.

Parameters:
  • key (int) – Zero-based stress period to return data from.
  • apply_mult (bool) – Apply multiplier
Returns:

data

Return type:

ndarray

class MFTransientList(sim_data, model_or_sim, structure, enable=True, path=None, dimensions=None, package=None)[source]

Bases: flopy.mf6.data.mfdatalist.MFList, flopy.mf6.data.mfdata.MFTransient, flopy.datbase.DataListInterface

Provides an interface for the user to access and update MODFLOW transient list data.

Parameters:
  • sim_data (MFSimulationData) – data contained in the simulation
  • structure (MFDataStructure) – describes the structure of the data
  • data (list or ndarray) – actual data
  • enable (bool) – enable/disable the array
  • path (tuple) – path in the data dictionary to this MFArray
  • dimensions (MFDataDimensions) – dimension information related to the model, package, and array
add_transient_key(transient_key)[source]

Adds a new transient time allowing data for that time to be stored and retrieved using the key transient_key. Method is used internally by FloPy and is not intended to the end user.

Parameters:transient_key (int) – Zero-based stress period to add
append_list_as_record(record, key=0)[source]

Appends the list data as a single record in this list’s recarray at time key. Assumes data has the correct dimensions.

Parameters:
  • data (list) – Data to append
  • key (int) – Zero based stress period to append data too.
data

Returns list data. Calls get_data with default parameters.

data_type

Type of data (DataType) stored in the list

dtype

Type of data (numpy.dtype) stored in the list

get_data(key=None, apply_mult=False, **kwargs)[source]

Returns the data for stress period key.

Parameters:
  • key (int) – Zero-based stress period to return data from.
  • apply_mult (bool) – Apply multiplier
Returns:

data

Return type:

recarray

get_file_entry(key=0, ext_file_action=<ExtFileAction.copy_relative_paths: 3>)[source]

Returns a string containing the data at time key formatted for a MODFLOW 6 file.

Parameters:
  • key (int) – Zero based stress period to return data from.
  • ext_file_action (ExtFileAction) – How to handle external paths.
Returns:

file entry

Return type:

str

load(first_line, file_handle, block_header, pre_data_comments=None, external_file_info=None)[source]

Loads data from first_line (the first line of data) and open file file_handle which is pointing to the second line of data. Returns a tuple with the first item indicating whether all data was read and the second item being the last line of text read from the file.

Parameters:
  • first_line (str) – A string containing the first line of data in this list.
  • file_handle (file descriptor) – A file handle for the data file which points to the second line of data for this array
  • block_header (MFBlockHeader) – Block header object that contains block header information for the block containing this data
  • pre_data_comments (MFComment) – Comments immediately prior to the data
  • external_file_info (list) – Contains information about storing files externally
masked_4D_arrays

Returns list data as a masked 4D array.

masked_4D_arrays_itr()[source]

Returns list data as an iterator of a masked 4D array.

plot(key=None, names=None, kper=0, filename_base=None, file_extension=None, mflay=None, **kwargs)[source]

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 – Empty list is returned if filename_base is not None. Otherwise a list of matplotlib.pyplot.axis is returned.

Return type:

list

remove_transient_key(transient_key)[source]

Remove transient stress period key. Method is used internally by FloPy and is not intended to the end user.

set_data(data, key=None, autofill=False)[source]

Sets the contents of the data at time key to data.

Parameters:
  • data (dict, recarray, list) – Data being set. Data can be a dictionary with keys as zero-based stress periods and values as the data. If data is an recarray or list of tuples, it will be assigned to the the stress period specified in key. If any is set to None, that stress period of data will be removed.
  • key (int) – Zero based stress period to assign data too. Does not apply if data is a dictionary.
  • autofill (bool) – Automatically correct data.
store_as_external_file(external_file_path, binary=False, replace_existing_external=True, check_data=True)[source]

Store all data externally in file external_file_path. the binary allows storage in a binary file. If replace_existing_external is set to False, this method will not do anything if the data is already in an external file.

Parameters:
  • external_file_path (str) – Path to external file
  • binary (bool) – Store data in a binary file
  • replace_existing_external (bool) – Whether to replace an existing external file.
  • check_data (bool) – Verify data prior to storing
store_internal(check_data=True)[source]

Store all data internally.

Parameters:check_data (bool) – Verify data prior to storing
to_array(kper=0, mask=False)[source]

Returns list data as an array.

update_record(record, key_index, key=0)[source]

Updates a record at index key_index and time key with the contents of record. If the index does not exist update_record appends the contents of record to this list’s recarray.

Parameters:
  • record (list) – Record to append
  • key_index (int) – Index to update
  • key (int) – Zero based stress period to append data too