flopy.utils.formattedfile module

Module to read MODFLOW formatted output files. The module contains one important classes that can be accessed by the user.

  • FormattedHeadFile (Formatted head file. Can also be used for drawdown)
class FormattedHeadFile(filename, text='head', precision='single', verbose=False, **kwargs)[source]

Bases: flopy.utils.formattedfile.FormattedLayerFile

FormattedHeadFile Class.

Parameters:
  • filename (string) – Name of the formatted head file
  • text (string) – Name of the text string in the formatted head file. Default is ‘head’
  • precision (string) – ‘single’ or ‘double’. Default is ‘single’.
  • verbose (bool) – Write information to the screen. Default is False.

Notes

The FormattedHeadFile class provides simple ways to retrieve 2d and 3d head arrays from a MODFLOW formatted head file and time series arrays for one or more cells.

The FormattedHeadFile class is built on a record array consisting of headers, which are record arrays of the modflow header information (kstp, kper, pertim, totim, text, nrow, ncol, ilay) and long integers, which are pointers to first bytes of data for the corresponding data array.

FormattedHeadFile can only read formatted head files containing headers. Use the LABEL option in the output control file to generate head files with headers.

Examples

>>> import flopy.utils.formattedfile as ff
>>> hdobj = ff.FormattedHeadFile('model.fhd', precision='single')
>>> hdobj.list_records()
>>> rec = hdobj.get_data(kstpkper=(1, 50))
>>> rec2 = ddnobj.get_data(totim=100.)
class FormattedHeader(text_ident, precision='single')[source]

Bases: flopy.utils.datafile.Header

The TextHeader class is a class to read in headers from MODFLOW formatted files.

Parameters:
  • is the text string in the header that identifies the type (text_ident) –
  • data (eg. 'head') precision is the precision of the floating point (of) –
  • in the file (data) –
read_header(text_file)[source]

Read header information from a formatted file

Parameters:
  • is an open file object currently at the beginning of (text_file) –
  • header (the) –
Returns:

  • out (numpy array of header information)
  • also stores the header’s format string as self.format_string

class FormattedLayerFile(filename, precision, verbose, kwargs)[source]

Bases: flopy.utils.datafile.LayerFile

The FormattedLayerFile class is the super class from which specific derived classes are formed. This class should not be instantiated directly

close()[source]

Close the file handle.

get_ts(idx)[source]

Get a time series from the formatted file.

Parameters:idx (tuple of ints, or a list of a tuple of ints) – idx can be (layer, row, column) or it can be a list in the form [(layer, row, column), (layer, row, column), …]. The layer, row, and column values must be zero based.
Returns:out – Array has size (ntimes, ncells + 1). The first column in the data array will contain time (totim).
Return type:numpy array

Notes

The layer, row, and column values must be zero-based, and must be within the following ranges: 0 <= k < nlay; 0 <= i < nrow; 0 <= j < ncol

Examples

is_float(s)[source]
is_int(s)[source]