flopy.mf6.data.mfdataarray module
- class MFArray(sim_data, model_or_sim, structure, data=None, enable=True, path=None, dimensions=None, block=None)[source]
Bases:
MFMultiDimVar
Provides an interface for the user to access and update MODFLOW array data. MFArray objects are not designed to be directly constructed by the end user. When a FloPy for MODFLOW 6 package object is constructed, the appropriate MFArray 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
- property data
Returns array data. Calls get_data with default parameters.
- property data_type
Type of data (DataType) stored in the array
- property dtype
Type of data (numpy.dtype) stored in the array
- get_data(layer=None, apply_mult=False, **kwargs)[source]
Returns the data associated with layer “layer”. If “layer” is None, returns all data.
- Parameters:
layer (int) –
- Returns:
data – Array data in an ndarray
- Return type:
ndarray
- get_file_entry(layer=None, ext_file_action=ExtFileAction.copy_relative_paths)[source]
Returns a string containing the data in layer “layer” formatted for a MODFLOW 6 file. For unlayered data do not pass in “layer”.
- Parameters:
layer (int) – The layer to return file entry for.
ext_file_action (ExtFileAction) – How to handle external paths.
- Returns:
file entry
- Return type:
- get_record(layer=None)[source]
Returns the data record associated with layer “layer”. If “layer” is None, returns all data.
- 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 is for internal flopy use and is not intended for the end user.
- Parameters:
first_line (str) – A string containing the first line of data in this array.
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
- Returns:
more data (bool,)
next data line (str)
- new_simulation(sim_data)[source]
Initialize MFArray object for a new simulation
- Parameters:
sim_data (MFSimulationData) – Data dictionary containing simulation data.
- plot(filename_base=None, file_extension=None, mflay=None, fignum=None, title=None, **kwargs)[source]
Plot 3-D model input data
- Parameters:
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 the array is plottable
- set_data(data, multiplier=None, layer=None)[source]
Sets the contents of the data at layer layer to data with multiplier multiplier. For unlayered data do not pass in layer. Data can have the following formats: 1) ndarray - numpy ndarray containing all of the data 2) [data] - python list containing all of the data 3) val - a single constant value to be used for all of the data
- set_layered_data(layered_data)[source]
Sets whether this MFArray supports layered data
- Parameters:
layered_data (bool) – Whether data is layered or not.
- set_record(data_record)[source]
Sets the contents of the data and metadata to the contents of ‘data_record`. For unlayered data do not pass in layer. For unlayered data ‘data_record’ is a dictionary with either of the following key/value pairs: 1) {‘filename’:filename, ‘factor’:fct, ‘iprn’:print, ‘data’:data} - dictionary defining external file information 2) {‘data’:data, ‘factor’:fct, ‘iprn’:print)}- dictionary defining internal information. Data that is layered can also be set by defining For layered data data_record must be a dictionary of dictionaries with zero-based layer numbers for the outer dictionary keys and the inner dictionary as described above:
- {0: {‘data’:data_lay_0, ‘factor’:fct_lay_0, ‘iprn’:prn_lay_0)},
1: {‘data’:data_lay_1, ‘factor’:fct_lay_1, ‘iprn’:prn_lay_1)}, 2: {‘data’:data_lay_2, ‘factor’:fct_lay_2, ‘iprn’:prn_lay_2)}}
- Parameters:
data_record (dict) – An dictionary of data record information or a dictionary of layers (keys) with a dictionary of data record information for each layer (values).
- store_as_external_file(external_file_path, layer=None, binary=False, replace_existing_external=True, check_data=True)[source]
Stores data from layer layer to an external file at external_file_path. For unlayered data do not pass in layer. If layer is not specified all layers will be stored with each layer as a separate 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
layer (int) – Which layer to store in external file, None value stores all layers.
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
- class MFTransientArray(sim_data, model_or_sim, structure, enable=True, path=None, dimensions=None, block=None)[source]
Bases:
MFArray
,MFTransient
Provides an interface for the user to access and update MODFLOW transient array data. MFTransientArray objects are not designed to be directly constructed by the end user. When a FloPy for MODFLOW 6 package object is constructed, the appropriate MFArray 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
Examples
- 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. This method is intended for internal library usage only.
- Parameters:
transient_key (int) – Zero-based stress period
- property data_type
Type of data (DataType) stored in the array
- get_data(key=None, apply_mult=True, **kwargs)[source]
Returns the data associated with stress period key key. If layer is None, returns all data for time key.
- get_file_entry(key=0, ext_file_action=ExtFileAction.copy_relative_paths)[source]
Returns a string containing the data in stress period “key”.
- Parameters:
key (int) – The stress period to return file entry for.
ext_file_action (ExtFileAction) – How to handle external paths.
- Returns:
file entry
- Return type:
- get_record(key=None)[source]
Returns the data record (data and metadata) associated with stress period key layer. If layer is None, returns all data for time layer.
- Parameters:
key (int) – Zero-based stress period of data to return
- 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 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 is for internal flopy use and is not intended to be called by the end user.
- Parameters:
first_line (str) – A string containing the first line of data in this array.
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
- Returns:
more data (bool,)
next data line (str)
- plot(kper=None, filename_base=None, file_extension=None, mflay=None, fignum=None, **kwargs)[source]
Plot transient array model input data
- Parameters:
transient2d (flopy.utils.util_array.Transient2D object) –
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’)
**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.
- kperstr
MODFLOW zero-based stress period number to return. If kper=’all’ then data for all stress period will be extracted. (default is zero).
- Returns:
axes – 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]
Removes a new transient time transient_key and any data stored at that time. This method is intended for internal library usage only.
- Parameters:
transient_key (int) – Zero-based stress period
- set_data(data, multiplier=None, layer=None, key=None)[source]
Sets the contents of the data at layer layer and time key to data with multiplier multiplier. For unlayered data do not pass in layer.
- Parameters:
data (dict, ndarray, 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 ndarray or list of lists, 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.
multiplier (int) – multiplier to apply to data
layer (int) – Layer of data being set. Keep default of None of data is not layered.
key (int) – Zero based stress period to assign data too. Does not apply if data is a dictionary.
- set_record(data_record)[source]
Sets data and metadata at layer layer and time key to data_record. For unlayered data do not pass in layer.
- Parameters:
data_record (dict) – Data record being set. Data must be a dictionary with keys as zero-based stress periods and values as a dictionary of data and metadata (factor, iprn, filename, binary, data) for a given stress period. How to define the dictionary of data and metadata is described in the MFData class’s set_record method.
- store_as_external_file(external_file_path, layer=None, binary=False, replace_existing_external=True, check_data=True)[source]
Stores data from layer layer to an external file at external_file_path. For unlayered data do not pass in layer. If layer is not specified all layers will be stored with each layer as a separate 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
layer (int) – Which layer to store in external file, None value stores all layers.
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