flopy.utils.observationfile module¶
- class CsvFile(csvfile, delimiter=',')[source]¶
Bases:
object
Class for reading csv based output files
- Parameters
csvfile (str) – csv file name
delimiter (str) – optional delimiter for the csv or formatted text file, defaults to “,”
- property nobs¶
Method to get the number of observations
- Return type
int
- property obsnames¶
Method to get the observation names
- Return type
list
- class HydmodObs(filename, verbose=False, hydlbl_len=20)[source]¶
Bases:
flopy.utils.observationfile.ObsFiles
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)
- Return type
None
- class Mf6Obs(filename, verbose=False, isBinary='auto')[source]¶
Bases:
flopy.utils.observationfile.ObsFiles
Mf6Obs Class - used to read ascii and binary MODFLOW6 observation 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)
isBinary (str, bool) – default is “auto”, code will attempt to automatically check if file is binary. User can change this to True or False if the auto check fails to work
- Return type
None
- class ObsFiles[source]¶
Bases:
flopy.utils.utils_def.FlopyBinaryData
- get_data(idx=None, obsname=None, totim=None)[source]¶
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 – Array has size (ntimes, nitems). totim is always returned. nitems is 2 if idx or obsname is not None or nobs+1.
- Return type
numpy record array
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')[source]¶
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 of selected data.
- Return type
pandas dataframe
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()[source]¶
Get the number of observations in the file
- Returns
out – 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’.
- Return type
tuple of int
- get_ntimes()[source]¶
Get the number of times in the file
- Returns
out – The number of simulation times (totim) in binary file.
- Return type
int
- class SwrObs(filename, precision='double', verbose=False)[source]¶
Bases:
flopy.utils.observationfile.ObsFiles
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.
Notes
Examples
>>> import flopy >>> so = flopy.utils.SwrObs('mymodel.swr.obs')
- get_reduced_pumping(f, structured=True)[source]¶
Method to read reduced pumping from a list file or an external reduced pumping observation file
- Parameters
f (str) – file name
structured (bool) – boolean flag to indicate if model is Structured or USG model. Defaults to True (structured grid).
- Returns
np.recarray
- Return type
recarray of reduced pumping records.