steady_flow¶
Read/write HEC-RAS steady flow files (.f**).
SteadyFlow — verbatim-line editor. All lines are stored
verbatim; only the specific data blocks that are mutated are reformatted.
save() is byte-faithful for every unmodified line.
File format notes:
Flow data: each
River Rch & RM=River,Reach,RSline is immediately followed by N flow values (one per profile) in 8-char fixed-width columns, up to 10 per row. NoNum Of Flows=orFlow=prefix.Boundary conditions: one
Boundary for River Rch & Prof#=River,Reach,Nblock per reach endpoint per profile. Up/Dn type codes:0 — None 1 — Known WS (``Up/Dn Known WS=<value>``) 2 — Critical Depth (no additional data) 3 — Normal Depth (``Up/Dn Slope=<value>``) 4 — Rating Curve (``Up/Dn Nval=<count>`` + interleaved stage/flow pairs)
Derived from format inspection of HEC-RAS 6.6 example files.
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.steady_flow.SteadyBoundary(river, reach, profile, up_type=0, dn_type=0, up_known_ws=None, dn_known_ws=None, up_slope=None, dn_slope=None, up_rating_curve=<factory>, dn_rating_curve=<factory>)[source]¶
Bases:
objectBoundary conditions for one river/reach endpoint for one flow profile.
up_type/dn_typeencode the condition type:0 — None (no BC) 1 — Known WS (``up_known_ws`` / ``dn_known_ws``) 2 — Critical Depth (no additional data required) 3 — Normal Depth (``up_slope`` / ``dn_slope``) 4 — Rating Curve (``up_rating_curve`` / ``dn_rating_curve``)
profileis 1-based and matches the profile index in the steady flow file (Boundary for River Rch & Prof#=..., 1).- Parameters:
- class rivia.model.steady_flow.SteadyFlow(path)[source]¶
Bases:
objectVerbatim-line editor for HEC-RAS steady flow files (.f**).
All lines are loaded into memory verbatim. Targeted edits (e.g. replacing flow values at a cross-section or updating a boundary condition) splice new formatted lines into the list while leaving every other line byte-identical.
save()writes the list back; a no-op parse+save produces an identical file.Flow data is accessed by river / reach / river-station string (
get_flows/set_flows). Boundary conditions are accessed by river / reach / 1-based profile number (get_boundary/set_boundary).Derived from format inspection of HEC-RAS 6.6 example files.
- Parameters:
path (str | Path)
- get_boundaries(river, reach)[source]¶
Return all boundary conditions for a river/reach, sorted by profile.
Returns an empty list if no matching boundaries are found.
- Return type:
- Parameters:
- get_boundary(river, reach, profile)[source]¶
Return the boundary conditions for the given reach endpoint and profile.
Returns
Noneif no matchingBoundary for River Rch & Prof#line is found.- Return type:
- Parameters:
- get_flows(river, reach, rs)[source]¶
Return flow values (one per profile) at the given location.
Returns
Noneif no matchingRiver Rch & RMline is found. Returns[]if the location exists but contains no parseable values.
- property profile_names: list[str]¶
Profile names from the header
Profile Names=line, stripped.Returns an empty list if the key is absent.
- property program_version: str | None¶
HEC-RAS version string.
Checks
Program Version=first (modern format), then falls back toVersion=(pre-v4 files such as older WAILUPE-style projects). Treat as read-only; HEC-RAS manages this field.
- save(path=None)[source]¶
Write all in-memory lines back to disk.
If path is omitted the source file is overwritten.
- set_boundary(boundary)[source]¶
Replace the boundary conditions at the given location.
The entire boundary block (from
Boundary for River Rch & Prof#=through its fields) is rebuilt from boundary. Fields irrelevant to the set type are omitted (e.g.Dn Slope=is not written whendn_type != 3).- Raises:
KeyError – No matching
Boundary for River Rch & Prof#line found.- Return type:
- Parameters:
boundary (SteadyBoundary)