flopy.mf6.mfpackage module
- class MFBlock(simulation_data, dimensions, structure, path, model_or_sim, container_package)[source]
Bases:
objectRepresents a block in a MF6 input file. This class is used internally by FloPy and use by users of the FloPy library is not recommended.
- Parameters:
simulation_data (MFSimulationData) – Data specific to this simulation
dimensions (MFDimensions) – Describes model dimensions including model grid and simulation time
structure (MFVariableStructure) – Structure describing block
path (tuple) – Unique path to block
- block_headers
Block header text (BEGIN/END), header variables, comments in the header
- Type:
- structure
Structure describing block
- Type:
- datasets
Dictionary of dataset objects with keys that are the name of the dataset
- Type:
OrderDict
- datasets_keyword
Dictionary of dataset objects with keys that are key words to identify start of dataset
- Type:
- data_factory(sim_data, model_or_sim, structure, enable, path, dimensions, data=None, package=None)[source]
Creates the appropriate data child object derived from MFData.
- is_allowed()[source]
Determine if block is valid based on the values of dependent MODFLOW variables.
- load(block_header, fd, strict=True)[source]
Loads block from file object. file object must be advanced to beginning of block before calling.
- Parameters:
block_header (MFBlockHeader) – Block header for block block being loaded.
fd (file) – File descriptor of file being loaded
strict (bool) – Enforce strict MODFLOW 6 file format.
- set_all_data_external(base_name, check_data=True, external_data_folder=None, binary=False, replace_existing=False)[source]
Sets the block’s list and array data to be stored externally, base_name is external file name’s prefix, check_data determines if data error checking is enabled during this process.
Warning
The MF6 check mechanism is deprecated pending reimplementation in a future release. While the checks API will remain in place through 3.x, it may be unstable, and will likely change in 4.x.
Note
External files are written immediately when this method is called, using the current value of max_columns_of_data and other formatting settings. If you need to change these settings, do so BEFORE calling this method. Changing settings afterward will not affect already-written external files unless you call this method again with replace_existing=True.
- Parameters:
base_name (str) – Base file name of external files where data will be written to.
check_data (bool) – Whether to do data error checking.
external_data_folder – Folder where external data will be stored
binary (bool) – Whether file will be stored as binary
replace_existing (bool) – Whether to replace existing external files. If True, existing external files will be rewritten with current settings (e.g., max_columns_of_data). If False, existing external files will not be rewritten. Default is False.
- set_all_data_internal(check_data=True)[source]
Sets the block’s list and array data to be stored internally, check_data determines if data error checking is enabled during this process.
Warning
The MF6 check mechanism is deprecated pending reimplementation in a future release. While the checks API will remain in place through 3.x, it may be unstable, and will likely change in 4.x.
- Parameters:
check_data (bool) – Whether to do data error checking.
- class MFBlockHeader(name, variable_strings, comment, simulation_data=None, path=None, block=None)[source]
Bases:
objectRepresents the header of a block in a MF6 input file. This class is used internally by FloPy and its direct use by a user of this library is not recommend.
- Parameters:
- build_header_variables(simulation_data, block_header_structure, block_path, data, dimensions)[source]
Builds data objects to hold header variables.
- connect_to_dict(simulation_data, path, comment=None)[source]
Add comment to the simulation dictionary
Writes block footer to file object fd.
- Parameters:
fd (file object) – File object to write block footer to.
- class MFChildPackages(model_or_sim, parent, pkg_type, filerecord, package=None, package_class=None)[source]
Bases:
objectBehind the scenes code for creating an interface to access child packages from a parent package. This class is automatically constructed by the FloPy library and is for internal library use only.
- class MFPackage(parent, package_type, filename=None, pname=None, loading_package=False, **kwargs)[source]
Bases:
PackageInterfaceProvides an interface for the user to specify data to build a package.
- Parameters:
parent (MFModel, MFSimulation, or MFPackage) – The parent model, simulation, or package containing this package.
package_type (str) – String defining the package type.
filename (str or PathLike, optional) – Name or path of file where this package is stored.
quoted_filename (str) – Filename with quotes around it when there is a space in the name
pname (str, optional) – Package name.
loading_package (bool, default False) – Whether or not to add this package to the parent container’s package list during initialization
**kwargs – Extra keyword arguments.
- structure
Describes the blocks and data contain in this package
- Type:
PackageStructure
- dimensions
Resolves data dimensions for data within this package
- Type:
PackageDimension
- build_child_package(pkg_type, data, parameter_name, filerecord)[source]
Builds a child package. This method is only intended for FloPy internal use.
- build_child_packages_container(pkg_type, filerecord)[source]
Builds a container object for any child packages. This method is only intended for FloPy internal use.
- build_mfdata(var_name, data=None)[source]
Returns the appropriate data type object (mfdatalist, mfdataarray, or mfdatascalar) given that object the appropriate structure (looked up based on var_name) and any data supplied. This method is for internal FloPy library use only.
- Parameters:
var_name (str) – Variable name
data (many supported types) – Data contained in this object
- Returns:
data object
- Return type:
MFData subclass
- check(f=None, verbose=True, level=1, checktype=None)[source]
Data check, returns True on success.
Warning
The MF6 check mechanism is deprecated pending reimplementation in a future release. While the checks API will remain in place through 3.x, it may be unstable, and will likely change in 4.x.
- create_package_dimensions()[source]
Creates a package dimensions object. For internal FloPy library use.
- Returns:
package dimensions
- Return type:
- property data_list
List of data in this package.
- export(f, **kwargs)[source]
Method to export a package to netcdf or shapefile based on the extension of the file name (.shp for shapefile, .nc for netcdf)
- Parameters:
f (str) – Filename
kwargs (keyword arguments) –
- modelgridflopy.discretization.Grid instance
User supplied modelgrid which can be used for exporting in lieu of the modelgrid associated with the model object
- Return type:
None or Netcdf object
- property filename
Package’s file name.
- get_package(name=None, type_only=False, name_only=False)[source]
Finds a package by package name, package key, package type, or partial package name. returns either a single package, a list of packages, or None.
- inspect_cells(cell_list, stress_period=None)[source]
Inspect model cells. Returns package data associated with cells.
- Parameters:
- Returns:
output – Array containing inspection results
- Return type:
array
- property name
Name of package
- property output
Method to get output associated with a specific package
- Return type:
MF6Output object
- property package_dict
Deprecated since version 3.9.
This method is for internal use only and will be deprecated.
- property package_filename_dict
Deprecated since version 3.9.
This method is for internal use only and will be deprecated.
- property package_key_dict
Deprecated since version 3.9.
This method is for internal use only and will be deprecated.
- property package_name_dict
Deprecated since version 3.9.
This method is for internal use only and will be deprecated.
- property package_names
Returns a list of package names.
Deprecated since version 3.9: This method is for internal use only and will be deprecated.
- property package_type
String describing type of package
- property package_type_dict
Deprecated since version 3.9.
This method is for internal use only and will be deprecated.
- property parent
Parent package
- plot(**kwargs)[source]
Plot 2-D, 3-D, transient 2-D, and stress period list (MfList) package input data
- Parameters:
**kwargs (dict) –
- filename_basestr
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_extensionstr
Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is ‘png’)
- mflayint
MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None)
- kperint
MODFLOW zero-based stress period number to return. (default is zero)
- keystr
MfList dictionary key. (default is None)
- Returns:
axes – Empty list is returned if filename_base is not None. Otherwise a list of matplotlib.pyplot.axis are returned.
- Return type:
- property plottable
If package is plottable
- property quoted_filename
Package’s file name with quotes if there is a space.
- set_all_data_external(check_data=True, external_data_folder=None, base_name=None, binary=False, replace_existing=False)[source]
Sets the package’s list and array data to be stored externally.
Note
External files are written immediately when this method is called, using the current value of max_columns_of_data and other formatting settings. If you need to change these settings, do so BEFORE calling this method. Changing settings afterward will not affect already-written external files unless you call this method again with replace_existing=True.
- Parameters:
check_data (bool) – Determine if data error checking is enabled
external_data_folder – Folder where external data will be stored
base_name (str) – Base file name prefix for all files
binary (bool) – Whether file will be stored as binary
replace_existing (bool) – Whether to replace existing external files. If True, existing external files will be rewritten with current settings (e.g., max_columns_of_data). If False, existing external files will not be rewritten. Default is False.
- set_all_data_internal(check_data=True)[source]
Sets the package’s list and array data to be stored internally.
- Parameters:
check_data (bool) – Determine if data error checking is enabled
- set_model_relative_path(model_ws)[source]
Sets the model path relative to the simulation’s path.
- Parameters:
model_ws (str) – Model path relative to the simulation’s path.
- to_geodataframe(gdf=None, kper=0, full_grid=True, shorten_attr=False, **kwargs)[source]
Method to create a GeoDataFrame from a modflow package
- Parameters:
gdf (GeoDataFrame) – optional geopandas geodataframe object to add data to. Default is None
kper (int) – stress period to get transient data from
full_grid (bool) – boolean flag for full grid dataframe construction. Default is True. If False, geodataframe will only include active cells
shorten_attr (bool) – method to truncate attribute names for shapefile restrictions
- Returns:
gdf
- Return type:
GeoDataFrame
- write(ext_file_action=ExtFileAction.copy_relative_paths)[source]
Writes the package to a file.
- Parameters:
ext_file_action (ExtFileAction) – How to handle pathing of external data files.