flopy.utils.observationfile module
- class CsvFile(csvfile, delimiter=',', deletechars='', replace_space='')[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 “,”
deletechars (str) – optional string containing characters that should be deleted from the column names, defaults to “”
replace_space (str) – optional string containing the character that will be used to replace the space with in any column names, defaults to “”
- static read_csv(fobj, dtype, delimiter=',', deletechars='', replace_space='')[source]
- Parameters:
fobj (file object) – open text file object to read
dtype (np.dtype) –
delimiter (str) – optional delimiter for the csv or formatted text file, defaults to “,”
deletechars (str) – optional string containing characters that should be deleted from the column names, defaults to “”
replace_space (str) – optional string containing the character that will be used to replace the space with in any column names, defaults to “”
- Return type:
np.recarray
- class HydmodObs(filename, verbose=False, hydlbl_len=20)[source]
Bases:
ObsFiles
HydmodObs Class - used to read binary MODFLOW HYDMOD package output
- class Mf6Obs(filename, verbose=False, isBinary='auto')[source]
Bases:
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:
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_ntimes()[source]
Get the number of times in the file
- Returns:
out – The number of simulation times (totim) in binary file.
- Return type:
- class SwrObs(filename, precision='double', verbose=False)[source]
Bases:
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')