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:
flopy.mf6.data.mfdata.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_num”. If “layer_num” is None, returns all data.
- Parameters
layer_num (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
str
- has_data(layer=None)[source]¶
Returns whether layer “layer_num” has any data associated with it.
- Parameters
layer_num (int) – Layer number to check for data. For unlayered data do not pass anything in
- Returns
has data – Returns if there is data.
- Return type
bool
- 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
list
- 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 4) {‘filename’:filename, ‘factor’:fct, ‘iprn’:print, ‘data’:data} - dictionary defining external file information 5) {‘data’:data, ‘factor’:fct, ‘iprn’:print) - dictionary defining internal information. Data that is layered can also be set by defining a list with a length equal to the number of layers in the model. Each layer in the list contains the data as defined in the formats above:
[layer_1_val, [layer_2_array_vals], {‘filename’:file_with_layer_3_data, ‘factor’:fct, ‘iprn’:print}]
- Parameters
data (ndarray/list) – An ndarray or nested lists containing the data to set.
multiplier (float) – Multiplier to apply to data
layer (int) – Data layer that is being set
- set_layered_data(layered_data)[source]¶
Sets whether this MFArray supports layered data
- Parameters
layered_data (bool) – Whether data is layered or not.
- 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
- store_internal(layer=None, check_data=True)[source]¶
Stores data from layer layer internally. For unlayered data do not pass in layer. If layer is not specified all layers will be stored internally
- Parameters
layer (int) – Which layer to store in external file, None value stores all layers.
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:
flopy.mf6.data.mfdataarray.MFArray
,flopy.mf6.data.mfdata.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(layer=None, apply_mult=True, **kwargs)[source]¶
Returns the data associated with stress period key layer. If layer is None, returns all data for time layer.
- Parameters
layer (int) – Zero-based stress period of data to return
apply_mult (bool) – Whether to apply multiplier to data prior to returning it
- 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
str
- has_data(layer=None)[source]¶
Returns whether layer “layer_num” has any data associated with it.
- Parameters
layer_num (int) – Layer number to check for data. For unlayered data do not pass anything in
- Returns
has data – Returns if there is data.
- Return type
bool
- 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
list
- 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.
- 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
- store_internal(layer=None, check_data=True)[source]¶
Stores data from layer layer internally. For unlayered data do not pass in layer. If layer is not specified all layers will be stored internally.
- Parameters
layer (int) – Which layer to store internally file, None value stores all layers.
check_data (bool) – Verify data prior to storing