flopy.utils.utils_def module¶
Generic classes and utility functions
- class FlopyBinaryData[source]¶
Bases:
object
The FlopyBinaryData class is a class to that defines the data types for integer, floating point, and character data in MODFLOW binary files. The FlopyBinaryData class is the super class from which the specific derived classes are formed. This class should not be instantiated directly.
- get_open_file_object(fname_or_fobj, read_write='rw')[source]¶
Returns an open file object for either a file name or open file object.
- get_pak_vals_shape(model, vals)[source]¶
Function to define shape of package input data for Util2d.
- Parameters
model (flopy model object) –
vals (Package input values (dict of arrays or scalars, or ndarray, or) – single scalar).
- Returns
shape – shape of input data for Util2d
- Return type
tuple
- get_unitnumber_from_ext_unit_dict(model, pak_class, ext_unit_dict=None, ipakcb=0)[source]¶
For a given modflow package, defines input file unit number, plus package input and (optionally) output (budget) save file names.
- Parameters
model (model object) – model for which the unit number is sought.
pak_class (modflow package class for which the unit number is sought.) –
ext_unit_dict (external unit dictionary, optional.) – If not provided, unitnumber and filenames will be returned as None.
ipakcb (int, optional) – Modflow package unit number on which budget is saved. Default is 0, in which case the returned output file is None.
- Returns
unitnumber (int) – file unit number for the given modflow package (or None)
filenames (list) – list of [package input file name, budget file name],
- get_util2d_shape_for_layer(model, layer=0)[source]¶
Define nrow and ncol for array (Util2d) shape of a given layer in structured and/or unstructured models.
- Parameters
model (model object) – model for which Util2d shape is sought.
layer (int) – layer (base 0) for which Util2d shape is sought.
- Returns
(nrow,ncol) – util2d shape for the given layer
- Return type
tuple of ints
- totim_to_datetime(totim, start='1-1-1970', timeunit='D')[source]¶
- Parameters
totim (list or numpy array) –
start (str) – Starting date for simulation. (default is 1-1-1970).
timeunit (string) – time unit of the simulation time. Valid values are ‘S’econds, ‘M’inutes, ‘H’ours, ‘D’ays, ‘Y’ears. (default is ‘D’).
- Returns
out – datetime object calculated from start and totim values
- Return type
list
- type_from_iterable(_iter, index=0, _type=<class 'int'>, default_val=0)[source]¶
Returns value of specified type from iterable.
- Parameters
_iter (iterable) –
index (int) – Iterable index to try to convert
_type (Python type) –
default_val (default value (0)) –
- Returns
val
- Return type
value of type _type, or default_val