iwfm.calib.divshort2obs

iwfm.calib.divshort2obs(budget_file, reach_file, nwidth=20)[source]

Convert diversion shortages from IWFM Stream Budget to the SMP file format for use by PEST.

(Based on STACDEP2OBS.F90 by Matt Tonkin, SSPA with routines by John Doherty.)

Reads budget_file and reach_file, then delegates the SMP/INS formatting to format_divshort_smp(). Use that helper directly if you already have parsed budget data.

Parameters:
  • budget_file (str) – Path to the IWFM stream budget output file (e.g. C2VSimCG_Streams_Budget.bud).

  • reach_file (str) – Path to the reach groups file (e.g. stgwgroups.in). See read_reaches() for format details.

  • nwidth (int, default=20) – Width of the name column in SMP output.

Returns:

  • divshort (list) – Diversion shortage values for each group in SMP format.

  • ins (list) – Corresponding PEST instructions for the SMP file.

Raises:
  • FileNotFoundError – If reach_file does not exist.

  • IndexError – If any group references a reach number beyond the budget file’s reach count (propagated from format_divshort_smp()).

  • ValueError – If the budget or reach file is malformed (numeric tokens fail to parse).