flopy.mf6.data.mfdatascalar module

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

Bases: MFData

Provides an interface for the user to access and update MODFLOW scalar data. MFScalar objects are not designed to be directly constructed by the end user. When a flopy for MODFLOW 6 package object is constructed, the appropriate MFScalar 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

add_one()[source]

Adds one if this is an integer scalar

property data

Returns the scalar data. Calls get_data with default parameters.

property data_type

Type of data (DataType) stored in the scalar

property dtype

The scalar’s numpy data type (numpy.dtype).

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

Returns the data associated with this object.

Parameters:

apply_mult (bool) – Parameter does not apply to scalar data.

Returns:

data

Return type:

str, int, float, recarray

get_file_entry(values_only=False, one_based=False, ext_file_action=ExtFileAction.copy_relative_paths)[source]

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

Parameters:
  • values_only (bool) – Return values only excluding keywords

  • one_based (bool) – Return one-based integer values

  • ext_file_action (ExtFileAction) – How to handle external paths.

Returns:

file entry

Return type:

str

has_data(key=None)[source]

Returns whether this object has 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.

  • file_handle (file descriptor) – A file handle for the data file which points to the second line of data

  • 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(filename_base=None, file_extension=None, **kwargs)[source]

Helper method to plot scalar objects

Parameters:
  • scalar – flopy.mf6.data.mfscalar 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’)

Returns:

list matplotlib.axes object

Return type:

axes

property plottable

If the scalar is plottable. Currently all scalars are not plottable.

set_data(data)[source]

Sets the contents of the data to data.

Parameters:

data (str/int/float/recarray/list) – Data to set

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

Bases: MFScalar, MFTransient

Provides an interface for the user to access and update MODFLOW transient scalar data. Transient scalar data is used internally by FloPy and should not be used directly by the end user.

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_one(key=0)[source]

Adds one to the data stored at key key. Method is used internally by FloPy and is not intended to the end user.

Parameters:

key (int) – Zero-based stress period to add

add_transient_key(key)[source]

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

Parameters:

key (int) – Zero-based stress period to add

property data_type

Type of data (DataType) stored in the scalar

get_data(key=0, **kwargs)[source]

Returns the data for stress period key.

Parameters:

key (int) – Zero-based stress period to return data from.

Returns:

data

Return type:

str/int/float/recarray

get_file_entry(key=None, 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:

str

has_data(key=None)[source]

Returns whether this object has 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.

Parameters:
  • first_line (str) – A string containing the first line of data in this scalar.

  • 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

plot(filename_base=None, file_extension=None, kper=0, fignum=None, **kwargs)[source]

Plot transient scalar model data

Parameters:
  • transientscalar (flopy.mf6.data.mfdatascalar.MFScalarTransient 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

property plottable

If the scalar is plottable

set_data(data, key=None)[source]

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

Parameters:
  • data (str/int/float/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 string, integer, double, 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.