The tools are defined in pyDeltaRCM.shared_tools.

Shared functions

pyDeltaRCM.shared_tools.get_start_indices(inlet, inlet_weights, num_starts)
pyDeltaRCM.shared_tools.get_steps(new_cells, iwalk, jwalk)

Find the values giving the next step.


Pick number from weighted array.

Randomly pick a number weighted by array probabilities (len 9) Return the index of the selected weight in array probs Takes a numpy array that is the precalculated probability around the cell flattened to 1D.

pyDeltaRCM.shared_tools.custom_unravel(i, shape)

Unravel indexes for 2D array.

pyDeltaRCM.shared_tools.custom_ravel(tup, shape)

Ravel indexes for 2D array.

pyDeltaRCM.shared_tools.get_weight_sfc_int(stage, stage_nbrs, qx, qy, ivec, jvec, distances)

Determine random walk weight surfaces.

Determines the surfaces for weighting the random walks based on the stage and discharge fields.


Extract version from file.

Extract version number from single file, and make it availabe everywhere.

Time scaling functions

pyDeltaRCM.shared_tools.scale_model_time(time, If=1, units='seconds')

Scale the model time to “real” time.

Model time is executed as assumed flooding conditions, and executed at the per-second level, with a multi-second timestep. This model design implicitly assumes that the delta is always receiving a large volume of sediment and water at the inlet. This is unrealistic, given that rivers flood only during a small portion of the year, and this is when morphodynamic activity is largest. See Time in pyDeltaRCM for a complete description of this assumption, and how to work with the assumption in configuring the model.

Using this assumption, it is possible to scale up model time to “real” time, by assuming an intermittency factor. This intermittency factor is the fraction of unit-time that a river is assumed to be flooding.

t_r = \dfrac{t}{I_f \cdot S_f}

where t is the model time (time), t_r is the “real” scaled time, I_f is the intermittency factor, and S_f is the scale factor to convert base units of seconds to units specified as an input argument. Note that this function uses _scale_factor internally for this conversion.

  • time (float) – The model time, in seconds.

  • If (float, optional) – Intermittency factor, fraction of time represented by morphodynamic activity. Should be in interval (0, 1]. Defaults to 1 if not provided, i.e., no scaling is performed.

  • units (str, optional) – The units to convert the scaled time to. Default is to return the scaled time in seconds (seconds), but optionally supply argument days or years for unit conversion.


scaled – Scaled time, in units, assuming the intermittency factor If.

Return type



ValueError – if the value for intermittency is not 0 < If <= 1.

pyDeltaRCM.shared_tools._scale_factor(If, units)

Scaling factor between model time and “real” time.

The scaling factor relates the model time to a real worl time, by the assumed intermittency factor and the user-specified units for output.

  • If (float) – Intermittency factor, fraction of time represented by morphodynamic activity. Must be in interval (0, 1].

  • units (str) – The units to convert the scaled time to. Must be a string in [‘seconds’, ‘days’, ‘years’].