flopy.utils.observationfile Module

class flopy.utils.observationfile.HydmodObs(filename, verbose=False, hydlbl_len=20)

HydmodObs Class - used to read binary MODFLOW HYDMOD package output

Parameters:

filename : str

Name of the hydmod output file

verbose : boolean

If true, print additional information to to the screen during the extraction. (default is False)

hydlbl_len : int

Length of hydmod labels. (default is 20)

Returns:

None

get_data(idx=None, obsname=None, totim=None)

Get data from the observation file.

Parameters:

idx : int

The zero-based record number. The first record is record 0. If idx is None and totim are None, data for all simulation times are returned. (default is None)

obsname : string

The name of the observation to return. If obsname is None, all observation data are returned. (default is None)

totim : float

The simulation time to return. If idx is None and totim are None, data for all simulation times are returned. (default is None)

Returns:

data : numpy record array

Array has size (ntimes, nitems). totim is always returned. nitems is 2 if idx or obsname is not None or nobs+1.

Notes

If both idx and obsname are None, will return all of the observation data.

Examples

>>> hyd = HydmodObs("my_model.hyd")
>>> ts = hyd.get_data()
get_dataframe(start_datetime='1-1-1970', idx=None, obsname=None, totim=None, timeunit='D')

Get pandas dataframe with the incremental and cumulative water budget items in the hydmod 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).

idx : int

The zero-based record number. The first record is record 0. If idx is None and totim are None, a dataframe with all simulation times is returned. (default is None)

obsname : string

The name of the observation to return. If obsname is None, all observation data are returned. (default is None)

totim : float

The simulation time to return. If idx is None and totim are None, a dataframe with all simulation times is returned. (default is None)

timeunit : string

time unit of the simulation time. Valid values are ‘S’econds, ‘M’inutes, ‘H’ours, ‘D’ays, ‘Y’ears. (default is ‘D’).

Returns:

out : pandas dataframe

Pandas dataframe of selected data.

Notes

If both idx and obsname are None, will return all of the observation data as a dataframe.

Examples

>>> hyd = HydmodObs("my_model.hyd")
>>> df = hyd.get_dataframes()
get_nobs()

Get the number of observations in the file

Returns:

out : tuple of int

A tupe with the number of records and number of flow items in the file. The number of flow items is non-zero only if swrtype=’flow’.

get_ntimes()

Get the number of times in the file

Returns:

out : int

The number of simulation times (totim) in binary file.

get_obsnames()

Get a list of observation names in the file

Returns:

out : list of strings

List of observation names in the binary file. totim is not included in the list of observation names.

get_times()

Get a list of unique times in the file

Returns:

out : list of floats

List contains unique simulation times (totim) in binary file.

class flopy.utils.observationfile.SwrObs(filename, precision='double', verbose=False)

Read binary SWR observations output from MODFLOW SWR Process observation files

Parameters:

filename : string

Name of the cell budget file

precision : string

‘single’ or ‘double’. Default is ‘double’.

verbose : bool

Write information to the screen. Default is False.

Examples

>>> import flopy
>>> so = flopy.utils.SwrObs('mymodel.swr.obs')
get_data(idx=None, obsname=None, totim=None)

Get data from the observation file.

Parameters:

idx : int

The zero-based record number. The first record is record 0. If idx is None and totim are None, data for all simulation times are returned. (default is None)

obsname : string

The name of the observation to return. If obsname is None, all observation data are returned. (default is None)

totim : float

The simulation time to return. If idx is None and totim are None, data for all simulation times are returned. (default is None)

Returns:

data : numpy record array

Array has size (ntimes, nitems). totim is always returned. nitems is 2 if idx or obsname is not None or nobs+1.

Notes

If both idx and obsname are None, will return all of the observation data.

Examples

>>> hyd = HydmodObs("my_model.hyd")
>>> ts = hyd.get_data()
get_dataframe(start_datetime='1-1-1970', idx=None, obsname=None, totim=None, timeunit='D')

Get pandas dataframe with the incremental and cumulative water budget items in the hydmod 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).

idx : int

The zero-based record number. The first record is record 0. If idx is None and totim are None, a dataframe with all simulation times is returned. (default is None)

obsname : string

The name of the observation to return. If obsname is None, all observation data are returned. (default is None)

totim : float

The simulation time to return. If idx is None and totim are None, a dataframe with all simulation times is returned. (default is None)

timeunit : string

time unit of the simulation time. Valid values are ‘S’econds, ‘M’inutes, ‘H’ours, ‘D’ays, ‘Y’ears. (default is ‘D’).

Returns:

out : pandas dataframe

Pandas dataframe of selected data.

Notes

If both idx and obsname are None, will return all of the observation data as a dataframe.

Examples

>>> hyd = HydmodObs("my_model.hyd")
>>> df = hyd.get_dataframes()
get_nobs()

Get the number of observations in the file

Returns:

out : tuple of int

A tupe with the number of records and number of flow items in the file. The number of flow items is non-zero only if swrtype=’flow’.

get_ntimes()

Get the number of times in the file

Returns:

out : int

The number of simulation times (totim) in binary file.

get_obsnames()

Get a list of observation names in the file

Returns:

out : list of strings

List of observation names in the binary file. totim is not included in the list of observation names.

get_times()

Get a list of unique times in the file

Returns:

out : list of floats

List contains unique simulation times (totim) in binary file.

flopy.utils.observationfile.get_selection(data, names)
Parameters:

data : numpy recarray

recarray of data to make a selection from

names : string or list of strings

column names to return

Returns:

out : numpy recarry

recarray with selection