flopy package

Subpackages

Submodules

Module contents

The FloPy package consists of a set of Python scripts to run MODFLOW, MT3D, SEAWAT and other MODFLOW-related groundwater programs. FloPy enables you to run all these programs with Python scripts. The FloPy project started in 2009 and has grown to a fairly complete set of scripts with a growing user base.

This version of Flopy (FloPy3) was released in December 2015 with a few great enhancements that make FloPy3 backwards incompatible. The first significant change is that FloPy3 uses zero-based indexing everywhere, which means that all layers, rows, columns, and stress periods start numbering at zero. This change was made for consistency as all array-indexing was already zero-based (as are all arrays in Python). This may take a little getting-used-to, but hopefully will avoid confusion in the future. A second significant enhancement concerns the ability to specify time-varying boundary conditions that are specified with a sequence of layer-row-column-values, like the WEL and GHB packages. A variety of flexible and readable ways have been implemented to specify these boundary conditions. FloPy is an open-source project and any assistance is welcomed. Please email the development team if you want to contribute.

run_model(exe_name: str | PathLike, namefile: str | None, model_ws: str | PathLike = '.', silent=False, pause=False, report=False, processors=None, normal_msg='normal termination', use_async=False, cargs=None, custom_print=None) Tuple[bool, List[str]][source]

Run the model using subprocess.Popen, optionally collecting stdout and printing timestamped progress. Model workspace, namefile, executable to use, and several other options may be configured, and additional command line arguments may also be provided.

Parameters:
  • exe_name (str or PathLike) – Executable name or path. If the executable name is provided, the executable must be on the system path. Alternatively, a full path to the executable may be provided.

  • namefile (str, optional) – Name of the name file of model to run. The name may be None to run models that don’t require a control file (name file)

  • model_ws (str or PathLike, optional, default '.') – Path to the parent directory of the namefile. (default is the current working directory ‘.’)

  • silent (boolean, default True) – Whether to suppress model output. (Default is True)

  • pause (boolean, optional, default False) – Pause and wait for keystroke upon completion. (Default is False)

  • report (boolean, optional, default False) – Save stdout lines to a list (buff) returned by the method. (Default is False)

  • processors (int) – Number of processors. Parallel simulations are only supported for MODFLOW 6 simulations. (default is None)

  • normal_msg (str or list) – Termination message used to determine if the model terminated normally. More than one message can be provided using a list. (Default is ‘normal termination’)

  • use_async (boolean) – Asynchronously read model stdout and report with timestamps. Good for models taking a long time to run, not good for models that run quickly.

  • cargs (str or list, optional, default None) – Additional command line arguments to pass to the executable. (Default is None)

  • custom_print (callable) – Optional callable for printing. It will replace the builtin print function. This is useful for a shorter print output or integration into other systems such as GUIs. default is None, i.e. use the builtin print

Returns:

  • success (boolean)

  • buff (list of lines of stdout (empty if report is False))

which(cmd, mode=1, path=None)[source]

Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file.

mode defaults to os.F_OK | os.X_OK. path defaults to the result of os.environ.get(“PATH”), or can be overridden with a custom search path.