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 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, label='LABEL', **kwargs)[source]

Bases: flopy.pakbase.Package

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 drawdown 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 lists) –

    Dictionary key is a tuple with the zero-based period and step (IPEROC, ITSOC) for each print/save option list. If stress_period_data is None, then heads are saved for the last time step of each stress period. (default is None)

    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.

    stress_period_data = {(0,1):[‘save head’]}) would save the head for the second timestep in the first stress period.

  • 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)')
check(f=None, verbose=True, level=1, checktype=None)[source]

Check package data for common errors.

Parameters:
  • f (str or file handle) – String defining file name or file handle for summary file of check method output. If a string is passed a file handle is created. If f is None, check method does not write results to a summary file. (default is None)
  • verbose (bool) – Boolean flag used to determine if check method results are written to the screen.
  • level (int) – Check method analysis level. If level=0, summary checks are performed. If level=1, full checks are performed.
Returns:

Return type:

None

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow.load('model.nam')
>>> m.oc.check()
get_budgetunit()[source]

Get the budget file unit number(s).

Parameters:None
Returns:iubud – Unit number or list of cell-by-cell budget output unit numbers. None is returned if ipakcb is less than one for all packages.
Return type:integer ot list of integers

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> dis = flopy.modflow.ModflowDis(m)
>>> bas = flopy.modflow.ModflowBas(m)
>>> lpf = flopy.modflow.ModflowLpf(m, ipakcb=100)
>>> wel_data = {0: [[0, 0, 0, -1000.]]}
>>> wel = flopy.modflow.ModflowWel(m, ipakcb=101,
... stress_period_data=wel_data)
>>> spd = {(0, 0): ['save head', 'save budget']}
>>> oc = flopy.modflow.ModflowOc(m, stress_period_data=spd)
>>> oc.get_budgetunit()
[100, 101]
static get_ocoutput_units(f, ext_unit_dict=None)[source]

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')
classmethod load(f, model, nper=None, nstp=None, nlay=None, ext_unit_dict=None)[source]

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 (int or list of ints) – Integer of list of integers containing the number of time steps in each stress period. If nstp is None, then nstp will be obtained from the DIS or DISU packages attached to the model object. The length of nstp must be equal to nper. (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.

Return type:

ModflowOc object

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> oc = flopy.modflow.ModflowOc.load('test.oc', m)
reset_budgetunit(budgetunit=None, fname=None)[source]

Reset the cell-by-cell budget unit (ipakcb) for every package that can write cell-by-cell data when SAVE BUDGET is specified in the OC file to the specified budgetunit.

Parameters:
  • budgetunit (int, optional) – Unit number for cell-by-cell output data. If budgetunit is None then the next available external unit number is assigned. Default is None
  • fname (string, optional) – Filename to use for cell-by-cell output file. If fname=None the cell-by-cell output file will be created using the model name and a ‘.cbc’ file extension. Default is None.
Returns:

Return type:

None

Examples

>>> import flopy
>>> m = flopy.modflow.Modflow()
>>> dis = flopy.modflow.ModflowDis(m)
>>> bas = flopy.modflow.ModflowBas(m)
>>> lpf = flopy.modflow.ModflowLpf(m, ipakcb=100)
>>> wel_data = {0: [[0, 0, 0, -1000.]]}
>>> wel = flopy.modflow.ModflowWel(m, ipakcb=101,
... stress_period_data=wel_data)
>>> spd = {(0, 0): ['save head', 'save budget']}
>>> oc = flopy.modflow.ModflowOc(m, stress_period_data=spd)
>>> oc.reset_budgetunit(budgetunit=1053, fname='test.cbc')
write_file()[source]

Write the package file.

Returns:
Return type:None