gsflow.gsflow Module¶
-
class
gsflow.gsflow.
GsflowModel
(control=None, prms=None, mf=None, modflow_only=False, prms_only=False, gsflow_exe=None, modsim=False, model_ws=None)[source]¶ GsflowModel is the GSFLOW model object. This class can be used to build a GSFLOW model, to load a GSFLOW model from it’s control file, to write input files for GSFLOW, and to run GSFLOW.
- Parameters
- control_filestr
control file path and name
- prmsPrmsModel object
gsflow.prms.PrmsModel
- mfModflow object
gsflow.modflow.Modflow
- modflow_onlybool
flag that indicates only Modflow model
- prms_onlybool
flag that indicates only PRMS model
- gsflow_exestr
GSFLOW executable path and name
- modsimbool
boolean flag to indicate that modsim is active. This creates a gsflow.modsim.Modsim object
- model_wsstr, None
override method to set the base model directory when the GSFLOW control file is not located in the same directory as the script to run GSFLOW
Examples
Load model from a control file
>>> import gsflow >>> gsf = gsflow.GsflowModel.load_from_file("gsflow.control")
Create a new, empty gsflow object
>>> control = gsflow.ControlFile(records_list=[]) >>> gsf = gsflow.GsflowModel(control=control)
- Attributes
modflow_only
Returns boolean value indicating if the model is a modflow only model
prms_only
Returns a boolean value indicating if the model is a prms only model
Methods
export_nc
(self, f, \*\*kwargs)Method to export the GSFLOW model as a netcdf file.
load_from_file
(control_file[, gsflow_exe, …])Method to load a gsflow model from it’s control file
run_model
(self[, model_ws, forgive, …])Method to run a gsflow model
write_input
(self[, basename, workspace, …])Write input files for gsflow. Four cases are possible:
-
export_nc
(self, f, **kwargs)[source]¶ Method to export the GSFLOW model as a netcdf file. Note: This method only works if nhru is equivalent to nrow * ncol in modflow.
- Parameters
- fstr
netcdf file name
- kwargs :
keyword arguments for netcdf
-
static
load_from_file
(control_file, gsflow_exe='gsflow.exe', modflow_only=False, prms_only=False, mf_load_only=None, forgive=False, model_ws=None)[source]¶ Method to load a gsflow model from it’s control file
- Parameters
- control_filestr
control file path & name
- gsflow_exestr
gsflow executable path & name
- modflow_onlybool
flag to load only modflow from the control file
- prms_onlybool
flag to load only prms from the control file
- mf_load_onlylist
list of packages to load from modflow ex. [DIS, BAS, LPF]
- forgivebool
forgive file loading errors in flopy
- model_wsstr, None
override method to set the base model directory when the GSFLOW control file is not located in the same directory as the script to run GSFLOW
- Returns
- ——-
GsflowModel object
Examples
>>> import gsflow >>> gsf = gsflow.GsflowModel.load_from_file("gsflow.control")
-
property
modflow_only
¶ Returns boolean value indicating if the model is a modflow only model
-
property
prms_only
¶ Returns a boolean value indicating if the model is a prms only model
-
run_model
(self, model_ws='.', forgive=False, gsflow_exe=None, silent=False)[source]¶ Method to run a gsflow model
- Parameters
- model_wsstr
parameter to specify the model directory
- forgivebool
forgives convergence issues
- gslfow_exestr or None
path to gsflow_exe, if gsflow_exe is None it will use the previously defined gsflow_exe variable or the default gsflow.exe.
- silentbool
flag to supress output printing to terminal during model run
- Returns
- None or (success, buffer)
Examples
>>> gsf = gsflow.GsflowModel.load_from_file("gsflow.control") >>> gsf.run_model()
-
write_input
(self, basename=None, workspace=None, write_only=None)[source]¶ - Write input files for gsflow. Four cases are possible:
if basename and workspace are None,then the exisiting files
will be overwritten - if basename is specified, only file names will be changes - if only workspace is specified, only the directory will be changed - when both basename and workspace are specifed both files and the directory they are written to are changed
- Parameters
- basenamestr
project basename
- workspacestr
model output directory
- write_only: a list
[‘control’, ‘parameters’, ‘prms_data’, ‘mf’, ‘modsim’]
Examples
>>> gsf = gsflow.GsflowModel.load_from_file('gsflow.control') >>> gsf.write_input(basename="new", workspace="../new_model")