unsteady_flow¶
Read/write HEC-RAS unsteady flow files (.u**).
UnsteadyFlow — structured editor. Boundary conditions are
parsed into typed dataclass objects and may be sorted by river station.
save() reconstructs the boundary section from the objects; trailing
meteorological / non-Newtonian lines are still written verbatim.
Convention¶
get_* methods return None when the requested item is not found.
set_* methods raise KeyError when the target does not exist.
- class rivia.model.unsteady_flow.FlowHydrograph(river, reach, river_station, _location_tail='', interval='1HOUR', values=<factory>, flow_hydrograph_slope=None, stage_tw_check=0, dss_file='', dss_path='', use_dss=False, use_fixed_start=False, fixed_start=', ', is_critical=False, critical_boundary_flow='', _extra_lines=<factory>)[source]¶
Bases:
_BoundaryUpstream / internal flow hydrograph boundary.
- class rivia.model.unsteady_flow.FrictionSlope(river, reach, river_station, _location_tail='', slope=0.0, value2=0.0)[source]¶
Bases:
_BoundaryNormal-depth (friction slope) downstream boundary.
- Parameters:
- class rivia.model.unsteady_flow.GateBoundary(river, reach, river_station, _location_tail='', gates=<factory>)[source]¶
Bases:
_BoundaryInline structure with one or more gated openings.
- Parameters:
- gates: list[GateOpening]¶
- class rivia.model.unsteady_flow.GateOpening(gate_name='', dss_path='', use_dss=False, time_interval='1HOUR', use_fixed_start=False, fixed_start=', ', values=<factory>)[source]¶
Bases:
objectTime series of openings for one gate.
- Parameters:
- class rivia.model.unsteady_flow.InitialFlowLoc(river, reach, river_station, flow)[source]¶
Bases:
objectInitial flow at a river / reach / station.
- class rivia.model.unsteady_flow.InitialRainfallRunoffElev(river, reach, river_station, elevation)[source]¶
Bases:
objectInitial water surface elevation for a reservoir / RRR.
- class rivia.model.unsteady_flow.InitialStorageElev(name, elevation)[source]¶
Bases:
objectInitial water surface elevation for a storage area.
- class rivia.model.unsteady_flow.LateralInflow(river, reach, river_station, _location_tail='', interval='1HOUR', values=<factory>, is_uniform=False, dss_file='', dss_path='', use_dss=False, use_fixed_start=False, fixed_start=', ', is_critical=False, critical_boundary_flow='', _extra_lines=<factory>)[source]¶
Bases:
_BoundaryLateral or uniform lateral inflow hydrograph.
- Parameters:
- class rivia.model.unsteady_flow.NormalDepth(river, reach, river_station, _location_tail='', slope=0.0)[source]¶
Bases:
_BoundaryNormal-depth boundary specified as a single slope value.
- class rivia.model.unsteady_flow.RatingCurve(river, reach, river_station, _location_tail='', pairs=<factory>, dss_path='', use_dss=False, use_fixed_start=False, fixed_start=', ', is_critical=False, critical_boundary_flow='', _extra_lines=<factory>)[source]¶
Bases:
_BoundaryRating-curve downstream boundary.
- Parameters:
- class rivia.model.unsteady_flow.StageHydrograph(river, reach, river_station, _location_tail='', interval='1HOUR', values=<factory>, dss_path='', use_dss=False, use_fixed_start=False, fixed_start=', ', _extra_lines=<factory>)[source]¶
Bases:
_BoundaryStage (water-surface) hydrograph boundary.
- Parameters:
- class rivia.model.unsteady_flow.UnsteadyFlow(path)[source]¶
Bases:
objectStructured editor for HEC-RAS unsteady flow files (.u**).
Boundary conditions are parsed into typed dataclass objects stored in
boundaries. Boundaries may be sorted by river station (useful for workflows that address gates or lateral inflows by index).save()reconstructs the boundary section from the objects; the header, initial conditions, and trailing meteorological / Non-Newtonian lines are preserved verbatim.Note
save()is not byte-identical to the original when boundaries are reordered or values are changed, because the file is reconstructed from parsed objects — the file is reconstructed from parsed data.- Parameters:
path (str | Path)
- property flow_hydrographs: list[FlowHydrograph]¶
All
FlowHydrographboundaries, in file order.
- property friction_slopes: list[FrictionSlope]¶
All
FrictionSlopeboundaries, in file order.
- property gate_boundaries: list[GateBoundary]¶
All
GateBoundaryboundaries, in file order.
- get_flow_hydrograph(river, reach, rs)[source]¶
Return flow hydrograph values for the given location, or
None.
- get_gate_openings(river, reach, rs, gate_name)[source]¶
Return gate opening values for the given location and gate name, or
None.
- get_lateral_inflow(river, reach, rs)[source]¶
Return lateral inflow values for the given location, or
None.
- property lateral_inflows: list[LateralInflow]¶
All
LateralInflowboundaries, in file order.
- property restart: tuple[int, str | None]¶
Return
(flag, filename)for the restart configuration.flag is the
Use Restartvalue (0= disabled,1= enabled). filename is theRestart Filenamevalue, orNoneif absent.
- save(path=None)[source]¶
Reconstruct and write the unsteady flow file.
The file is built as: 1. Header lines (verbatim from parse) 2. Initial condition lines (reconstructed from objects) 3. Boundary section (reconstructed from
boundaries) 4. Trailing lines (verbatim from parse)
- set_all_gate_openings(values)[source]¶
Set gate opening values across all gates in all
GateBoundary.- Parameters:
values (
list[float|list[float]]) – One entry per gate (in order across all boundaries). Each entry is either a scalarfloat(broadcast to the gate’s existing time-series length) or alist[float](used as-is). Ifvaluesis shorter than the total number of gates, the remaining gates are left unchanged.- Return type:
- set_all_lateral_inflows(values)[source]¶
Set lateral inflow values across all
LateralInflowboundaries.- Parameters:
values (
list[float|list[float]]) – One entry per lateral inflow (in file order). Each entry is either a scalarfloat(broadcast to the boundary’s existing time-series length) or alist[float](used as-is). Ifvaluesis shorter than the total number of lateral inflows, the remaining boundaries are left unchanged.- Return type:
- set_flow_hydrograph(index, values)[source]¶
Set flow hydrograph values by position in
flow_hydrographs.
- set_gate_opening(index, values, gate_index=0)[source]¶
Set gate opening values by position in
gate_boundaries.
- set_gate_opening_at(river, reach, rs, gate, values)[source]¶
Set gate opening values by location and gate name or index.
- set_initial_flow(index, flow)[source]¶
Update the initial flow at index in
initial_flow_locs.- Parameters:
- Raises:
IndexError – index is out of range.
- Return type:
- set_lateral_inflow(index, values)[source]¶
Set lateral inflow values by position in
lateral_inflows.
- sort_flow_hydrographs(*, descending=True)[source]¶
Sort
FlowHydrographentries by river station.
- sort_gate_boundaries(*, descending=True)[source]¶
Sort
GateBoundaryentries by river station.Other boundary types remain at their original positions.
- sort_lateral_inflows(*, descending=True)[source]¶
Sort
LateralInflowentries by river station.