Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 40 additions & 37 deletions flopy/mf6/mfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,29 @@ class MFModel(ModelInterface):

Parameters
----------
simulation_data : MFSimulationData
Simulation data object of the simulation this model will belong to
simulation : MFSimulation
Simulation object that this model is a part of.
model_type : str, default "gwf6"
Model type.
modelname : str, default "model"
Name of the model.
model_nam_file : str, optional
Relative path to the model name file from model working folder.
version : str, default "mf6"
Version of modflow.
exe_name : str, default "mf6"
Model executable name.
add_to_simulation : bool, default True
Adds model to simulation.
structure : MFModelStructure
Structure of this type of model
modelname : str
Name of the model
model_nam_file : str
Relative path to the model name file from model working folder
version : str
Version of modflow
exe_name : str
Model executable name
model_ws : str
Model working folder path
disfile : str
Relative path to dis file from model working folder
grid_type : str
Type of grid the model will use (structured, unstructured, vertices)
verbose : bool
Verbose setting for model operations (default False)
Structure of this type of model.
model_rel_path : str or PathLike, default "." (curdir)
Relative path of model folder to simulation folder.
verbose : bool, default False
Verbose setting for model operations.
**kwargs
Extra keyword options to support spatial referencing, including
``xll``, ``yll``, ``xul``, ``yul``, ``rotation``, and ``crs``.

Attributes
----------
Expand Down Expand Up @@ -880,30 +883,30 @@ def load_base(
Parameters
----------
simulation : MFSimulation
simulation object that this model is a part of
simulation_data : MFSimulationData
simulation data object
Simulation object that this model is a part of.
structure : MFModelStructure
structure of this type of model
model_name : str
name of the model
model_nam_file : str
relative path to the model name file from model working folder
version : str
version of modflow
Structure of this type of model.
modelname : str, default "NewModel"
Name of the model.
model_nam_file : str, default "modflowtest.nam"
Relative path to the model name file from model working folder.
mtype : str, default "gwf"
Not used.
version : str, default "mf6"
Version of modflow.
exe_name : str or PathLike, default "mf6"
model executable name or path
strict : bool
strict mode when loading files
Model executable name or path.
strict : bool, default True
Strict mode when loading files.
model_rel_path : str, default "." (curdir)
relative path of model folder to simulation folder
relative path of model folder to simulation folder.
load_only : list
list of package abbreviations or package names corresponding to
List of package abbreviations or package names corresponding to
packages that flopy will load. default is None, which loads all
packages. the discretization packages will load regardless of this
setting. subpackages, like time series and observations, will also
packages. The discretization packages will load regardless of this
setting. Subpackages, like time series and observations, will also
load regardless of this setting.
example list: ['ic', 'maw', 'npf', 'oc', 'my_well_package_1']
Example list: ``['ic', 'maw', 'npf', 'oc', 'my_well_package_1']``

Returns
-------
Expand Down
16 changes: 9 additions & 7 deletions flopy/mf6/mfpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,18 +1694,20 @@ class MFPackage(PackageInterface):
Parameters
----------
parent : MFModel, MFSimulation, or MFPackage
The parent model, simulation, or package containing this package
The parent model, simulation, or package containing this package.
package_type : str
String defining the package type
filename : str or PathLike
Name or path of file where this package is stored
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
Package name
loading_package : bool
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.

Attributes
----------
Expand Down
123 changes: 63 additions & 60 deletions flopy/mf6/mfsimbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,48 +404,51 @@ class MFSimulationBase:

Parameters
----------
sim_name : str
sim_name : str, default "sim"
Name of the simulation.
version : str
Version of MODFLOW 6 executable
exe_name : str
Path to MODFLOW 6 executable
sim_ws : str
version : str, default "mf6"
Version of MODFLOW 6 executable.
exe_name : str, default "mf6"
Path to MODFLOW 6 executable.
sim_ws : str or PathLike, default ".' (curdir)
Path to MODFLOW 6 simulation working folder. This is the folder
containing the simulation name file.
verbosity_level : int
Verbosity level of standard output from 0 to 2. When 0 is specified no
standard output is written. When 1 is specified standard
error/warning messages with some informational messages are written.
When 2 is specified full error/warning/informational messages are
written (this is ideal for debugging).
continue_ : bool
verbosity_level : int, default 1
Verbosity level of standard output:

0. No standard output
1. Standard error/warning messages with some informational
messages
2. Verbose mode with full error/warning/informational messages.
This is ideal for debugging.
continue_ : bool, optional
Sets the continue option in the simulation name file. The continue
option is a keyword flag to indicate that the simulation should
continue even if one or more solutions do not converge.
nocheck : bool
Sets the nocheck option in the simulation name file. The nocheck
option is a keyword flag to indicate that the model input check
routines should not be called prior to each time step. Checks
are performed by default.
memory_print_option : str
Sets memory_print_option in the simulation name file.
Memory_print_option is a flag that controls printing of detailed
memory manager usage to the end of the simulation list file. NONE
means do not print detailed information. SUMMARY means print only
the total memory for each simulation component. ALL means print
information for each variable stored in the memory manager. NONE is
default if memory_print_option is not specified.
write_headers: bool
When true flopy writes a header to each package file indicating that
nocheck : bool, optional
Sets the nocheck option in the simulation name file. The nocheck
option is a keyword flag to indicate that the model input check
routines should not be called prior to each time step. Checks
are performed by default.
memory_print_option : str, optional
Sets memory_print_option in the simulation name file.
Memory_print_option is a flag that controls printing of detailed
memory manager usage to the end of the simulation list file. None
means do not print detailed information. SUMMARY means print only
the total memory for each simulation component. ALL means print
information for each variable stored in the memory manager. None is
default if memory_print_option is not specified.
write_headers: bool, default True
When True flopy writes a header to each package file indicating that
it was created by flopy.
lazy_io: bool
When true flopy only reads external data when the data is requested
lazy_io: bool, default False
When True flopy only reads external data when the data is requested
and only writes external data if the data has changed. This option
automatically overrides the verify_data and auto_set_sizes, turning
both off.
use_pandas: bool
Load/save data using pandas dataframes (for supported data)
use_pandas: bool, default True
Load/save data using pandas dataframes (for supported data).

Examples
--------
>>> s = MFSimulationBase.load('my simulation', 'simulation.nam')
Expand Down Expand Up @@ -779,48 +782,48 @@ def load(

Parameters
----------
cls_child :
cls object of child class calling load
sim_name : str
sim_name : str, default "modflowsim"
Name of the simulation.
version : str
MODFLOW version
exe_name : str or PathLike
Path to MODFLOW executable (relative to the simulation workspace or absolute)
sim_ws : str or PathLike
Path to simulation workspace
strict : bool
Strict enforcement of file formatting
verbosity_level : int
Verbosity level of standard output
0: No standard output
1: Standard error/warning messages with some informational
version : str, default "mf6"
Version of MODFLOW 6 executable.
exe_name : str or PathLike, default "mf6"
Path to MODFLOW 6 executable.
sim_ws : str or PathLike, default "." (curdir)
Path to MODFLOW 6 simulation working folder. This is the folder
containing the simulation name file.
strict : bool, default True
Strict enforcement of file formatting.
verbosity_level : int, default 1
Verbosity level of standard output:

0. No standard output
1. Standard error/warning messages with some informational
messages
2: Verbose mode with full error/warning/informational
messages. This is ideal for debugging.
load_only : list
2. Verbose mode with full error/warning/informational messages.
This is ideal for debugging.
load_only : list, optional
List of package abbreviations or package names corresponding to
packages that flopy will load. default is None, which loads all
packages. the discretization packages will load regardless of this
setting. subpackages, like time series and observations, will also
load regardless of this setting.
example list: ['ic', 'maw', 'npf', 'oc', 'ims', 'gwf6-gwf6']
verify_data : bool
Verify data when it is loaded. this can slow down loading
write_headers: bool
When true flopy writes a header to each package file indicating
that it was created by flopy
lazy_io: bool
When true flopy only reads external data when the data is requested
verify_data : bool, default False
Verify data when it is loaded. This can slow down loading.
write_headers: bool, default True
When True flopy writes a header to each package file indicating
that it was created by flopy.
lazy_io: bool, default False
When True flopy only reads external data when the data is requested
and only writes external data if the data has changed. This option
automatically overrides the verify_data and auto_set_sizes, turning
both off.
use_pandas: bool
Load/save data using pandas dataframes (for supported data)
use_pandas: bool, default True
Load/save data using pandas dataframes (for supported data).

Returns
-------
sim : MFSimulation object
MFSimulation object

Examples
--------
Expand Down
49 changes: 26 additions & 23 deletions flopy/mf6/utils/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ def _get_template_env():
keep_trailing_newline=True,
)

from flopy.mf6.utils.codegen.filters import Filters

env.filters["base"] = Filters.base
env.filters["title"] = Filters.title
env.filters["description"] = Filters.description
env.filters["prefix"] = Filters.prefix
env.filters["parent"] = Filters.parent
env.filters["skip_init"] = Filters.skip_init
env.filters["package_abbr"] = Filters.package_abbr
env.filters["variables"] = Filters.variables
env.filters["attrs"] = Filters.attrs
env.filters["init"] = Filters.init
env.filters["untag"] = Filters.untag
env.filters["type"] = Filters.type
env.filters["children"] = Filters.children
env.filters["default_value"] = Filters.default_value
env.filters["safe_name"] = Filters.safe_name
env.filters["value"] = Filters.value
env.filters["math"] = Filters.math
env.filters["clean"] = Filters.clean
from flopy.mf6.utils.codegen import filters

env.filters["base"] = filters.base
env.filters["title"] = filters.title
env.filters["description"] = filters.description
env.filters["prefix"] = filters.prefix
env.filters["parent"] = filters.parent
env.filters["skip_init"] = filters.skip_init
env.filters["package_abbr"] = filters.package_abbr
env.filters["variables"] = filters.variables
env.filters["attrs"] = filters.attrs
env.filters["init"] = filters.init
env.filters["untag"] = filters.untag
env.filters["type"] = filters.type
env.filters["children"] = filters.children
env.filters["default_value"] = filters.default_value
env.filters["safe_name"] = filters.safe_name
env.filters["value"] = filters.value
env.filters["math"] = filters.math
env.filters["clean"] = filters.clean

return env

Expand Down Expand Up @@ -72,11 +72,11 @@ def make_targets(dfn, outdir: PathLike, verbose: bool = False):

# import here instead of module so we don't
# expect optional deps at module init time
from flopy.mf6.utils.codegen import filters
from flopy.mf6.utils.codegen.component import ComponentDescriptor
from flopy.mf6.utils.codegen.filters import Filters

def _get_template_name(component_name) -> str:
base = Filters.base(component_name)
base = filters.base(component_name)
if base == "MFSimulationBase":
return "simulation.py.jinja"
elif base == "MFModel":
Expand All @@ -88,9 +88,12 @@ def _get_template_name(component_name) -> str:
else:
raise NotImplementedError(f"Unknown base class: {base}")

if verbose:
print(f"Making target for DFN {dfn['name']!r} ...")

for component in ComponentDescriptor.from_dfn(dfn):
component_name = component["name"]
target_path = outdir / f"mf{Filters.title(component_name)}.py"
target_path = outdir / f"mf{filters.title(component_name)}.py"
template = env.get_template(_get_template_name(component_name))
with open(target_path, "w") as f:
f.write(template.render(**component))
Expand Down
Loading
Loading