gsflow.control Module¶
-
class
gsflow.control.
ControlFile
(records_list, name='Control', model_dir='', header=None, abs_path=True)[source]¶ Class to hold information about control file. Class reads, allows edits, and writes control file parameter data.
- Parameters
- records_listlist
list of ControlRecord objects
- namestr
file name
- model_dirstr
model working directory
- headerlist
file header
- abs_pathbool
optional flag to store control file path variables to abs paths, default is True
Examples
load from file
>>> import gsflow >>> control = gsflow.ControlFile.load_from_file("gsflow.control")
build a new empty object
>>> control = gsflow.ControlFile(records_list=[])
- Attributes
- record_names
records_list
Returns a list of ControlRecord objects
Methods
add_record
(self[, name, values, where, after])Convience method to add a record to the control file
get_record
(self, name)Get a complete record object
get_values
(self, name)Get a record’s values
load_from_file
(control_file[, abs_path])Method to load and create a ControlFile object from a pre-built gsflow control file.
remove_record
(self, name)Method to remove a parameter record from a control file
set_values
(self, name, values)Method to set new values to a control record
write
(self[, name])Method to write the control file
-
add_record
(self, name=None, values=None, where=None, after=None)[source]¶ Convience method to add a record to the control file
- Parameters
- namestr
record name
- valueslist
list of values
- whereint, optional
index location to insert record
- afterint, optional
index location - 1 to insert record
-
get_record
(self, name)[source]¶ Get a complete record object
- Parameters
- namestr
ControlRecord name
- Returns
- ControlRecord object
-
get_values
(self, name)[source]¶ Get a record’s values
- Parameters
- namestr
record name
- Returns
- np.ndarray or list
-
static
load_from_file
(control_file, abs_path=True)[source]¶ Method to load and create a ControlFile object from a pre-built gsflow control file.
- Parameters
- control_filestr
control file path & name
- set_absbool
optional flag to set control file variables to abs paths, default is True
- Returns
- ControlFile object
-
property
records_list
¶ Returns a list of ControlRecord objects
-
remove_record
(self, name)[source]¶ Method to remove a parameter record from a control file
- Parameters
- namestr
control record name
-
class
gsflow.control.
ControlRecord
(name=None, values=None, datatype=None)[source]¶ ControlRecord is the object used for creating and editing control file record objects
- Parameters
- namestr
record name
- valueslist
list of values
- datatypeint
integer datatype flag
Examples
create a modflow_nam ControlRecord
>>> rec = ControlRecord("modflow_nam", ["gsflow_test.nam",])
- Attributes
Methods
write
(self, fid)Write method for a control record
export_nc
from_dict
to_dict
-
property
nvalues
¶ Returns the number of values in the record
-
property
values
¶ Returns a list of the records values