pywatershed.MmrToMf6Dfw#

class pywatershed.MmrToMf6Dfw(control_file=None, control=None, start_time=None, end_time=None, tdis_perlen=86400, tdis_nstp=1, param_file=None, params=None, segment_shp_file=None, output_dir=PosixPath('.'), bc_binary_files=False, bc_flows_combined=False, sim_name='mmr_to_dfw', inflow_dir=None, inflow_from_PRMS=True, save_flows=True, time_zone='UTC', write_on_init=False, chd_options=None, cxs_options=None, disv1d_options=None, dfw_options=None, dfw_griddata=None, flw_options=None, ic_options=None, ims_options=None, oc_options=None, sto_options=None)[source]#

PRMS Muskingum-Mann Routing (MMR) to MF6 Diffusive Wave (DFW).

Terms:

  • MMR: Muskingum-Mann Routing in PRMS

  • DFW: Diffusive Wave in MF6 (develop branch)

This class builds a MF6 simulation with Diffusive Wave (DFW) routing from PRMS NHM input files for Muskingum-Mann Routing (MMR) and a few simple assumptions. The lateral (to-channel) fluxes from a PRMS are used as time varying boundary conditions.

Please see the example notebook examples/mmr_to_mf6_dfw.ipynb which demonstrates running the Delaware River Basin in MF6 DFW based on the PRMS data and its lateral inflows.

In addition to standard MF6 packages and their input files (e.g. IMS, OC, etc), the surface water flow package is created with the diffusive wave (DFW) package and depends on the DISV1D and FLW boundary conditions. The cross sectional area (CXS) package is optional.

The daily inflows from PRMS can optionally be smoothed to desired sub-daily resolution of MF6 stress period length using mean preserving splines from the mpsplines python package jararias/mpsplines:

Ruiz-Arias, J. A. (2022). Mean-preserving interpolation with splines for solar radiation modeling. Solar Energy, Vol. 248, pp. 121-127.

PRMS MMR Parameters used and how:

  • tosegment:

    Used to give the reach/segment connectivity (transformed to zero based for use in python and flopy). No units.

  • seg_length:

    Used for SfwDisl, the discretization of the reaches, directly. Also used to calculate seg_mid_elevation if not present in parameters. Units of meters from metadata (these are converted to units requested for modflow, which we currently hardcode to meters and seconds.)

  • seg_slope:

    Passed directly to CHF DFW. Also used to calculate seg_mid_elevation if not present in parameters. See its description below. Unitless slope.

  • hru_segment:

    Used to calculate seg_mid_elevation if not present in parameters. See its description below. Unitless index mapping from PRMS HRUs to segments.

  • hru_elev:

    Used to calculate seg_mid_elevation if not present in parameters. See its description below. Units are in meters (though not documented in the metadata as such, just “elev_units”)

  • seg_width:

    This is (apparently) the NHD bank-full width present in the PRMS parameter files but unused in PRMS. Units are in meters.

  • mann_n:

    Mannings N coefficient for MMR. Passed directly to CHF DFW. Units in seconds / meter ** (1/3) according to the metadata.

The following optional parameters can be user-supplied but are NOT part of PRMS parameters:

  • seg_mid_elevation:

    The elevation at the mid-point of a segment. This is calculated always starting from one of the basin outlets. The outlet elevation is calculated as per chd_options[“stress_period_data”], the downstream end of the segment is assumed to have the elevation of the lowest HRU which maps to this segment

    outlet_downstream_elev = lowest_hru_elev

    The upstream end of the outlet segment is then calculated

    outlet_upstream_elev =  lowest_hru_elev + seg_length * seg_slope.

    The midpoint of the of the outlet is the average of upstream and downstream segment elevations. For all other segments above outlets, its downstream elevation is the same as its downstream segment’s upstream elevation and so

    segment_upstream_elev = downstream_seg_upstream_elev + seg_length * seg_slope.

    And its midpoint is again the average elevation between upstream and downstream elevations of the segment.

  • chd_options[“stress_period_data”]:

    At each outlet in the domain, this is taken as the lowest hru elevation over all hrus which map to this segment.

The MF6 IO descrption can be found here https://modflow6.readthedocs.io/en/latest/mf6io.html

__init__(control_file=None, control=None, start_time=None, end_time=None, tdis_perlen=86400, tdis_nstp=1, param_file=None, params=None, segment_shp_file=None, output_dir=PosixPath('.'), bc_binary_files=False, bc_flows_combined=False, sim_name='mmr_to_dfw', inflow_dir=None, inflow_from_PRMS=True, save_flows=True, time_zone='UTC', write_on_init=False, chd_options=None, cxs_options=None, disv1d_options=None, dfw_options=None, dfw_griddata=None, flw_options=None, ic_options=None, ims_options=None, oc_options=None, sto_options=None)[source]#

Instantiate a MmrToMf6Dfw object.

Parameters:
  • control_file (Union[str, Path]) – The path to a PRMS control file. Exactly one of this and control are required. If start and end times are the same, then the run is considered a steady state run.

  • control (Control) – a Control object. Exactly one of this and control are required.

  • start_time (datetime64) – np.datetime64 = None, to edit the start time.

  • end_time (datetime64) – np.datetime64 = None, to edit the simulation end time.

  • tdis_perlen (int) – The number of seconds in the MF6 stress periods. The value must evenly dvide 1 day or 86400 seconds. Currently the value must be the same for all stress periods. Default is 1 day = 86400s. For values less than the default, mean-preserving splines are used to smooth the flows to the desired resolution.

  • tdis_nstp (int) – The number of substeps in each stress period. The value must be the same for all stress periods and the default is 1.

  • param_file (Union[str, Path]) – The filepath to the domain parameters. Exactly one of this and the params argument is required.

  • params (PrmsParameters) – a Parameter object. Exactly one of this and the params argument is required.

  • segment_shp_file (Union[str, Path]) – a shapefile of segments assumptions are that this file has a column “nsevment_v” which is the same as “nhm_seg” in the parameter file and another column “model_idx” corresponding to the 1-based index of nhm_seg in the parameter file.

  • output_dir (Union[str, Path]) – Where to write and run the model.

  • bc_binary_files (bool) – Write binary files for the FLW boundary conditions.

  • bc_flows_combined (bool) – A single, combined boundary flow file, or 3 individual files for the 3 prms flux terms?

  • sim_name (str) – A name for the simulation.

  • inflow_dir (Union[str, Path]) – Where to find the PRMS to-channel flux files.

  • inflow_from_PRMS (bool) – The PRMS inflows are in depth while the inflows from pywatershed are volumetric and they have different names indicating this. The default is PRMS inflows.

  • save_flows (bool) – Set as a general MF6 option on all packages.

  • time_zone (str) – the timezone to use.

  • write_on_init (bool) – Write the MF6 files on initialization?

  • chd_options (dict) – Options to pass to flopy when making each MF6 package. These are not always applied and their effect should be checked on the MF6 input files written before running the model. Still a work in progress.

  • cxs_options (dict) – See above.

  • disv1d_options (dict) – See above.

  • dfw_options (dict) – See above.

  • dfw_griddata (dict) – See above.

  • flw_options (dict) – See above.

  • ic_options (dict) – See above.

  • ims_options (dict) – See above.

  • oc_options (dict) – See above.

  • sto_options (dict) – See above.

Methods

__init__([control_file, control, ...])

Instantiate a MmrToMf6Dfw object.

run(*args, **kwargs)

Run the simulation.

write(*args[, rewrite])

Write the simulation to disk.

run(*args, **kwargs)[source]#

Run the simulation.

Parameters:
  • *args – Arguments to pass to flopy’s sim.write_simulation.

  • **kwargs – Keyword arguments to pass to sim.write_simulation.

write(*args, rewrite=False, **kwargs)[source]#

Write the simulation to disk.

Parameters:
  • *args – Arguments to pass to flopy’s sim.write_simulation.

  • rewrite (bool) – Allow the simulation to be written more than once.

  • **kwargs – Keyword arguments to pass to sim.write_simulation.