flopy.utils.flopy_io Module

Module for input/output utilities

flopy.utils.flopy_io.flux_to_wel(cbc_file, text, precision='single', model=None, verbose=False)

Convert flux in a binary cell budget file to a wel instance

Parameters:

cbc_file : (str) cell budget file name

text : (str) text string of the desired flux type (e.g. “drains”)

precision : (optional str) precision of the cell budget file

model : (optional) BaseModel instance. If passed, a new ModflowWel

instance will be added to model

verbose : bool flag passed to CellBudgetFile

Returns:

flopy.modflow.ModflowWel instance

flopy.utils.flopy_io.line_parse(line)

Convert a line of text into to a list of values. This handles the case where a free formatted MODFLOW input file may have commas in it.

flopy.utils.flopy_io.loadtxt(file, delimiter=' ', dtype=None, skiprows=0, use_pandas=True, **kwargs)

Use pandas if it is available to load a text file (significantly faster than n.loadtxt or genfromtxt; see http://stackoverflow.com/questions/18259393/numpy-loading-csv-too-slow-compared-to-matlab)

Parameters:

file : file or str

File, filename, or generator to read.

delimiter : str, optional

The string used to separate values. By default, this is any whitespace.

dtype : data-type, optional

Data-type of the resulting array

skiprows : int, optional

Skip the first skiprows lines; default: 0.

use_pandas : bool

If true, the much faster pandas.read_csv method is used.

kwargs : dict

Keyword arguments passed to numpy.loadtxt or pandas.read_csv.

Returns:

ra : np.recarray

Numpy record array of file contents.

flopy.utils.flopy_io.read_fixed_var(line, ncol=1, length=10, ipos=None, free=False)

Parse a fixed format line using user provided data

Parameters:

line : str

text string to parse.

ncol : int

number of columns to parse from line. (default is 1)

length : int

length of each column for fixed column widths. (default is 10)

ipos : list, int, or numpy array

user-provided column widths. (default is None)

free : bool

boolean indicating if sting is free format. ncol, length, and ipos are not used if free is True. (default is False)

Returns:

out : list

padded list containing data parsed from the passed text string

flopy.utils.flopy_io.write_fixed_var(v, length=10, ipos=None, free=False, comment=None)
Parameters:

v : list, int, float, bool, or numpy array

list, int, float, bool, or numpy array containing the data to be written to a string.

length : int

length of each column for fixed column widths. (default is 10)

ipos : list, int, or numpy array

user-provided column widths. (default is None)

free : bool

boolean indicating if a free format string should be generated. length and ipos are not used if free is True. (default is False)

comment : str

comment string to add to the end of the string

Returns:

out : str

fixed or free format string generated using user-provided data