parasolpy.nowak

Nonparametric stochastic disaggregation after Nowak et al. (2010).

Reference:

Nowak, K., J. Prairie, B. Rajagopalan, and U. Lall (2010), A nonparametric stochastic approach for multisite disaggregation of annual to daily streamflow, Water Resour. Res., 46, W08529.

Functions

choose_analog_index(rng, Z, sim_Z)

Select an analog year index using K-nearest-neighbor weighting.

sim_multi_trace(rng, Z, p, years, sim_Z[, ...])

Disaggregate multiple simulated annual sequences into sub-annual traces.

sim_single_year(rng, Z, p, years, sim_Z[, ...])

Disaggregate one simulated annual flow into sub-annual periods.

parasolpy.nowak.choose_analog_index(rng, Z, sim_Z)[source]

Select an analog year index using K-nearest-neighbor weighting.

Finds the K nearest neighbors in Z to the simulated annual flow sim_Z (where K = floor(sqrt(len(Z)))), then draws one index with probability inversely proportional to rank distance (eq. 1 in the paper).

Parameters:
  • rng – numpy random Generator instance (e.g. numpy.random.default_rng()).

  • Z – 1-D numpy array of observed aggregated (annual) flows.

  • sim_Z – Scalar simulated aggregated flow for the current year.

Returns:

Index into Z of the chosen analog year.

Return type:

int

parasolpy.nowak.sim_single_year(rng, Z, p, years, sim_Z, print_results=False)[source]

Disaggregate one simulated annual flow into sub-annual periods.

Selects an analog year via choose_analog_index(), then scales its proportion vector by sim_Z to produce a disaggregated flow sequence.

Parameters:
  • rng – numpy random Generator instance.

  • Z – 1-D array of observed annual flows (length = number of historical years).

  • p – 2-D array of shape (num_years, num_periods) where each row is the fraction of annual flow in each sub-annual period.

  • years – 1-D array of calendar years corresponding to rows of p.

  • sim_Z – Scalar simulated annual flow for the year being disaggregated.

  • print_results – If True, print a one-line summary to stdout.

Returns:

1-D array of length num_periods with the disaggregated flow for each sub-annual period.

Return type:

numpy.ndarray

parasolpy.nowak.sim_multi_trace(rng, Z, p, years, sim_Z, repl=1, print_results=False)[source]

Disaggregate multiple simulated annual sequences into sub-annual traces.

Calls sim_single_year() for every combination of sequence, replicate, and year in sim_Z, assembling results into a single output matrix.

Parameters:
  • rng – numpy random Generator instance.

  • Z – 1-D array of observed annual flows.

  • p – 2-D array of shape (num_years, num_periods) with proportion vectors.

  • years – 1-D array of calendar years corresponding to rows of p.

  • sim_Z – 2-D array of shape (num_sequences, num_sim_years) with simulated annual flows; rows are independent sequences, columns are years.

  • repl – Number of replicates generated for each row of sim_Z. Defaults to 1.

  • print_results – If True, print per-year summary lines to stdout.

Returns:

2-D array of shape (num_periods * num_sim_years, num_sequences * repl) containing the disaggregated flows. Each column is one complete trace.

Return type:

numpy.ndarray