MFsetupMixin class
- class mfsetup.mfmodel.MFsetupMixin(parent)[source]
Bases:
object
Mixin class for shared functionality between MF6model and MFnwtModel. Meant to be inherited by both those classes and not be called directly.
https://stackoverflow.com/questions/533631/what-is-a-mixin-and-why-are-they-useful
- get_boundary_cells(exclude_inactive=False)[source]
Get the i, j locations of cells along the model perimeter.
- Returns:
- k, i, j1D numpy arrays of ints
zero-based layer, row, column locations of boundary cells
- property high_k_lake_recharge
Recharge value to apply to high-K lakes, in model units.
- property interp_weights
For a given parent, only calculate interpolation weights once to speed up re-gridding of arrays to pfl_nwt.
- property isbc
3D array indicating which cells have a lake in each layer. -1 : well 0 : no lake 1 : lak package lake (lakarr > 0) 2 : high-k lake 3 : ghb 4 : sfr 5 : riv
see also the .bc_numbers attibute
- property lakarr
3-D array of lake extents in each layer. Non-zero values correspond to lak package IDs. Extent of lake in each layer is based on bathymetry and model layer thickness.
- property lake_bathymetry
Put lake bathymetry setup logic here instead of DIS package.
- classmethod load_cfg(yamlfile, verbose=False)[source]
Loads a configuration file, with default settings specific to the MFnwtModel or MF6model class.
- Parameters:
- yamlfilestr (filepath)
Configuration file in YAML format with pfl_nwt setup information.
- verbosebool
- Returns:
- cfgdict (configuration dictionary)
- load_features(filename, bbox_filter=None, id_column=None, include_ids=None, cache=True)[source]
Load vector and attribute data from a shapefile; cache it to the _features dictionary.
- property model_version
Semantic version of model, using a hacked version of the versioneer. Version is reported using git tags for the model repository or a start_version: key specified in the configuration file (default 0). The start_version or tag is then appended by the remaining information in a pep440-post style version tag (e.g. most recent git commit hash for the model repository + “dirty” if the model repository has uncommited changes)
References
https://github.com/warner/python-versioneer https://github.com/warner/python-versioneer/blob/master/details.md
- property package_list
Definitive list of packages. Get from namefile input first (as in mf6 input), then look under model input.
- property parent_layers
Mapping between layers in source model and layers in destination model.
- Returns:
- parent_layersdict
{inset layer : parent layer}
- property parent_mask
Boolean array indicating window in parent model grid (subset of cells) that encompass the inset model domain, with a surrounding buffer. Used to speed up interpolation of parent grid values onto inset model grid.
- property parent_stress_periods
Mapping between stress periods in source model and stress periods in destination model.
- Returns:
- parent_stress_periodsdict
{inset stress period : parent stress period}
- property perimeter_bc_type
Dictates how perimeter boundaries are set up.
- if ‘head’; a constant head package is created
from the parent model starting heads
- if ‘flux’; a specified flux boundary is created
from parent model cell by cell flow output
- regrid_from_parent(parent_array, mask=None, method='linear')[source]
Interpolate values in parent array onto the pfl_nwt model grid, using model grid instances attached to the parent and pfl_nwt models.
- Parameters:
- parent_arrayndarray
Values from parent model to be interpolated to pfl_nwt grid. 1 or 2-D numpy array of same sizes as a layer of the parent model.
- maskndarray (bool)
1 or 2-D numpy array of same sizes as a layer of the parent model. True values indicate cells to include in interpolation, False values indicate cells that will be dropped.
- methodstr (‘linear’, ‘nearest’)
Interpolation method.
- setup_external_filepaths(package, variable_name, filename_format, file_numbers=None)[source]
Set up external file paths for a MODFLOW package variable. Sets paths for intermediate files, which are written from the (processed) source data. Intermediate files are supplied to Flopy as external files for a given package variable. Flopy writes external files to a specified location when the MODFLOW package file is written. This method gets the external file paths that will be written by FloPy, and puts them in the configuration dictionary under their respective variables.
- Parameters:
- packagestr
Three-letter package abreviation (e.g. ‘DIS’ for discretization)
- variable_namestr
FloPy name of variable represented by external files (e.g. ‘top’ or ‘botm’)
- filename_formatstr
File path to the external file(s). Can be a string representing a single file (e.g. ‘top.dat’), or for variables where a file is written for each layer or stress period, a format string that will be formated with the zero-based layer number (e.g. ‘botm{}.dat’) for files botm0.dat, botm1.dat, …
- file_numberslist of ints
List of numbers for the external files. Usually these represent zero-based layers or stress periods.
- relative_external_pathsbool
If true, external paths will be specified relative to model_ws, otherwise, they will be absolute paths
- Returns
- ——-
- filepathslist
List of external file paths
- Adds intermediated file paths to model.cfg[<package>][‘intermediate_data’]
- Adds external file paths to model.cfg[<package>][<variable_name>]
- classmethod setup_from_cfg(cfg, verbose=False)[source]
Make a model from scratch, using information in a configuration dictionary.
- Parameters:
- cfgdict
Configuration dictionary, as produced by the model.load_cfg method.
- verbosebool
- Returns:
- mmodel instance
- classmethod setup_from_yaml(yamlfile, verbose=False)[source]
Make a model from scratch, using information in a yamlfile.
- Parameters:
- yamlfilestr (filepath)
Configuration file in YAML format with pfl_nwt setup information.
- verbosebool
- Returns:
- mmodel instance
- source_path = PosixPath('/home/runner/work/modflow-setup/modflow-setup/mfsetup')
-1 : well 0 : no lake 1 : lak package lake (lakarr > 0) 2 : high-k lake 3 : ghb 4 : sfr