flopy.modflow.mfoc Module

mfoc module. Contains the ModflowOc class. Note that the user can access the ModflowOc class as flopy.modflow.ModflowOc.

Additional information for this MODFLOW package can be found at the Online MODFLOW Guide.

class flopy.modflow.mfoc.ModflowOc(model, ihedfm=0, iddnfm=0, chedfm=None, cddnfm=None, cboufm=None, compact=True, stress_period_data={(0, 0): ['save head']}, extension=['oc', 'hds', 'ddn', 'cbc', 'ibo'], unitnumber=None, filenames=None, **kwargs)

MODFLOW Output Control Package Class.

Parameters:

model : model object

The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

ihedfm : int

is a code for the format in which heads will be printed. (default is 0).

iddnfm : int

is a code for the format in which heads will be printed. (default is 0).

chedfm : string

is a character value that specifies the format for saving heads. The format must contain 20 characters or less and must be a valid Fortran format that is enclosed in parentheses. The format must be enclosed in apostrophes if it contains one or more blanks or commas. The optional word LABEL after the format is used to indicate that each layer of output should be preceded with a line that defines the output (simulation time, the layer being output, and so forth). If there is no record specifying CHEDFM, then heads are written to a binary (unformatted) file. Binary files are usually more compact than text files, but they are not generally transportable among different computer operating systems or different Fortran compilers. (default is None)

cddnfm : string

is a character value that specifies the format for saving drawdown. The format must contain 20 characters or less and must be a valid Fortran format that is enclosed in parentheses. The format must be enclosed in apostrophes if it contains one or more blanks or commas. The optional word LABEL after the format is used to indicate that each layer of output should be preceded with a line that defines the output (simulation time, the layer being output, and so forth). If there is no record specifying CDDNFM, then drawdowns are written to a binary (unformatted) file. Binary files are usually more compact than text files, but they are not generally transportable among different computer operating systems or different Fortran compilers. (default is None)

cboufm : string

is a character value that specifies the format for saving ibound. The format must contain 20 characters or less and must be a valid Fortran format that is enclosed in parentheses. The format must be enclosed in apostrophes if it contains one or more blanks or commas. The optional word LABEL after the format is used to indicate that each layer of output should be preceded with a line that defines the output (simulation time, the layer being output, and so forth). If there is no record specifying CBOUFM, then ibounds are written to a binary (unformatted) file. Binary files are usually more compact than text files, but they are not generally transportable among different computer operating systems or different Fortran compilers. (default is None)

stress_period_data : dictionary of of lists

Dictionary key is a tuple with the zero-based period and step (IPEROC, ITSOC) for each print/save option list. (default is {(0,0):[‘save head’]})

The list can have any valid MODFLOW OC print/save option:

PRINT HEAD PRINT DRAWDOWN PRINT BUDGET SAVE HEAD SAVE DRAWDOWN SAVE BUDGET SAVE IBOUND

The lists can also include (1) DDREFERENCE in the list to reset drawdown reference to the period and step and (2) a list of layers for PRINT HEAD, SAVE HEAD, PRINT DRAWDOWN, SAVE DRAWDOWN, and SAVE IBOUND.

The list is used for every stress period and time step after the (IPEROC, ITSOC) tuple until a (IPEROC, ITSOC) tuple is entered with and empty list.

compact : boolean

Save results in compact budget form. (default is True).

extension : list of strings

(default is [‘oc’, ‘hds’, ‘ddn’, ‘cbc’, ‘ibo’]).

unitnumber : list of ints

(default is [14, 51, 52, 53, 0]).

filenames : str or list of str

Filenames to use for the package and the head, drawdown, budget (not used), and ibound output files. If filenames=None the package name will be created using the model name and package extension and the output file names will be created using the model name and extensions. If a single string is passed the package will be set to the string and output names will be created using the model name and head, drawdown, budget, and ibound extensions. To define the names for all package files (input and output) the length of the list of strings should be 5. Default is None.

Notes

The “words” method for specifying output control is the only option available. Also, the “compact” budget should normally be used as it produces files that are typically much smaller. The compact budget form is also a requirement for using the MODPATH particle tracking program.

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> spd = {(0, 0): ['print head'],
...   (0, 1): [],
...   (0, 249): ['print head'],
...   (0, 250): [],
...   (0, 499): ['print head', 'save ibound'],
...   (0, 500): [],
...   (0, 749): ['print head', 'ddreference'],
...   (0, 750): [],
...   (0, 999): ['print head']}
>>> oc = flopy.modflow.ModflowOc(m, stress_period_data=spd, cboufm='(20i5)')
static get_ocoutput_units(f, ext_unit_dict=None)

Get head and drawdown units from a OC file.

Parameters:

f : filename or file handle

File to load.

ext_unit_dict : dictionary, optional

If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

Returns:

ihedun : integer

Unit number of the head file.

fhead : str

File name of the head file. Is only defined if ext_unit_dict is passed and the unit number is a valid key. , headfilename, oc : ModflowOc object ModflowOc object.

iddnun : integer

Unit number of the drawdown file.

fddn : str

File name of the drawdown file. Is only defined if ext_unit_dict is passed and the unit number is a valid key.

Examples

>>> import flopy
>>> ihds, hf, iddn, df = flopy.modflow.ModflowOc.get_ocoutput_units('test.oc')
static load(f, model, nper=None, nstp=None, nlay=None, ext_unit_dict=None)

Load an existing package.

Parameters:

f : filename or file handle

File to load.

model : model object

The model object (of type flopy.modflow.mf.Modflow) to which this package will be added.

nper : int

The number of stress periods. If nper is None, then nper will be obtained from the model object. (default is None).

nstp : list

List containing the number of time steps in each stress period. If nstp is None, then nstp will be obtained from the DIS package attached to the model object. (default is None).

nlay : int

The number of model layers. If nlay is None, then nnlay will be obtained from the model object. nlay only needs to be specified if an empty model object is passed in and the oc file being loaded is defined using numeric codes. (default is None).

ext_unit_dict : dictionary, optional

If the arrays in the file are specified using EXTERNAL, or older style array control records, then f should be a file handle. In this case ext_unit_dict is required, which can be constructed using the function flopy.utils.mfreadnam.parsenamefile.

Returns:

oc : ModflowOc object

ModflowOc object.

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> oc = flopy.modflow.ModflowOc.load('test.oc', m)
write_file()

Write the package file.

Returns:None