flopy.mfusg.mfusg module
Mfusg module.
- class MfUsg(modelname='mfusgtest', namefile_ext='nam', version='mfusg', exe_name: str | PathLike = 'mfusg', structured=True, listunit=2, model_ws: str | PathLike = '.', external_path=None, verbose=False, free_format_npl=None, **kwargs)[source]
Bases:
ModflowMODFLOW-USG Model Class.
- Parameters:
modelname (str or PathLike, default "modflowusgtest") – Name of model. This string will be used to name the MODFLOW input that are created with write_model.
namefile_ext (str, default "nam") – Extension for the namefile.
exe_name (str, default "mfusg") – The name of the executable to use.
structured (bool, default True) – Specify if model grid is structured (default) or unstructured.
listunit (int, default 2) – Unit number for the list file.
model_ws (str, default "." (curdir)) – Model workspace. Directory name to create model data sets.
external_path (str, optional) – Location for external files.
verbose (bool, default False) – Print additional information to the screen.
free_format_npl (int, optional) – Number of values per line when writing free-format arrays. When set (e.g.,
free_format_npl=10), arrays are written with that many values per line instead of all values on a single line. This produces block-format output, improving readability for large models. Default is None (all values on one line).
Notes
Examples
>>> import flopy >>> usg = flopy.mfusg.MfUsg()
- classmethod load(f: str, version='mfusg', exe_name: str | PathLike = 'mfusg', verbose=False, model_ws: str | PathLike = '.', load_only=None, forgive=False, check=True)[source]
Load an existing MODFLOW-USG model.
- Parameters:
f (str) – Name of MODFLOW name file to load.
version (str, default "mfusg") – MODFLOW version. Must be “mfusg”.
exe_name (str, default "mfusg") – MODFLOW executable name.
verbose (bool, default False) – Show messages that can be useful for debugging.
model_ws (str or PathLike, default "." (curdir)) – Model workspace path. Default is the current directory.
load_only (list, str or None) – List of case insensitive packages to load, e.g. [“bas6”, “lpf”]. One package can also be specified, e.g. “rch”. Default is None, which attempts to load all files. An empty list [] will not load any additional packages than is necessary. At a minimum, “dis” or “disu” is always loaded.
forgive (bool, optional, default False) – Option to raise exceptions on package load failure, which can be useful for debugging. Default False.
check (boolean, optional) – Check model input for common errors. Default True.
- Return type:
Examples
>>> import flopy >>> ml = flopy.mfusg.MfUsg.load('model.nam')
- fmt_string(array, free=False)[source]
Returns a C-style fmt string for numpy savetxt that corresponds to the dtype.
- Parameters:
array (numpy array) –
free (bool, optional) – If True, use high-precision format (%16.9G) for floats which requires FREE format in the BAS file. If False (default), use fixed 10-character format (%10.2e) compatible with MODFLOW-USG’s fixed-width input format.