gsflow.prms.prms_parameter Module¶
-
class
gsflow.prms.prms_parameter.
ParameterRecord
(name=None, values=None, dimensions=None, datatype=None, width=10, file_name=None)[source]¶ ParameterRecord is a class for storing parameters
- Parameters
- namestr
parameter name
- valueslist
parameter values
- dimensionslist
dimensions of the record
- datatypeint
datatype flag of the record
- widthint, optional
- file_namestr
parameter file to write the parameter to
- Attributes
Methods
export_nc
(self, f, modflow, \*\*kwargs)Method to export netcdf
write
(self, fid)Method to write to an open file
from_dict
to_dict
-
export_nc
(self, f, modflow, **kwargs)[source]¶ Method to export netcdf
- Parameters
- fstr or fp.export.NetCdf
filename to write the parameter to (*.nc)
- modflowobject
fp.modflow.Modflow or gsflow.modflow.Modflow object
- kwargsdict
keyword arguments
Notes
NetCdf export relies on flopy, so at the moment will only work for GSFLOW models where PRMS has the same discretization as the modflow grid
-
property
nvalues
¶ Returns the number of values in the record
-
property
values
¶ np.ndarray of record values
-
class
gsflow.prms.prms_parameter.
PrmsParameters
(parameters_list, header=None)[source]¶ Class to hold PRMS parameter information. This class enables reading, writing, and editing PRMS parameter files.
- Parameters
- parameters_listlist
list of ParameterRecord objects
- headersstr, optional
file header
Examples
Load parameters from file
>>> import gsflow >>> params = gsflow.prms.PrmsParameters.load_from_file(["myparams1.txt", "myparams2.txt"])
create a new PrmsParameters object
>>> params = gsflow.prms.PrmsParameters([parameter_record1, parameter_record2,])
- Attributes
parameter_files
Returns a list of parameter file names
parameters_list
Returns a list of parameter records
- record_names
Methods
add_record
(self, name[, values, dimensions, …])Method to add a new parameter record to the PrmsParameters object
add_record_object
(self, record_obj[, replace])Method to add a ParameterRecord object
export_nc
(self, f, modflow, \*\*kwargs)Method to export a PrmsParameters object to netcdf (.nc) file
get_record
(self, name)Method to get a parameter record by name
get_values
(self, name)Method to get values from a parameter
load_from_file
(param_files)Create a PrmsParameters object from parameter file(s)
remove_record
(self, name)Method to remove a parameter record
reset_filenames
(self, f)Method to reset all filenames in the PrmsParameter object to a single user supplied filename
set_values
(self, name, values)Method to set values to an existing parameter
write
(self[, name])Method to write the PrmsParameters object to PRMS parameter files
-
add_record
(self, name, values=None, dimensions=None, datatype=None, width=10, file_name=None, where=None, after=None, replace=False)[source]¶ Method to add a new parameter record to the PrmsParameters object
- Parameters
- namestr
parameter name
- valueslist
parameter values
- dimensionslist
parameter dimensions
- datatypeint
datatype flag
- widthint, optional
- file_namestr
filename parameter will be written to
- whereint, optional
index location to insert parameter
- afterint, optional
index location - 1 to insert parameter
- replacebool
replace an existing parameter when True, default is False
-
add_record_object
(self, record_obj, replace=True)[source]¶ Method to add a ParameterRecord object
- record_objParameterRecord object
ParameterRecord object
- replacebool
boolean flag that allows record replacement, default is True
-
export_nc
(self, f, modflow, **kwargs)[source]¶ Method to export a PrmsParameters object to netcdf (.nc) file
- Parameters
- fstr or fp.export.NetCdf
filename to write the parameter to (*.nc)
- modflowobject
fp.modflow.Modflow or gsflow.modflow.Modflow object
Notes
NetCdf export relies on flopy, so at the moment will only work for GSFLOW models where PRMS has the same discretization as the modflow grid
-
get_record
(self, name)[source]¶ Method to get a parameter record by name
- Parameters
- namestr
parameter name
- Returns
- ParameterRecord object
-
get_values
(self, name)[source]¶ Method to get values from a parameter
- Parameters
- namestr
parameter name
- Returns
- np.array
-
static
load_from_file
(param_files)[source]¶ Create a PrmsParameters object from parameter file(s)
- Parameters
- param_fileslist
list of parameter files
- Returns
- PrmsParameters
-
property
parameter_files
¶ Returns a list of parameter file names
-
property
parameters_list
¶ Returns a list of parameter records
-
remove_record
(self, name)[source]¶ Method to remove a parameter record
- Parameters
- name: str
parameter name
-
reset_filenames
(self, f)[source]¶ Method to reset all filenames in the PrmsParameter object to a single user supplied filename
- Parameters
- fstr