flopy.mf6.data.mfdatalist module
- class MFList(sim_data, model_or_sim, structure, data=None, enable=True, path=None, dimensions=None, package=None, block=None)[source]
Bases:
MFMultiDimVar
,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.
- 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.
- property data_type
Type of data (DataType) stored in the list
- property 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)[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:
- get_record()[source]
Returns the list’s data and metadata in a dictionary. Data is in key “data” and metadata in keys “filename” and “binary”.
- Returns:
data_record
- Return type:
- 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.
- property 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) –
- axeslist 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)
- pcolorbool
Boolean used to determine if matplotlib.pyplot.pcolormesh plot will be plotted. (default is True)
- colorbarbool
Boolean used to determine if a color bar will be added to the matplotlib.pyplot.pcolormesh. Only used if pcolor=True. (default is False)
- inactivebool
Boolean used to determine if a black overlay in inactive cells in a layer will be displayed. (default is True)
- contourbool
Boolean used to determine if matplotlib.pyplot.contour plot will be plotted. (default is False)
- clabelbool
Boolean used to determine if matplotlib.pyplot.clabel will be plotted. Only used if contour=True. (default is False)
- gridbool
Boolean used to determine if the model grid will be plotted on the figure. (default is False)
- masked_valueslist
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:
- property 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.
- set_data(data, autofill=False, check_data=True)[source]
Sets the contents of the data to “data”. Data can have the following formats:
recarray - recarray containing the datalist
[(line_one), (line_two), …] - list where each line of the datalist is a tuple within the list
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})
- set_record(data_record, autofill=False, check_data=True)[source]
Sets the contents of the data and metadata to “data_record”. Data_record is a dictionary with has the following format:
{‘filename’:filename, ‘binary’:True/False, ‘data’=data}
To store to file include ‘filename’ in the dictionary.
- 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.
- 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:
- 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
- class MFMultipleList(sim_data, model_or_sim, structure, enable=True, path=None, dimensions=None, package=None, block=None)[source]
Bases:
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
- class MFTransientList(sim_data, model_or_sim, structure, enable=True, path=None, dimensions=None, package=None, block=None)[source]
Bases:
MFList
,MFTransient
,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.
- property data
Returns list data. Calls get_data with default parameters.
- property data_type
Type of data (DataType) stored in the list
- property dtype
Type of data (numpy.dtype) stored in the list
- get_file_entry(key=0, ext_file_action=ExtFileAction.copy_relative_paths)[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:
- get_record(key=None)[source]
Returns the data for stress period key. If no key is specified returns all records in a dictionary with zero-based stress period numbers as keys. See MFList’s get_record documentation for more information on the format of each record returned.
- has_data(key=None)[source]
Returns whether this MFList has any data associated with it in key “key”.
- 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
- property masked_4D_arrays
Returns list data as 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) –
- axeslist 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)
- pcolorbool
Boolean used to determine if matplotlib.pyplot.pcolormesh plot will be plotted. (default is True)
- colorbarbool
Boolean used to determine if a color bar will be added to the matplotlib.pyplot.pcolormesh. Only used if pcolor=True. (default is False)
- inactivebool
Boolean used to determine if a black overlay in inactive cells in a layer will be displayed. (default is True)
- contourbool
Boolean used to determine if matplotlib.pyplot.contour plot will be plotted. (default is False)
- clabelbool
Boolean used to determine if matplotlib.pyplot.clabel will be plotted. Only used if contour=True. (default is False)
- gridbool
Boolean used to determine if the model grid will be plotted on the figure. (default is False)
- masked_valueslist
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:
- 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 a recarray or list of tuples, it will be assigned to 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.
- set_record(data_record, autofill=False, check_data=True)[source]
Sets the contents of the data based on the contents of ‘data_record`.
- Parameters:
data_record (dict) – Data_record being set. Data_record must be a dictionary with keys as zero-based stress periods and values as dictionaries containing the data and metadata. See MFList’s set_record documentation for more information on the format of the values.
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.
- store_internal(check_data=True)[source]
Store all data internally.
- Parameters:
check_data (bool) – Verify data prior to storing