PRMS-related functions

mfobs.prms.get_prms_statvar_obs(perioddata, statvar_file, statvar_sitenames=None, obsnme_date_suffix=True, obsnme_suffix_format='%Y%m%d', abs=False)[source]

Read raw PRMS statvar observation output from text file table with times along the row axis and observation sites along the column axis. Reshape (stack) results to be n times x n sites rows, with a single observation value in each row.

If there is more than one time in a stress period, retain only the last time (so that there is one observation per stress period for each site.

Parameters:
perioddataDataFrame

DataFrame with start/end dates for stress periods. Must have columns ‘per’ (stress period number), ‘time’ (modflow time, in days), ‘start_datetime’ (start date for the stress period) and ‘end_datetime’ (end date for the stress period).

model_output_filestr

Path to MODFLOW-6 observation csv output (shape: n times rows x n obs columns).

statvar_sitenamesdict

Dictionary of the site names (values) associated with each HRU or stream segment (keys) referenced in the statvar file.

obsnme_date_suffixbool

If true, give observations a date-based suffix. Otherwise, assign a elapsed time-based suffix. In either case, the format of the suffix is controlled by obsnme_suffix_format. by default True

obsnme_suffix_formatstr, optional

Format for suffix of obsnmes. Observation names are created following the format of <obsprefix>_<date or elapsed time suffix>. By default, '%Y%m', which would yield '202001' for a Jan, 2020 observation (obsnme_date_suffix=True). If obsnme_date_suffix=False, obsnme_suffix_format should be a decimal format in the “new-style” string format (e.g. ‘{:03d}’, which would yield '001' for an elapsed time of 1 day.)

absbool, optional

Option to convert simulated values to absolute values

Returns:
resultsDataFrame

DataFrame with one head observation per row, with the following columns:

per

zero-based model stress period

site_no

unique identifier for each site

variable

PRMS variable name

obsprefix

prefix of observation name (site identifier)

sim_value

simulated values

datetime

pandas datetimes, based on stress period start date

obsnme

observation name based on format of <obsprefix>_’%Y%m’

Example observation names:

site1000_202001, for a Jan. 2020 observation at site1000 (obsnme_date_suffix=True)

site1000_00001, for a day 1 observation at site1000 (obsnme_date_suffix=False)

mfobs.prms.read_statvar_file(statvar_file)[source]

Read a PRMS statvar file into a pandas dataframe.

Parameters:
statvar_filestr or pathlike
Returns:
dfpandas DataFrame (n days x n sites)

With a datetime index (one row per day) and columns: site1, site2, …

Column names are formulated as variable-segment, for example, seg_outflow-1527 for stream segment outflow at segment 1527.