flopy.utils.mflistfile module

This is a set of classes for reading budget information out of MODFLOW-style listing files. Cumulative and incremental budgets are returned as numpy recarrays, which can then be easily plotted.

class ListBudget(file_name, budgetkey=None, timeunit='days')[source]

Bases: object

MODFLOW family list file handling

Parameters
  • file_name (str) – the list file name

  • budgetkey (str) – the text string identifying the budget table. (default is None)

  • timeunit (str) – the time unit to return in the recarray. (default is ‘days’)

Notes

The ListBudget class should not be instantiated directly. Access is through derived classes: MfListBudget (MODFLOW), SwtListBudget (SEAWAT) and SwrListBudget (MODFLOW with the SWR process)

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> incremental, cumulative = mf_list.get_budget()
>>> df_in, df_out = mf_list.get_dataframes(start_datetime="10-21-2015")
get_budget(names=None)[source]

Get the recarrays with the incremental and cumulative water budget items in the list file.

Parameters

names (str or list of strings) – Selection of column names to return. If names is not None then totim, time_step, stress_period, and selection(s) will be returned. (default is None).

Returns

out – Numpy recarrays with the water budget items in list file. The recarray also includes totim, time_step, and stress_period. A separate recarray is returned for the incremental and cumulative water budget entries.

Return type

recarrays

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> budget = mf_list.get_budget()
get_cumulative(names=None)[source]

Get a recarray with the cumulative water budget items in the list file.

Parameters

names (str or list of strings) – Selection of column names to return. If names is not None then totim, time_step, stress_period, and selection(s) will be returned. (default is None).

Returns

out – Numpy recarray with the water budget items in list file. The recarray also includes totim, time_step, and stress_period.

Return type

recarray

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> cumulative = mf_list.get_cumulative()
get_data(kstpkper=None, idx=None, totim=None, incremental=False)[source]

Get water budget data from the list file for the specified conditions.

Parameters
  • idx (int) – The zero-based record number. The first record is record 0. (default is None).

  • kstpkper (tuple of ints) – A tuple containing the time step and stress period (kstp, kper). These are zero-based kstp and kper values. (default is None).

  • totim (float) – The simulation time. (default is None).

  • incremental (bool) – Boolean flag used to determine if incremental or cumulative water budget data for the specified conditions will be returned. If incremental=True, incremental water budget data will be returned. If incremental=False, cumulative water budget data will be returned. (default is False).

Returns

data – Array has size (number of budget items, 3). Recarray names are ‘index’, ‘value’, ‘name’.

Return type

numpy recarray

Notes

if both kstpkper and totim are None, will return the last entry

Examples

>>> import matplotlib.pyplot as plt
>>> import flopy
>>> mf_list = flopy.utils.MfListBudget("my_model.list")
>>> data = mf_list.get_data(kstpkper=(0,0))
>>> plt.bar(data['index'], data['value'])
>>> plt.xticks(data['index'], data['name'], rotation=45, size=6)
>>> plt.show()
get_dataframes(start_datetime='1-1-1970', diff=False)[source]

Get pandas dataframes with the incremental and cumulative water budget items in the list file.

Parameters

start_datetime (str) – If start_datetime is passed as None, the rows are indexed on totim. Otherwise, a DatetimeIndex is set. (default is 1-1-1970).

Returns

out – Pandas dataframes with the incremental and cumulative water budget items in list file. A separate pandas dataframe is returned for the incremental and cumulative water budget entries.

Return type

pandas dataframes

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> incrementaldf, cumulativedf = mf_list.get_dataframes()
get_incremental(names=None)[source]

Get a recarray with the incremental water budget items in the list file.

Parameters

names (str or list of strings) – Selection of column names to return. If names is not None then totim, time_step, stress_period, and selection(s) will be returned. (default is None).

Returns

out – Numpy recarray with the water budget items in list file. The recarray also includes totim, time_step, and stress_period.

Return type

recarray

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> incremental = mf_list.get_incremental()
get_kstpkper()[source]

Get a list of unique stress periods and time steps in the list file water budgets.

Returns

out – List of unique kstp, kper combinations in list file. kstp and kper values are zero-based.

Return type

list of (kstp, kper) tuples

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> kstpkper = mf_list.get_kstpkper()
get_model_runtime(units='seconds')[source]

Get the elapsed runtime of the model from the list file.

Parameters

units (str) – Units in which to return the runtime. Acceptable values are ‘seconds’, ‘minutes’, ‘hours’ (default is ‘seconds’)

Returns

out – Floating point value with the runtime in requested units. Returns NaN if runtime not found in list file

Return type

float

Examples

>>> mf_list = MfListBudget("my_model.list")
>>> budget = mf_list.get_model_runtime(units='hours')
get_record_names()[source]

Get a list of water budget record names in the file.

Returns

out – List of unique text names in the binary file.

Return type

list of strings

Examples

>>> mf_list = MfListBudget('my_model.list')
>>> names = mf_list.get_record_names()
get_reduced_pumping()[source]

Get numpy recarray of reduced pumping data from a list file. Reduced pumping data most have been written to the list file during the model run. Works with MfListBudget and MfusgListBudget.

Returns

A numpy recarray with the reduced pumping data from the list file.

Return type

numpy recarray

Example

>>> objLST = MfListBudget("my_model.lst")
>>> raryReducedPpg = objLST.get_reduced_pumping()
>>> dfReducedPpg = pd.DataFrame.from_records(raryReducedPpg)
get_times()[source]

Get a list of unique water budget times in the list file.

Returns

out – List contains unique water budget simulation times (totim) in list file.

Return type

list of floats

Examples

>>> mf_list = MfListBudget('my_model.list')
>>> times = mf_list.get_times()
isvalid()[source]

Get a boolean indicating if budget data are available in the file.

Returns

out – Boolean indicating if budget data are available in the file.

Return type

boolean

Examples

>>> mf_list = MfListBudget('my_model.list')
>>> valid = mf_list.isvalid()
set_budget_key()[source]
class Mf6ListBudget(file_name, budgetkey=None, timeunit='days')[source]

Bases: flopy.utils.mflistfile.ListBudget

set_budget_key()[source]
class MfListBudget(file_name, budgetkey=None, timeunit='days')[source]

Bases: flopy.utils.mflistfile.ListBudget

set_budget_key()[source]
class MfusgListBudget(file_name, budgetkey=None, timeunit='days')[source]

Bases: flopy.utils.mflistfile.ListBudget

set_budget_key()[source]
class SwrListBudget(file_name, budgetkey=None, timeunit='days')[source]

Bases: flopy.utils.mflistfile.ListBudget

set_budget_key()[source]
class SwtListBudget(file_name, budgetkey=None, timeunit='days')[source]

Bases: flopy.utils.mflistfile.ListBudget

set_budget_key()[source]