geometry¶
Read/write HEC-RAS geometry files (.g**).
Geometry — verbatim-line editor for HEC-RAS 1-D geometry files
(.g01, .g02, …). All lines are stored verbatim. Typed access is provided
for:
File metadata (
title,program_version,viewing_rectangle)Reach / node inventory (
reaches,junctions,node_rs_list)Cross-section data:
#Sta/Elev,#Mann,Bank Sta,#XS Ineff,Exp/Cntr,Levee,#Block Obstruct,XS HTab Starting El and Incr(read viaget_cross_section(), write via targeted setters)Structure nodes (bridge, culvert, inline/lateral structure) preserved verbatim and accessible via
get_node_lines()
save() is byte-faithful for every unmodified line.
Node type codes in Type RM Length L Ch R = TYPE, ...:
1 — Cross Section
2 — Culvert (single or twin-pipe)
3 — Bridge
4 — Multiple Opening
5 — Inline Structure
6 — Lateral Structure
Cross-section fixed-width format (8-char columns):
#Sta/Elev= N alternating station/elevation pairs, 10 per row
#Mann= N,t,a triplets (station, n-value, variation), 9 per row
#XS Ineff= N triplets (x_start, x_end, elevation), 9 per row
followed by Permanent Ineff= flags (8-char, 10/row)
#Block Obstruct= N,t triplets (x_start, x_end, elevation), 9 per row
Levee=lf,ls,le,rf,rs,re[,lfe,rfe]
left/right flag(-1=active), station, elevation,
optional failure elevations
XS HTab Starting El and Incr=el,incr,count
Vertical (depth/flow-varying) Manning’s n — appears between XS Rating Curve=
and Exp/Cntr= when active:
Vertical n Elevations= N N WSE or flow breakpoints (8-char cols, 10/row)
Vertical n for Station=S per-station entry; N n-values follow (8-char, 10/row)
...
Vertical n Flow= F F=0 → WSE breakpoints; F=-1 → flow breakpoints
When vertical n is active, #Mann= N , 0 , 0 stores zone boundary stations
only; n-values in that block are all zero (placeholders).
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.geometry.BlockedObstruction(x_start, x_end, elevation)[source]¶
Bases:
objectOne blocked-obstruction interval in a cross section (
#Block Obstruct).Flow area between x_start and x_end is blocked up to elevation. Use a very large elevation (e.g.
999) for a permanently blocked zone.- Variables:
x_start – Left boundary station.
x_end – Right boundary station.
elevation – Elevation ceiling of the blocked zone.
- Parameters:
- class rivia.model.geometry.Bridge(mode, upstream_type, downstream_type, centerline=<factory>, location=('', '', ''), upstream_node=('', '', ''), downstream_node=('', '', ''), weir=None, gate_groups=<factory>, description='', roadway=None, culvert_groups=<factory>, piers=<factory>, node_name='', htab_hw_max=None, htab_tw_max=None, htab_max_flow=None)[source]¶
Bases:
StructureBridge or culvert (node types 3 / 2) parsed from a
.g**text geometry file.Mirrors
rivia.hdf.geometry.Bridge. Inheritsmode,upstream_type,downstream_type, andcenterlinefromStructure.Differences vs the HDF version:
weir: populated from theDeck Distdata line scalar fields (width, coefficient, skew, max_submergence, shape);us_slope,ds_slope, anduse_water_surfaceare alwaysnan/False— not stored in the text format. Redundant withroadwayscalars.roadway: full deck geometry including upstream/downstream station, high-chord, and low-chord arrays;Nonewhen noDeck Distline is present.culvert_groups: barrel definitions fromCulvert=lines.piers: pier groups fromPier Skew, ...blocks.gate_groups: always[]— bridge/culvert format usesBridge Culverthydraulics, notIW Gate Nameblocks.description: text-file-specific field fromBEGIN/END DESCRIPTION; no equivalent in HDF.
- Variables:
location –
(river, reach, rs)of this structure.upstream_node –
(river, reach, rs)of the nearest upstream XS;("", "", "")when none found.downstream_node –
(river, reach, rs)of the nearest downstream XS;("", "", "")when none found.weir – Overflow weir scalars from the
Deck Distline;Noneif the line is absent.gate_groups – Always
[].description – Node description from
BEGIN/END DESCRIPTION.roadway – Full deck geometry (stations, hi/lo chords) from the
Deck Distblock;Nonewhen absent.culvert_groups – Barrel definitions from
Culvert=lines.piers – Pier groups from
Pier Skew, ...blocks.node_name – Node name from
Node Name=; empty string when absent.htab_hw_max – Max headwater elevation from
BC HTab HWMax=;Nonewhen absent.htab_tw_max – Max tailwater elevation from
BC HTab TWMax=;Nonewhen absent.htab_max_flow – Max flow from
BC HTab MaxFlow=;Nonewhen absent.
- Parameters:
- culvert_groups: list[CulvertGroup]¶
- class rivia.model.geometry.CrossSection(river, reach, rs, description='', stations=<factory>, elevations=<factory>, mann_entries=<factory>, mann_type=0, mann_alt=0, bank_left=None, bank_right=None, ineff_areas=<factory>, expansion=0.3, contraction=0.1, left_length=None, channel_length=None, right_length=None, interpolated=False, vertical_n=None, levee_left=None, levee_right=None, blocked_obstructions=<factory>, htab_starting_elevation=None, htab_increment=None, htab_count=None)[source]¶
Bases:
objectParsed data for one HEC-RAS cross section (node type 1).
Returned by
Geometry.get_cross_section(). Write changes back with the targeted setters onGeometry(set_mannings,set_stations,set_bank_stations,set_exp_cntr).- Variables:
river – River name.
reach – Reach name.
rs – River station string (normalised: no trailing whitespace or
*interpolation marker).description – Node description from
BEGIN/END DESCRIPTION.stations – Station values from
#Sta/Elev.elevations – Elevation values from
#Sta/Elev.mann_entries – Manning’s n zones from
#Mann.mann_type – Type flag from
#Mann= N , type , altheader.mann_alt – Alt flag from
#Mann= N , type , altheader.bank_left – Left bank station (
Bank Sta).bank_right – Right bank station (
Bank Sta).ineff_areas – Ineffective flow areas (
#XS Ineff).expansion – Expansion loss coefficient (
Exp/Cntr).contraction – Contraction loss coefficient (
Exp/Cntr).left_length – Left overbank reach length from node header.
channel_length – Channel reach length from node header.
right_length – Right overbank reach length from node header.
interpolated –
Trueif the RS string had a trailing*(HEC-RAS interpolated cross section).vertical_n – Vertical (depth/flow-varying) Manning’s n, or
Noneif the cross section uses flat n-values.levee_left – Left-bank levee (
Levee=line), orNone.levee_right – Right-bank levee (
Levee=line), orNone.blocked_obstructions – Blocked-obstruction intervals (
#Block Obstruct).htab_starting_elevation – Starting elevation for the hydraulic table (
XS HTab Starting El and Incr).htab_increment – Elevation increment for the hydraulic table.
htab_count – Number of entries in the hydraulic table.
- Parameters:
river (str)
reach (str)
rs (str)
description (str)
mann_entries (list[ManningEntry])
mann_type (int)
mann_alt (int)
bank_left (float | None)
bank_right (float | None)
expansion (float)
contraction (float)
left_length (float | None)
channel_length (float | None)
right_length (float | None)
interpolated (bool)
vertical_n (VerticalN | None)
levee_left (LeveeData | None)
levee_right (LeveeData | None)
blocked_obstructions (list[BlockedObstruction])
htab_starting_elevation (float | None)
htab_increment (float | None)
htab_count (int | None)
- blocked_obstructions: list[BlockedObstruction]¶
- mann_entries: list[ManningEntry]¶
- class rivia.model.geometry.CulvertGroup(name, shape_code, shape_name, span, rise, length, n_top, entrance_loss, exit_loss, inlet_type, outlet_type, upstream_invert, upstream_station, downstream_invert, downstream_station, chart_number, num_barrels=1, n_bottom=None, depth_n_bottom=None)[source]¶
Bases:
objectOne culvert barrel definition from a
Culvert=line.Field order matches the comma-separated data on the
Culvert=line:shape, span, rise, length, n, Ke, exit_loss, inlet_type, outlet_type, us_invert, us_station, ds_invert, ds_station, name, ?, chart_number
- Variables:
name – Culvert identifier (index 13), e.g.
'Culvert # 1'.shape_code – Shape code (index 0) — see
_CULVERT_SHAPES.shape_name – Human-readable shape, e.g.
'Circular','Box'.span – Width or diameter (index 1).
rise – Height (index 2);
0.0when blank.length – Barrel length (index 3).
n_top – Manning’s roughness coefficient (index 4).
entrance_loss – Entrance loss coefficient Ke (index 5).
exit_loss – Exit loss coefficient (index 6).
inlet_type – Inlet control type code (index 7).
outlet_type – Outlet control type code (index 8).
upstream_invert – Upstream invert elevation (index 9).
upstream_station – Upstream station location (index 10).
downstream_invert – Downstream invert elevation (index 11).
downstream_station – Downstream station location (index 12).
chart_number – Inlet control chart number (index 15).
num_barrels – Number of barrels — from
BC Culvert Barrel=line;1when that line is absent.n_bottom – Bottom Manning’s n — from
Culvert Bottom n=;Nonewhen absent.depth_n_bottom – Bottom fill depth — from
Culvert Bottom Depth=;Nonewhen absent.TODO (..) – (no
us_station/ds_stationcolumns; barrel stations appear on the next line asnum_barrelsupstream +num_barrelsdownstream values in 8-char fixed-width columns). These station values are currently not parsed.
- Parameters:
name (str)
shape_code (int)
shape_name (str)
span (float)
rise (float)
length (float)
n_top (float)
entrance_loss (float)
exit_loss (float)
inlet_type (int)
outlet_type (int)
upstream_invert (float)
upstream_station (float)
downstream_invert (float)
downstream_station (float)
chart_number (int)
num_barrels (int)
n_bottom (float | None)
depth_n_bottom (float | None)
- class rivia.model.geometry.GateGroup(name, width, height, invert, gate_coefficient, trunnion_exponent, opening_exponent, height_exponent, gate_type, weir_coefficient, is_ogee, spillway_approach_height, design_energy_head, trunnion_height, orifice_coefficient, head_reference, radial_coefficient, is_sharp_crested, use_weir_param1, use_weir_param2, use_weir_param3, openings=<factory>)[source]¶
Bases:
objectOne gate group in an inline structure (
IW Gate Nameblock).Field order follows the comma-delimited
IW Gate Namedata line:name,Wd,H,Inv,GCoef,Exp_T,Exp_O,Exp_H,Type,WCoef,Is_Ogee, SpillHt,DesHd,#Openings,trunnion_height,orifice_coef, head_ref,radial_coef,,is_sharp_crested,weir_p1,weir_p2,weir_p3
- Variables:
name – Group name (index 0).
width – Gate width —
Wd(index 1).height – Gate height —
H(index 2).invert – Gate invert elevation —
Inv(index 3).gate_coefficient – Gate discharge coefficient (applies to all gate types) —
GCoef(index 4). The HDF version names this fieldsluice_coefficient.trunnion_exponent – Trunnion arm exponent —
Exp_T(index 5).opening_exponent – Gate opening exponent —
Exp_O(index 6).height_exponent – Gate height exponent —
Exp_H(index 7).gate_type – Gate type string —
Type(index 8):'sluice','radial','overflow_closed_top','overflow_open', or'user_defined_curves'.weir_coefficient – Overflow weir coefficient —
WCoef(index 9).is_ogee –
TruewhenIs_Ogee(index 10) is-1(ogee crest shape).spillway_approach_height – Spillway approach height —
SpillHt(index 11).design_energy_head – Design energy head —
DesHd(index 12).trunnion_height – Trunnion height (index 14).
orifice_coefficient – Orifice coefficient (index 15).
head_reference – Head reference point — 0 = sill, 1 = centre of opening (index 16).
radial_coefficient – Radial (Tainter) gate discharge coefficient (index 17).
is_sharp_crested –
Truewhen index 19 is-1.use_weir_param1 –
Truewhen index 20 is-1.use_weir_param2 –
Truewhen index 21 is-1.use_weir_param3 –
Truewhen index 22 is-1.openings – Individual gate openings (stations + names).
- Parameters:
name (str)
width (float)
height (float)
invert (float)
gate_coefficient (float)
trunnion_exponent (float)
opening_exponent (float)
height_exponent (float)
gate_type (str)
weir_coefficient (float)
is_ogee (bool)
spillway_approach_height (float)
design_energy_head (float)
trunnion_height (float)
orifice_coefficient (float)
head_reference (int)
radial_coefficient (float)
is_sharp_crested (bool)
use_weir_param1 (bool)
use_weir_param2 (bool)
use_weir_param3 (bool)
openings (list[GateOpening])
- property Cs: float¶
Submerged discharge coefficient (alias for
orifice_coefficient).Typical value ~0.8; applied when tailwater submerges the gate opening.
- property Cu: float¶
Unsubmerged discharge coefficient (alias for
gate_coefficient).Typical range 0.5–0.7 for sluice and radial gates.
- openings: list[GateOpening]¶
- class rivia.model.geometry.GateOpening(name, station, gis=<factory>)[source]¶
Bases:
objectOne gate opening within a gate group.
- Variables:
name – Opening name from
IW Gate Opening=line; empty string when the line is absent.station – Lateral station of the gate opening (8-char fixed-width column).
gis – GIS (x, y) coordinate pairs from the data line following the
IW Gate Opening=line (16-char fixed-width columns). Empty list when the GIS point count is zero.
- Parameters:
- class rivia.model.geometry.Geometry(path)[source]¶
Bases:
objectVerbatim-line editor for HEC-RAS geometry files (.g**).
All lines are loaded verbatim. Structured cross-section data can be read (
get_cross_section(),cross_sections()) and written (set_mannings(),set_stations(),set_bank_stations(),set_exp_cntr()). Structure nodes (bridges, culverts, etc.) are accessible as raw lines viaget_node_lines().save()writes all in-memory lines back to disk; a no-op parse+save produces a byte-identical file.- Parameters:
path (str | Path)
- all_cross_sections()[source]¶
Return every cross section in the geometry, in file order.
Iterates all reaches and collects cross sections from each. Structure nodes (bridges, culverts, etc.) are skipped.
- Return type:
- cross_sections(river, reach)[source]¶
Return all cross sections in reach, in file order.
Structure nodes (bridges, culverts, etc.) are skipped.
- Return type:
- Parameters:
- get_cross_section(river, reach, rs)[source]¶
Parse and return the cross section at (river, reach, rs).
Returns
Noneif not found or if the node is not a cross section (type != 1).- Return type:
- Parameters:
- get_node_lines(river, reach, rs)[source]¶
Return the raw lines for a node block (header inclusive).
Useful for inspecting structure nodes (bridges, culverts, etc.) that are not fully parsed. Returns
Noneif not found.
- inline_gate_groups(river, reach, rs)[source]¶
Return gate group names for an inline structure, in file order.
Parses
IW Gate Nameheader lines from the node block. The name is the first comma-separated field on the data line that immediately follows each header line.
- node_rs_list(river, reach)[source]¶
Return
(node_type, rs)pairs for every node in reach.Useful for surveying what cross sections and structures exist. Results are in file order (upstream to downstream for standard HEC-RAS convention).
- node_type(river, reach, rs)[source]¶
Return the node type code for (river, reach, rs), or
None.Returns one of
NodeType.CROSS_SECTION,NodeType.CULVERT,NodeType.BRIDGE,NodeType.MULTIPLE_OPENING,NodeType.INLINE_STRUCTURE,NodeType.LATERAL_STRUCTURE.
- property program_version: str | None¶
HEC-RAS version that wrote this file (
Program Version=).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_bank_stations(river, reach, rs, left, right)[source]¶
Set the left and right bank stations for the given cross section.
- set_blocked_obstructions(river, reach, rs, obstructions)[source]¶
Replace or remove the blocked-obstruction block for the given XS.
Pass an empty list to remove any existing
#Block Obstruct=block. When no block exists, the new block is inserted beforeBank Sta=.
- set_exp_cntr(river, reach, rs, expansion, contraction)[source]¶
Set the expansion/contraction loss coefficients.
- set_htab(river, reach, rs, starting_elevation, increment, count)[source]¶
Set the hydraulic-table parameters for the given cross section.
Replaces the
XS HTab Starting El and Incr=line in-place, or inserts it afterXS Rating Curve=if absent.- Parameters:
river (
str) – River name (case-insensitive).reach (
str) – Reach name (case-insensitive).rs (
str) – River station string.starting_elevation (
float) – First elevation in the hydraulic table.increment (
float) – Elevation increment between table entries.count (
int) – Number of entries in the hydraulic table.
- Raises:
KeyError – No matching cross-section node found.
- Return type:
- set_levee(river, reach, rs, left, right)[source]¶
Set or remove levee data for the given cross section.
Pass
Nonefor both left and right to remove any existingLevee=line. The line is replaced in-place when it already exists; otherwise it is inserted before#XS Ineff=orBank Sta=.- Parameters:
- Raises:
KeyError – No matching cross-section node found.
- Return type:
- set_mannings(river, reach, rs, entries, mann_type=None, mann_alt=None)[source]¶
Replace the Manning’s n data for the given cross section.
The
#Mann=header and data rows are rebuilt from entries. If mann_type or mann_alt areNone, the existing values from the file are preserved.- Parameters:
river (
str) – River name (case-insensitive).reach (
str) – Reach name (case-insensitive).rs (
str) – River station string (leading/trailing whitespace and trailing*are ignored in comparisons).entries (
list[ManningEntry]) – New Manning’s n zones (station, n_value, variation).mann_type (
int|None) – Type flag for the#Mann=header.Nonekeeps the existing value.mann_alt (
int|None) – Alt flag for the#Mann=header.Nonekeeps the existing value.
- Raises:
KeyError – No matching node or no
#Mann=line found.- Return type:
- set_stations(river, reach, rs, stations, elevations)[source]¶
Replace the station/elevation data for the given cross section.
- Parameters:
- Raises:
ValueError – stations and elevations have different lengths.
KeyError – No matching node or no
#Sta/Elev=line found.
- Return type:
- set_vertical_n(river, reach, rs, vertical_n)[source]¶
Replace or remove the vertical n block for the given cross section.
When vertical_n is not
Nonethe existing block (if any) is replaced in-place; if none exists, the block is inserted after theXS Rating Curve=line. PassingNoneremoves any existing block.The caller is responsible for ensuring the
#Mannblock still contains valid zone boundary stations. When vertical n is active HEC-RAS expects those n-values to be0(placeholders).
- property structures: StructureCollection¶
Structure collection parsed from this geometry file.
Returns a
StructureCollectionwhoseinlinesproperty holds all inline structures keyed by'River Reach RS'. The result is cached; invalidated automatically onsave().Example:
g = Geometry("model.g01") for key, iw in g.structures.inlines.items(): print(key, [gg.name for gg in iw.gate_groups])
- class rivia.model.geometry.IneffArea(x_start, x_end, elevation, permanent=False)[source]¶
Bases:
objectOne ineffective flow area interval.
- Variables:
x_start – Left boundary station.
x_end – Right boundary station.
elevation – Activation elevation (area is ineffective below this).
permanent –
Trueif always active (Tflag),Falseif elevation-triggered (Fflag).
- Parameters:
- class rivia.model.geometry.InlineStructure(mode, upstream_type, downstream_type, centerline=<factory>, location=('', '', ''), upstream_node=('', '', ''), downstream_node=('', '', ''), weir=None, gate_groups=<factory>, description='', pilot_flow=0.0, crest_profile=<factory>)[source]¶
Bases:
StructureInline structure (node type 5) parsed from a
.g**text geometry file.Mirrors
rivia.hdf.geometry.InlineStructure. Inheritsmode,upstream_type,downstream_type, andcenterlinefromStructure.Differences vs the HDF version:
upstream_node/downstream_node: use("", "", "")as the no-value sentinel (same as HDF), populated by walkingnode_rs_listto find the nearest flanking cross sections.weir: populated fromIW Disteven whenmodeis''(HDF returnsNoneformode='').description: text-file-specific field from theBEGIN/END DESCRIPTIONblock; no equivalent in HDF.pilot_flow: minimum flow through the structure when all gates are fully closed — fromIW Pilot Flow=; no equivalent in HDF.crest_profile: station/elevation pairs defining the weir crest geometry — from the#Inline Weir SE=block; no equivalent in HDF.
- Variables:
location –
(river, reach, rs)of this structure.upstream_node –
(river, reach, rs)of the nearest upstream XS;("", "", "")when none found.downstream_node –
(river, reach, rs)of the nearest downstream XS;("", "", "")when none found.weir – Overflow weir data from
IW Distblock;Noneif noIW Distline is present.gate_groups – Gate group definitions from
IW Gate Nameblocks.description – Node description from
BEGIN/END DESCRIPTION.pilot_flow – Minimum (pilot) flow through the structure —
IW Pilot Flow=;0.0when absent.crest_profile – Weir crest station/elevation pairs from the
#Inline Weir SE=block; empty list when absent.
- Parameters:
- class rivia.model.geometry.LateralStructure(mode, upstream_type, downstream_type, centerline=<factory>, location=('', '', ''), upstream_node=('', '', ''), downstream_node='', weir=None, gate_groups=<factory>, description='', pos=0, distance=nan, crest_profile=<factory>, flap_gates=False, tw_multiple_xs=False)[source]¶
Bases:
StructureLateral structure (node type 6) parsed from a
.g**text geometry file.Mirrors
rivia.hdf.geometry.LateralStructure. Inheritsmode,upstream_type,downstream_type, andcenterlinefromStructure.Differences vs the HDF version:
downstream_node: HDF stores the name of the connected Storage Area or 2-D Flow Area. The text format stores a connected river+reach viaLateral Weir End=river,reach,rs,...; this field holds"river reach"(stripped, space-joined). Empty string when theLateral Weir End=line is absent.weir: built from individualLateral Weir WD=,Lateral Weir Coef=, andLateral Weir WSCriteria=lines;skew=0,min_elevation=nan,us_slope/ds_slope=nan.gate_groups: always[]— lateral structures in the text format useLateral Weirhydraulics, notIW Gate Nameblocks.description: text-file-specific field fromBEGIN/END DESCRIPTION; no equivalent in HDF.
- Variables:
location –
(river, reach, rs)of this structure.upstream_node –
(river, reach, rs)of the nearest upstream XS;("", "", "")when none found.downstream_node – Connected river+reach as
"river reach"(fromLateral Weir End=); empty string when absent.weir – Overflow weir data from
Lateral Weirlines;Noneif noLateral Weir WD=line is present.gate_groups – Always
[].description – Node description from
BEGIN/END DESCRIPTION.pos – Bank side of the weir —
0= left,1= right (fromLateral Weir Pos=).distance – Setback distance from the upstream cross section (from
Lateral Weir Distance=);nanwhen absent.crest_profile – Weir crest station/elevation pairs from the
Lateral Weir SE=block; empty list when absent.flap_gates –
TruewhenLateral Weir Flap Gates= -1or1;Falsewhen0or absent.tw_multiple_xs –
Truewhen tailwater uses multiple XS averaging (Lateral Weir TW Multiple XS=non-zero).TODO (..) – and six coefficients) is not yet parsed.
TODO – yet parsed.
TODO – position code and distance) is not yet parsed.
TODO – coordinate block) is not yet parsed.
TODO – parsed.
- Parameters:
- class rivia.model.geometry.LeveeData(station, elevation, failure_elevation=None)[source]¶
Bases:
objectLevee definition for one bank of a cross section.
Encoded on the
Levee=line as a-1active flag followed by station and elevation.- Variables:
station – Lateral station of the levee crest.
elevation – Levee crest elevation.
failure_elevation – Elevation at which the levee fails;
Noneif not specified.
- Parameters:
- class rivia.model.geometry.ManningEntry(station, n_value, variation=0.0)[source]¶
Bases:
objectOne horizontal Manning’s n zone.
- Variables:
station – Left boundary station of this n zone.
n_value – Manning’s roughness coefficient.
variation – Third column in the HEC-RAS file. Usually
0; used for vertical-n or alternative-n assignments.
- Parameters:
- class rivia.model.geometry.NodeType(value)[source]¶
Bases:
IntEnumNode type codes from the
Type RM Length L Ch R = TYPE, ...line.- BRIDGE = 3¶
- CROSS_SECTION = 1¶
- CULVERT = 2¶
- INLINE_STRUCTURE = 5¶
- LATERAL_STRUCTURE = 6¶
- MULTIPLE_OPENING = 4¶
- class rivia.model.geometry.Pier(skew, upstream_station, upstream_count, downstream_station, downstream_count, upstream_widths, upstream_elevations, downstream_widths, downstream_elevations)[source]¶
Bases:
objectOne pier group from a
Pier Skew, UpSta & Num, DnSta & Num=block.The header line carries the skew, station, and count; four fixed-width blocks (8-char columns, up to 10 per row) immediately follow:
upstream_count widths upstream_count elevations downstream_count widths downstream_count elevations
- Variables:
skew – Pier skew angle in degrees;
0.0when blank.upstream_station – Station of the upstream pier face.
upstream_count – Number of upstream pier elements.
downstream_station – Station of the downstream pier face.
downstream_count – Number of downstream pier elements.
upstream_widths – Width of each upstream pier element.
upstream_elevations – Top-of-pier elevation for each upstream element.
downstream_widths – Width of each downstream pier element.
downstream_elevations – Top-of-pier elevation for each downstream element.
- Parameters:
- class rivia.model.geometry.Roadway(dist, width, weir_coefficient, skew, max_submergence, shape, min_lo_chord, max_hi_chord, stations_up=<factory>, hi_chord_up=<factory>, lo_chord_up=<factory>, stations_dn=<factory>, hi_chord_dn=<factory>, lo_chord_dn=<factory>)[source]¶
Bases:
objectDeck/roadway geometry from the
Deck Dist Width WeirC ...block.The header
Deck Dist Width WeirC Skew NumUp NumDn MinLoCord MaxHiCord MaxSubmerge Is_Ogeeis followed by a comma-separated data line and then six fixed-width blocks (8-char columns, up to 10 values per row):numUp upstream deck stations
numUp upstream high-chord (top of deck) elevations
numUp upstream low-chord (soffit) elevations
numDn downstream versions of the above (same layout)
lo_chord_up/lo_chord_dnwill be an empty list when the corresponding block is all-blank (some culvert files omit low-chord data).- Variables:
dist – Distance from the upstream cross section to the bridge face (index 0).
width – Deck/roadway width (index 1).
weir_coefficient – Overflow weir discharge coefficient (index 2).
skew – Bridge skew angle in degrees (index 3).
max_submergence – Maximum submergence ratio (index 8);
nanwhen blank.shape – Overflow weir crest shape —
'Broad Crested'or'Ogee'(from Is_Ogee flag, index 9).min_lo_chord – Minimum low-chord elevation (index 6);
nanwhen blank.max_hi_chord – Maximum high-chord elevation (index 7);
nanwhen blank.stations_up – Upstream deck station values.
hi_chord_up – Upstream high-chord (top of deck) elevations.
lo_chord_up – Upstream low-chord (soffit) elevations; empty list when the block is all-blank.
stations_dn – Downstream deck station values.
hi_chord_dn – Downstream high-chord elevations.
lo_chord_dn – Downstream low-chord elevations; empty list when all-blank.
TODO (..) –
Deck Dist) encodes open-deck / culvert-only options and is not yet parsed.TODO – Yarnell K factor, etc.) is not yet parsed.
TODO – parsed.
TODO
- Parameters:
- class rivia.model.geometry.Structure(mode, upstream_type, downstream_type, centerline=<factory>)[source]¶
Bases:
objectBase class for one HEC-RAS structure parsed from a text geometry file.
Mirrors
rivia.hdf.geometry.Structurein field names. Key difference:centerline: the text geometry file carries no GIS centreline coordinates for structures; always an empty list. The HDF version stores an(n_pts, 2)numpy array.
- Variables:
mode –
HEC-RAS mode string (e.g.
'Weir/Gate/Culverts'). Always''for inline structures — not stored in the text format.upstream_type – Connection type on the upstream side (
'XS','SA','2D', or'--'). Always'XS'for inline structures.downstream_type – Connection type on the downstream side.
centerline – GIS centreline as
[(x, y), ...]; always[]from text files.
- Parameters:
- class rivia.model.geometry.StructureCollection(inlines, bridges, laterals)[source]¶
Bases:
objectStructure collection parsed from a HEC-RAS text geometry file.
Covers inline structures (node type 5), bridges/culverts (types 3/2), and lateral structures (type 6).
Access structures via the typed properties:
g = Geometry("model.g01") for key, iw in g.structures.inlines.items(): print(key, iw.gate_groups) for key, br in g.structures.bridges.items(): print(key, br.weir) for key, lat in g.structures.laterals.items(): print(key, lat.downstream_node)
- Parameters:
- property bridges: StructureIndex[Bridge]¶
All bridges and culverts (types 3 and 2) keyed by
'River Reach RS'.
- property inlines: StructureIndex[InlineStructure]¶
All inline structures (type 5) keyed by
'River Reach RS'.
- property laterals: StructureIndex[LateralStructure]¶
All lateral structures (type 6) keyed by
'River Reach RS'.
- class rivia.model.geometry.StructureIndex(items)[source]¶
Bases:
Generic[_T]Read-only ordered mapping from a string key to a structure object.
Supports both string key (
"River Reach RS") and integer positional index. Mirrors the interface ofStructureIndex.
- class rivia.model.geometry.VerticalN(breakpoints, by_flow, stations)[source]¶
Bases:
objectVertical (depth/flow-varying) Manning’s n for a cross section.
HEC-RAS stores this block between
XS Rating Curve=andExp/Cntr=when vertical variation is active. The#Mannblock in the same XS still defines zone boundaries but carries placeholder zero n-values.- Variables:
breakpoints – Water-surface elevations (
by_flow=False) or flow values (by_flow=True) at which n is tabulated. Length N.by_flow –
Truewhen breakpoints are flows (Vertical n Flow=-1);Falsewhen they are WSE (Vertical n Flow= 0).stations – Per-station n-value curves, each with N entries.
- Parameters:
by_flow (bool)
stations (list[VerticalNStation])
- stations: list[VerticalNStation]¶
- class rivia.model.geometry.VerticalNStation(station, n_values)[source]¶
Bases:
objectManning’s n values at one cross-section station, varying by depth or flow.
- Variables:
station – Lateral station (same coordinate system as
#Sta/Elev).n_values – n-value at each breakpoint in
VerticalN.
- Parameters:
- class rivia.model.geometry.Weir(width, coefficient, shape, max_submergence, min_elevation, skew, dist=nan, spillway_approach_height=nan, design_energy_head=nan, us_slope=nan, ds_slope=nan, use_water_surface=False)[source]¶
Bases:
objectOverflow weir parameters from the
IW Distblock.Mirrors
rivia.hdf.geometry.Weirin field names. Key differences vs the HDF version:Always populated when an
IW Distline exists, even when mode is empty (the HDF version returnsNoneformode='').us_slope,ds_slope: not present in theIW Disttext line; stored asnan.use_water_surface: not stored in the text geometry format; alwaysFalse.
- Variables:
width – Weir width (
WD, index 1).coefficient – Weir discharge coefficient (
Coef, index 2).shape –
'Broad Crested'or'Ogee'(Is_Ogee, index 6).max_submergence – Maximum submergence ratio (
MaxSub, index 4).min_elevation – Minimum weir crest elevation (
Min_El, index 5);nanwhen blank.skew – Weir skew angle in degrees (
Skew, index 3).dist – Distance from the upstream XS to the weir face (index 0 of the
IW Distdata line);nanfor bridges and laterals (not stored in those formats).spillway_approach_height – Spillway approach height —
SpillHt(index 7 of theIW Distdata line);nanfor bridges and laterals.design_energy_head – Design energy head —
DesHd(index 8 of theIW Distdata line);nanfor bridges and laterals.us_slope – Upstream face slope H:V;
nan— not in text format.ds_slope – Downstream face slope H:V;
nan— not in text format.use_water_surface – Use water surface as weir reference head; always
False— not in text format.
- Parameters: