unsteady_plan¶
UnsteadyUnsteadyPlan - read HEC-RAS unsteady plan HDF5 files (.p*.hdf).
Plan HDF files embed the same Geometry/ group as geometry HDF files
plus Results/Unsteady/... time-series and summary output.
UnsteadyUnsteadyPlan inherits Geometry so all geometry accessors are available.
FlowAreaResults extends FlowArea with lazy time-series properties,
summary DataFrames, and computed depth / velocity methods. Raster export
methods delegate to rivia.geo via a deferred import so this module is
fully usable without rasterio or scipy installed.
- class rivia.hdf.unsteady_plan.BridgeResults(geom, group, timestamps)[source]¶
Bases:
_StructureResultsMixin,BridgeGeometry and time-series results for one HEC-RAS bridge structure.
Inherits geometry from
Bridgeand shared HDF result access from_StructureResultsMixin.The HDF group is at
Results/.../DSS Hydrograph Output/.../Bridge/<river reach rs>.- Parameters:
geom (
Bridge) – Geometry object fromStructureCollection.group (
Group) –h5py.Groupat the bridge result path.timestamps (
DatetimeIndex) – Output timestamps for this block; index for allpd.Seriesproperties.
- property structure_variables: Dataset¶
All bridge variables as a lazy
h5py.Dataset, shape(n_t, 3).
- class rivia.hdf.unsteady_plan.ComputeSummary(run, volume, volume_1d, volume_2d)[source]¶
Bases:
objectFull unsteady simulation summary for a plan HDF file.
Aggregates all summary groups under
Results/Unsteady/Summary.- Variables:
run – Overall run metadata (solution status, timing, stability).
volume – Model-wide volume accounting (1D + 2D combined).
volume_1d – Volume accounting for 1-D components only.
volume_2d – Per-area volume accounting for each 2-D flow area. Empty dict when the model has no 2-D flow areas.
- Parameters:
run (RunStatus)
volume (VolumeAccounting)
volume_1d (VolumeAccounting1D)
volume_2d (dict[str, VolumeAccounting2DArea])
- errors()[source]¶
Return key convergence and volume-balance error metrics.
Derives four scalar error measures from this summary that are useful for quick quality-control checks after a run.
- Returns:
A flat dictionary with the following keys:
"wse"Maximum water-surface elevation error across all cells (model units – feet or metres).
Nonewhen the simulation went unstable before the run converged."volume_error_pct"Overall volume balance error as a percentage of total inflow, read directly from the HEC-RAS
Results/Unsteady/Summaryvolume accounting block."volume_1d_error_pct"1-D volume balance error (%) computed from the individual 1-D flux terms:
error = -(flow_us_in + net_other_fluxes + storage_change) supply = reach_vol_start + sa_vol_start + flow_us_in + hydro_lat + hydro_sa + diversions + groundwater + precip_excess error_pct = error / supply * 100
where net_other_fluxes =
-flow_ds_out + hydro_lat + hydro_sa + diversions + groundwater + precip_excess.supplyis the total 1-D water budget (initial storage plus all non-DS-outflow fluxes); for a 1D-only model this matches the HEC-RAS overall"Error Percent"attribute. Returnsnanwhen total 1-D supply is zero."volume_2d_error_pct"Largest-magnitude 2-D volume balance error (%) across all 2-D flow areas, preserving the sign of the worst-case area. Zero when the model has no 2-D flow areas.
- Return type:
See also
okQuality-control pass/fail check with threshold logging.
- ok(wse_threshold=0.5, volume_error_pct_threshold=1.0, volume_1d_error_pct_threshold=1.0, volume_2d_error_pct_threshold=1.0)[source]¶
Return
Trueif the simulation completed stably and all error metrics are within their thresholds.Checks stability first, then each error metric against its threshold. All failures are collected and logged before returning so the caller sees the complete picture in one pass.
If the simulation went unstable every failure is logged at
CRITICAL; otherwise threshold violations are logged atWARNING.- Parameters:
wse_threshold (
float) – Maximum allowable water-surface elevation error in model units (feet or metres). Default:0.5.volume_error_pct_threshold (
float) – Maximum allowable overall volume balance error (%). Default:1.0.volume_1d_error_pct_threshold (
float) – Maximum allowable 1-D volume balance error (%). Default:1.0.volume_2d_error_pct_threshold (
float) – Maximum allowable 2-D volume balance error (%) per 2-D flow area. Default:1.0.
- Returns:
Trueif the simulation is stable and all metrics are within bounds;Falseotherwise.- Return type:
See also
errorsRaw error metric values.
- to_dict()[source]¶
Return a nested dict with short, meaningful keys.
Top-level keys:
"run","volume","volume_1d","volume_2d". The"volume_2d"value is a dict keyed by 2-D flow area name.
- volume: VolumeAccounting¶
- volume_1d: VolumeAccounting1D¶
- volume_2d: dict[str, VolumeAccounting2DArea]¶
- class rivia.hdf.unsteady_plan.CrossSectionMappingResults(geom, hdf, index, root, timestamps)[source]¶
Bases:
_CrossSectionResultsBaseGeometry and results for one XS from the Base Output block.
Returned by
plan.cross_sections("mapping")[key]. All variables written by HEC-RAS at the mapping interval are exposed as time-indexedpd.Series.- Parameters:
geom (
CrossSection) – Geometry object fromCrossSectionCollection.hdf (
File) – Openh5py.File– kept alive by the parentUnsteadyPlancontext.index (
int) – Column index of this XS in the(n_t, n_xs)result datasets.root (
str) – HDF path prefix –_TS_XS.timestamps (
DatetimeIndex) – Mapping output timestamps from the parent collection.
- class rivia.hdf.unsteady_plan.CrossSectionOutputResults(geom, hdf, index, root, timestamps)[source]¶
Bases:
_CrossSectionResultsBaseGeometry and results for one XS from the DSS Hydrograph Output block.
Returned by
plan.cross_sections("output")[key]. Available datasets:wse,flow,flow_cumulative.- Parameters:
geom (
CrossSection) – Geometry object fromCrossSectionCollection.hdf (
File) – Openh5py.File– kept alive by the parentUnsteadyPlancontext.index (
int) – Column index of this XS in the(n_t, n_xs)result datasets.root (
str) – HDF path prefix –_DSS_XS.timestamps (
DatetimeIndex) – DSS hydrograph output timestamps from the parent collection.
- class rivia.hdf.unsteady_plan.CrossSectionPostProcessResults(geom, hdf, index, root, timestamps)[source]¶
Bases:
_CrossSectionResultsBaseGeometry and results for one XS from the Post Process Profiles block.
Returned by
plan.cross_sections("post_process")[key].Named properties expose every variable as a time-indexed
pd.Series(timeseries only — the Max WS envelope row is excluded). The shape and index type are identical toCrossSectionMappingResultsandCrossSectionOutputResults:xs = plan.cross_sections("post_process")["Butte Cr Upper 7"] xs = plan.cross_sections("post_process")[0] xs.wse # pd.Series, index=pd.DatetimeIndex xs.flow # pd.Series, index=pd.DatetimeIndex xs.velocity_channel # pd.Series, index=pd.DatetimeIndex
To access the Max WS envelope value for a specific variable, use the parent collection:
coll = plan.cross_sections("post_process") coll.wse()["max_wse"].loc[(river, reach, rs)]
For multi-XS access prefer the collection’s
profile_table()or named methods (one bulk HDF read vs. one read per property call here).- Parameters:
geom (
CrossSection) – Geometry object fromCrossSectionCollection.hdf (
File) – Openh5py.File– kept alive by the parentUnsteadyPlancontext.index (
int) – Column index of this XS in the(n_profiles, n_xs)result datasets.root (
str) – HDF path prefix –_POSTPROC_XS.timestamps (
DatetimeIndex) – Instantaneous profile timestamps from the parent collection (Max WS excluded, lengthn).
- property critical_energy_grade: Series¶
Critical energy grade line elevation (m), indexed by
timestamps.
- property critical_water_surface: Series¶
Critical water surface elevation (m), indexed by
timestamps.
- property flow_area_left_ob: Series¶
Left overbank flow area time series (m²), indexed by
timestamps.
- property flow_area_right_ob: Series¶
Right overbank flow area time series (m²), indexed by
timestamps.
- property hydraulic_depth_right_ob: Series¶
Right overbank hydraulic depth (m), indexed by
timestamps.
- property hydraulic_radius_left_ob: Series¶
Left overbank hydraulic radius (m), indexed by
timestamps.
- property hydraulic_radius_right_ob: Series¶
Right overbank hydraulic radius (m), indexed by
timestamps.
- property ineffective_area_channel: Series¶
Channel area including ineffective zones (m²), indexed by timestamps.
- property ineffective_area_left_ob: Series¶
Left overbank area incl. ineffective zones (m²), indexed by timestamps.
- property ineffective_area_right_ob: Series¶
Right overbank area incl. ineffective zones (m²), indexed by timestamps.
- property ineffective_area_total: Series¶
Total area incl. ineffective zones (m²), indexed by timestamps.
- property top_width_channel_with_ineffective: Series¶
Channel top width incl. ineffective areas (m), indexed by timestamps.
- property top_width_left_ob_with_ineffective: Series¶
Left OB top width incl. ineffective areas (m), indexed by timestamps.
- property top_width_right_ob_with_ineffective: Series¶
Right OB top width incl. ineffective areas (m), indexed by timestamps.
- property top_width_total_with_ineffective: Series¶
Total top width incl. ineffective areas (m), indexed by timestamps.
- property wetted_perimeter_left_ob: Series¶
Left overbank wetted perimeter (m), indexed by
timestamps.
- class rivia.hdf.unsteady_plan.CrossSectionPostProcessResultsCollection(hdf, root, result_cls=<class 'rivia.hdf.unsteady_plan.CrossSectionMappingResults'>, attrs_path=None, timestamps_fn=None)[source]¶
Bases:
CrossSectionResultsCollectionCross-section results for the Post Process Profiles block.
Returned by
plan.cross_sections("post_process").All result data is read through this collection rather than through per-XS objects. The generic engine is
profile_table(); named convenience methods (wse,flow,velocity_channel, …) delegate to it.The profile axis of every returned
pd.DataFrameis labeled["max_wse", 0, 1, …, n-1]where"max_wse"is the Max WS envelope (HDF index 0) and integers0 … n-1are the instantaneous profiles aligned withtimestamps.- Parameters:
hdf (
File) – Openh5py.Filehandle.root (
str) – HDF path prefix –_POSTPROC_XS.result_cls (
type[_CrossSectionResultsBase]) –CrossSectionPostProcessResults(geometry carrier).attrs_path (
str|None) –_POSTPROC_GEOM_ATTRS(attributes live outside the XS group).timestamps_fn (
Callable[[],DatetimeIndex] |None) – Callable returninginstantaneous_timestamps.
- property critical_energy_grade: DataFrame¶
Critical energy grade line elevation, location × profiles (m).
- property critical_water_surface: DataFrame¶
Critical water surface elevation, location × profiles (m).
- property energy_grade: DataFrame¶
Energy grade line elevation, location × profiles (m).
- Returns:
Columns
["max_wse", 0, 1, …].- Return type:
pd.DataFrame
- property flow: DataFrame¶
Flow, location × profiles (m³/s).
- Returns:
Columns
["max_wse", 0, 1, …].- Return type:
pd.DataFrame
- property hydraulic_depth_left_ob: DataFrame¶
Left overbank hydraulic depth, location × profiles (m).
- property hydraulic_depth_right_ob: DataFrame¶
Right overbank hydraulic depth, location × profiles (m).
- property hydraulic_radius_left_ob: DataFrame¶
Left overbank hydraulic radius, location × profiles (m).
- property hydraulic_radius_right_ob: DataFrame¶
Right overbank hydraulic radius, location × profiles (m).
- property ineffective_area_channel: DataFrame¶
Channel area including ineffective zones, location × profiles (m²).
- property ineffective_area_left_ob: DataFrame¶
Left overbank area including ineffective zones, location × profiles (m²).
- property ineffective_area_right_ob: DataFrame¶
Right overbank area including ineffective zones, location × profiles (m²).
- property ineffective_area_total: DataFrame¶
Total area including ineffective zones, location × profiles (m²).
- profile_table(variable)[source]¶
Return a location × profiles
pd.DataFramefor one variable.Reads the full
(n_profiles, n_xs)HDF dataset in a single call and selects only the columns belonging to cross sections present in this collection.- Parameters:
variable (
str) – Dataset name, e.g."Water Surface","Velocity Channel","Flow Total". Resolved with friendly fallback: the literal name is tried first, thenAdditional Variables/<variable>.- Returns:
Index —
pd.MultiIndexwith levels(River, Reach, RS), one row per cross section in collection order.Columns —
["max_wse", 0, 1, …, n-1]."max_wse"is the Max WS envelope (HDF row 0); integers map 1-to-1 intotimestamps.Values —
float.
- Return type:
pd.DataFrame
- Raises:
KeyError – If variable is not found in the HDF.
ValueError – If the profile count in the HDF does not match
len(timestamps) + 1.
- property top_width_channel_with_ineffective: DataFrame¶
Channel top width including ineffective areas, location × profiles (m).
- property top_width_left_ob_with_ineffective: DataFrame¶
Left overbank top width incl. ineffective areas, location × profiles (m).
- property top_width_right_ob_with_ineffective: DataFrame¶
Right overbank top width incl. ineffective areas, location × profiles (m).
- property top_width_total_with_ineffective: DataFrame¶
Total top width including ineffective areas, location × profiles (m).
- property wetted_perimeter_left_ob: DataFrame¶
Left overbank wetted perimeter, location × profiles (m).
- property wetted_perimeter_right_ob: DataFrame¶
Right overbank wetted perimeter, location × profiles (m).
- class rivia.hdf.unsteady_plan.CrossSectionProfileResults(geom, hdf, index, root, timestamps)[source]¶
Bases:
_CrossSectionResultsBaseGeometry and results for one XS from the DSS Profile Output block.
Returned by
plan.cross_sections("profile")[key].DSS Profile Output contains raw unsteady-engine output at the Detailed Output Interval. Available datasets:
wse,flow. Also exposes theCross Section Attributesstructured array unique to this block.- Parameters:
geom (
CrossSection) – Geometry object fromCrossSectionCollection.hdf (
File) – Openh5py.File– kept alive by the parentUnsteadyPlancontext.index (
int) – Column index of this XS in the(n_t, n_xs)result datasets.root (
str) – HDF path prefix –_DSS_PROF_XS.timestamps (
DatetimeIndex) – Detailed output timestamps from the parent collection.
- class rivia.hdf.unsteady_plan.CrossSectionResultsCollection(hdf, root, result_cls=<class 'rivia.hdf.unsteady_plan.CrossSectionMappingResults'>, attrs_path=None, timestamps_fn=None)[source]¶
Bases:
CrossSectionCollectionPlan-enriched cross section collection with time-series results.
Parameterised over the concrete result class and the HDF path used to map cross sections to column indices, so one implementation serves all three output blocks.
- Parameters:
hdf (
File) – Openh5py.Filehandle.root (
str) – HDF path to the cross section result group:_TS_XS,_DSS_XS, or_POSTPROC_XS.result_cls (
type[_CrossSectionResultsBase]) – Concrete result class to instantiate per cross section –CrossSectionMappingResults,CrossSectionOutputResults, orCrossSectionPostProcessResults.attrs_path (
str|None) – HDF path to theCross Section Attributesstructured array used to map(river, reach, station)-> column index. Defaults tof"{root}/Cross Section Attributes", which is correct for Base Output and DSS blocks. Pass_POSTPROC_GEOM_ATTRSfor the Post Process block, where attributes live outside the XS result group.timestamps_fn (
Callable[[],DatetimeIndex] |None) – Zero-argument callable that returns thepd.DatetimeIndexfor this block. Resolved lazily on first access; the result is cached ontimestamps.
- property timestamps: DatetimeIndex¶
Timestamps for this result block as a
pd.DatetimeIndex.Resolved lazily from the callable passed at construction time.
- Raises:
AttributeError – If no
timestamps_fnwas supplied.
- class rivia.hdf.unsteady_plan.FlowAreaResults(geom_group, ts_group, sum_group, name, n_cells)[source]¶
Bases:
_FlowAreaResultsDerivedGeometry and time-series results for one named 2-D flow area.
Inherits all geometry properties from
FlowAreaand all derived/computed methods from_FlowAreaResultsDerived.Method naming conventions
Raw dataset properties –
h5py.Dataset; slice to control what is loaded:area.water_surface[t] # one timestep -> ndarray (n_cells + n_ghost,) area.water_surface[a:b] # slice -> ndarray (b-a, n_cells + n_ghost) area.water_surface[:] # all -> ndarray (n_t, n_cells + n_ghost)
Snapshot accessors – one time, all locations -> ndarray:
area.get_water_surface(timestep=t) # (n_cells,) area.get_depth(timestep=t) # (n_cells,) area.get_cell_velocity(t) # (n_cells, 2) area.get_face_velocity(timestep=t, component="vector") # (n_faces, 2) area.get_facepoint_velocity_field(t) # (n_facepoints, 2)
Location time-series – one location, all times -> pandas:
area.get_water_surface(cell=c) # Series WSE over time area.get_face_velocity(face=f) # Series velocity over time area.get_face_flow(face=f) # Series flow over time area.get_facepoint_velocity(facepoint=fp) # DataFrame [vx, vy, speed]
Summary properties – aggregate over the full time span, all locations:
area.max_water_surface # DataFrame ['value', 'time'] per cell area.max_face_velocity # DataFrame ['value', 'time'] per face area.get_max_depth() # DataFrame ['value', 'time'] per cell
- Parameters:
- property cell_velocity: Dataset | None¶
HEC-RAS cell-velocity speed scalar, or
Noneif not output.h5py.Dataset, shape(n_timesteps, n_cells). This is the optional output enabled in the HDF Write Parameters; seeget_cell_velocity()for the derived vector field.
- property face_flow: Dataset | None¶
Volumetric face-flow time series, or
Noneif not output.h5py.Dataset, shape(n_timesteps, n_faces).
- property face_velocity: Dataset¶
Signed face-normal velocity time series.
h5py.Dataset, shape(n_timesteps, n_faces).
- property max_face_velocity: DataFrame¶
Maximum face velocity per face.
DataFrame with columns
['value', 'time']. Index: 0-based face index.
- property max_water_surface: DataFrame¶
Maximum WSE per cell.
DataFrame with columns
['value', 'time'].value: maximum water-surface elevation (model units).time: elapsed simulation time (days) when max occurred. Index: 0-based cell index. Real cells only (ghost rows excluded).
- property min_water_surface: DataFrame¶
Minimum WSE per cell. Same column layout as
max_water_surface. Real cells only (ghost rows excluded).
- property timestamps: DatetimeIndex¶
Result output time stamps as a
pd.DatetimeIndex.Parsed from the
Time Date Stampdataset (sibling of the2D Flow Areasgroup underUnsteady Time Series). Used as the index for all time-series results returned byget_*accessors.
- property water_surface: Dataset¶
Water-surface elevation time series.
h5py.Dataset, shape(n_timesteps, n_cells + n_ghost). HEC-RAS stores ghost cell WSE (boundary condition stages) in the trailing columns. Slice with[:self.n_cells]for real cells only, or[:]for all including ghost cells. Slice to read:area.water_surface[10].
- class rivia.hdf.unsteady_plan.FlowAreaResultsCollection(hdf)[source]¶
Bases:
FlowAreaCollectionCollection of
FlowAreaResultsobjects backed by a plan HDF file.Overrides
FlowAreaCollectionto returnFlowAreaResultsinstead of plainFlowAreainstances.- Parameters:
hdf (h5py.File)
- class rivia.hdf.unsteady_plan.InlineResults(geom, group, timestamps)[source]¶
Bases:
_StructureResultsMixin,InlineStructureGeometry and time-series results for one HEC-RAS inline structure.
Inherits geometry from
InlineStructureand shared HDF result access from_StructureResultsMixin.The HDF group is at
Results/.../DSS Hydrograph Output/.../Inline Structures/<river reach rs>.- Parameters:
geom (
InlineStructure) – Geometry object fromStructureCollection.group (
Group) –h5py.Groupat the inline structure result path.timestamps (
DatetimeIndex) – Output timestamps for this block; index for allpd.Seriesproperties.
- class rivia.hdf.unsteady_plan.LateralResults(geom, group, timestamps, skip_row0=False)[source]¶
Bases:
_StructureResultsMixin,LateralStructureGeometry and time-series results for one HEC-RAS lateral structure.
Inherits geometry from
LateralStructureand shared HDF result access from_StructureResultsMixin.The HDF group is at
Results/.../DSS Hydrograph Output/.../Lateral Structures/<river reach rs>.downstream_nodeis the name of the connected Storage Area or 2-D Flow Area, or an empty string when flow exits the system.- Parameters:
geom (
LateralStructure) – Geometry object fromStructureCollection.group (
Group) –h5py.Groupat the lateral structure result path.timestamps (
DatetimeIndex) – Output timestamps for this block; index for allpd.Seriesproperties.skip_row0 (bool)
- class rivia.hdf.unsteady_plan.RunStatus(solution, run_window, compute_time_total, compute_time_dss, max_cores, max_wsel_error, time_unstable, timestamp_unstable)[source]¶
Bases:
objectOverall run metadata from
Results/Unsteady/Summary.- Variables:
solution – HEC-RAS solution status string, e.g.
"Unsteady Finished Successfully"or"Unsteady Went Unstable".run_window – Wall-clock window during which the simulation ran, as a raw string, e.g.
"26NOV2025 15:58:44 to 26NOV2025 16:03:41".compute_time_total – Total wall-clock computation time in
"HH:MM:SS"format.compute_time_dss – Time spent writing DSS output in
"HH:MM:SS"format.max_cores – Maximum number of CPU cores used.
max_wsel_error – Maximum water-surface elevation error (model units), or
Nonewhen the simulation went unstable before convergence.time_unstable – Elapsed simulation time (days) when the solution went unstable, or
Noneif the run finished successfully.timestamp_unstable – HEC-RAS date/time string for the instability, or
Noneif the run finished successfully (HEC-RAS writes"Not Applicable").
- Parameters:
- parse_run_window()[source]¶
Parse
run_windowinto(start, end)datetimes.Splits the raw string on
" to "and parses each half with the HEC-RAS timestamp format"%d%b%Y %H:%M:%S".- Returns:
(start, end)as timezone-naivedatetime.datetimeobjects, orNonewhen the string is missing, malformed, or cannot be parsed.- Return type:
tuple[datetime, datetime] or None
Examples
s = hdf.compute_summary() window = s.run.parse_run_window() if window: start, end = window print(end - start) # wall-clock duration
- class rivia.hdf.unsteady_plan.SA2DConnectionResults(geom, group, timestamps, skip_row0=False)[source]¶
Bases:
_StructureResultsMixin,SA2DConnectionGeometry and time-series results for one HEC-RAS SA/2D connection.
Inherits geometry from
SA2DConnectionand shared HDF result access (structure_variables,total_flow,stage_hw,stage_tw,weir_variables,flow_gate) from_StructureResultsMixin.- Parameters:
geom (
SA2DConnection) – Geometry object fromStructureCollection.group (
Group) –h5py.Groupat-/SA 2D Area Conn/<plan_name>.timestamps (
DatetimeIndex) – Output timestamps for this block; index for allpd.Seriesproperties.skip_row0 (bool)
- property breaching_variables: Dataset | None¶
Breach geometry and flow time series, or
Noneif not breach-capable.Lazy
h5py.Dataset, shape(n_t, 10). Columns: Stage HW, Stage TW, Bottom Width, Bottom Elevation, Left Side Slope, Right Side Slope, Breach Flow, Breach Velocity, Breach Flow Area, Top Elevation.
- property headwater_cells: ndarray | None¶
2-D mesh cell indices on the headwater side, or
Noneif absent.Shape
(n_faces,).
- property tailwater_cells: ndarray | None¶
2-D mesh cell indices on the tailwater side, or
Noneif absent.For 2D<->2D connections (levees) these are stored as a flat
int32dataset at the group root. For SA<->2D connections (e.g. a dam with a storage-area headwater) they are stored as fixed-width byte strings inHW TW Segments/Tailwater Cellsand are decoded here.Shape
(n_cells,).
- class rivia.hdf.unsteady_plan.StorageAreaResults(sa, sa_index, ts_sa_group, sum_sa_group, timestamps, skip_row0=False)[source]¶
Bases:
StorageAreaGeometry and time-series results for one storage area.
Inherits all geometry properties from
StorageArea(boundary,volume_elevation,volume_at_elevation(), etc.).Time-series properties return
pd.Seriesindexed bytimestamps.- Parameters:
sa (
StorageArea) – Parent geometry object whose fields are copied into this instance.sa_index (
int) – 0-based column index of this SA in the flat(n_t, n_sa)datasets (Water Surface,Flow) stored underStorage Areas/.ts_sa_group (
Group|None) –h5py.Groupat-/Unsteady Time Series/Storage Areas, orNonewhen the plan has no SA results.sum_sa_group (
Group|None) –h5py.Groupat-/Summary Output/Storage Areas, orNone.timestamps (
DatetimeIndex) – Output timestamps for the block this SA was loaded from; used as the index for allpd.Seriestime-series properties.skip_row0 (bool)
- property connection_names: list[str]¶
Names of the inflow connection sources (from HDF
Connectionsattribute).Falls back to index-based names if the attribute is absent.
- property connections: ndarray | None¶
Inflow from each named connection.
Shape
(n_t, n_conns), orNonewhen no connection data is stored. Column names are inconnection_names.
- property max_wse: DataFrame¶
Maximum WSE.
DataFrame with columns
['value', 'time'].value: maximum WSE in model units.time: elapsed simulation time (days) when maximum occurred.
- class rivia.hdf.unsteady_plan.StorageAreaResultsCollection(hdf, output='mapping')[source]¶
Bases:
StorageAreaCollectionCollection of
StorageAreaResultsbacked by a plan HDF file.Overrides
StorageAreaCollectionto returnStorageAreaResultswith both geometry and plan results.The
timestampsproperty exposes the output block’s time axis as apd.DatetimeIndex; it is also passed into eachStorageAreaResultsitem so per-SApd.Seriesproperties share the same index.- Parameters:
hdf (
File) – Openh5py.Filehandle.output ({"mapping", "output", "profile", "post_process"}, optional) – Which output block to read. Defaults to
"mapping"(Base Output).
- property timestamps: DatetimeIndex¶
Output timestamps for this block as a
pd.DatetimeIndex.Resolved lazily from the HDF file on first access.
- Raises:
KeyError – If the expected timestamp dataset is absent from the HDF file.
- class rivia.hdf.unsteady_plan.StructureResultsCollection(hdf, output='output')[source]¶
Bases:
StructureCollectionPlan-enriched structure collection: all structure types with results.
Overrides
StructureCollectionso each item carries both geometry attributes and time-series result access.- Parameters:
hdf (
File) – Openh5py.Filehandle.output ({"mapping", "output", "profile", "post_process"}, optional) –
Which output block to read. Defaults to
"output"(DSS Hydrograph)."mapping"— Base Output (all four structure types)."output"— DSS Hydrograph Output (all four structure types)."profile"— DSS Profile Output (all four structure types)."post_process"— Post Process Profiles. Lateral and SA/2D connections only; Inline and Bridge items fall back to plain geometry.structure (When no plan result group is found for a)
geometry (the plain)
unchanged. (object is kept)
- property timestamps: DatetimeIndex¶
Output timestamps for this block as a
pd.DatetimeIndex.Resolved lazily from the HDF file on first access.
- Raises:
KeyError – If the expected timestamp dataset is absent from the HDF file.
- class rivia.hdf.unsteady_plan.UnsteadyPlan(filename, program_directory=None)[source]¶
Bases:
_PlanHdf,GeometryRead HEC-RAS plan HDF5 output files (
*.p*.hdf).A plan HDF file contains the same
Geometry/data as a geometry HDF file, plusResults/Unsteady/...time-series and summary output.- Parameters:
Examples
with UnsteadyPlan("MyModel.p01") as hdf: ts = hdf.mapping_timestamps area = hdf.flow_areas["spillway"] wse = area.water_surface[10] # one timestep depth = area.get_depth(timestep=10) speed = area.get_cell_velocity(10, component="speed") max_d = area.get_max_depth() # requires rasterio + scipy: area.export_raster("depth", "depth.tif", timestep=None, cell_size=5.0, crs="EPSG:26910") # or get an in-memory dataset: ds = area.export_raster("depth", timestep=None, cell_size=5.0) arr = ds.read(1) ds.close()
- property computation_interval: timedelta | None¶
Base computation time step, or
Noneif absent.Read from
Plan Data/Plan InformationattributeComputation Time Step Base. HEC-RAS stores the value as a concatenated number-unit string, e.g.'20SEC','5MIN','1HR','1HOUR','1DAY'.
- compute_errors()[source]¶
Return key convergence and volume-balance error metrics.
Convenience wrapper: calls
compute_summary()and delegates toComputeSummary.errors(). See that method for full documentation.See also
ComputeSummary.errorsFull documentation and return-value details.
compute_okQuality-control pass/fail check with threshold logging.
- compute_ok(wse_threshold=0.5, volume_error_pct_threshold=1.0, volume_1d_error_pct_threshold=1.0, volume_2d_error_pct_threshold=1.0)[source]¶
Return
Trueif the simulation completed stably and all error metrics are within their thresholds.Convenience wrapper: calls
compute_summary()and delegates toComputeSummary.ok(). See that method for full documentation, including parameter descriptions and logging behaviour.- Return type:
- Parameters:
Examples
Quick pass/fail check after a run:
if not hdf.compute_ok(): raise RuntimeError("Simulation quality check failed.")
Custom thresholds:
if not hdf.compute_ok(wse_threshold=0.1, volume_error_pct_threshold=0.5): logger.warning("Tight-tolerance check failed.")
See also
ComputeSummary.okFull documentation and parameter descriptions.
compute_errorsRaw error metric values.
- compute_summary()[source]¶
Return the full unsteady simulation summary.
Reads all groups under
Results/Unsteady/Summaryand returns aComputeSummarydataclass aggregating run metadata, overall volume accounting, 1-D volume accounting, and per-area 2-D volume accounting.Call
ComputeSummary.to_dict()on the result for a nested dict with short, meaningful keys.- Return type:
- Raises:
KeyError – If
Results/Unsteady/Summaryis absent – e.g. the file is a steady-flow plan or the simulation has not been run yet.
Examples
with UnsteadyPlan("MyModel.p01") as hdf: s = hdf.compute_summary() print(s.run.solution) print(s.volume.error_pct) d = s.to_dict()
- cross_sections(output='mapping')[source]¶
1-D cross sections with geometry and time-series results.
- Parameters:
output ({"mapping", "output", "profile", "post_process"}, optional) –
Which output block to read.
"mapping"(default) — Base Output at the mapping interval. ReturnsCrossSectionResultsCollectionwhose items areCrossSectionMappingResults. Per-XSpd.Seriesproperties:wse,flow,flow_lateral,velocity_channel,velocity_total,flow_cumulative."output"— DSS Hydrograph Output at the hydrograph interval. ReturnsCrossSectionResultsCollectionwhose items areCrossSectionOutputResults. Per-XSpd.Seriesproperties:wse,flow,flow_cumulative."profile"— DSS Profile Output at the detailed interval. ReturnsCrossSectionResultsCollectionwhose items areCrossSectionProfileResults. Per-XSpd.Seriesproperties:wse,flow,cross_section_attributes."post_process"— Post Process Profiles. Returns aCrossSectionPostProcessResultsCollectionwith collection-levelprofile_table(variable)method and named properties (wse,flow,velocity_channel, …) each returning a location × profilespd.DataFrame.[key]returns aCrossSectionPostProcessResultswhose named properties (wse,flow,velocity_channel, …) each return apd.Seriesindexed bypd.DatetimeIndex(timeseries only, Max WS envelope excluded).- Returns:
Collection supporting
[key], integer index, andnames. Timestamps are available ascoll.timestamps.- Return type:
- Raises:
ValueError – If output is not one of the four recognised values.
- property detailed_interval: timedelta | None¶
Detailed output interval, or
Noneif absent.Derived from the difference between the first two timestamps in the DSS Profile Output
Time Date Stampdataset. Used by both"profile"and"post_process"output blocks (same HEC-RAS Detailed Output Interval setting).
- property detailed_timestamps: DatetimeIndex¶
Detailed output interval timestamps as a
pd.DatetimeIndex.Reads from the DSS Profile Output
Time Date Stampdataset. Bothcross_sections("profile")/storage_areas("profile")andcross_sections("post_process")/storage_areas("post_process")share this interval (same HEC-RAS Detailed Output Interval setting).- Raises:
KeyError – If DSS Profile Output was not written for this plan.
- property flow_areas: FlowAreaResultsCollection¶
Access 2-D flow areas with both geometry and results data.
- property mapping_interval: timedelta | None¶
Mapping output interval, or
Noneif absent.Read from
Plan Data/Plan InformationattributeBase Output Interval. HEC-RAS stores the value as a concatenated number-unit string, e.g.'5MIN'.
- property mapping_timestamps: DatetimeIndex¶
Simulation output time stamps as a
pd.DatetimeIndex.Parsed from the
Time Date Stampdataset written by HEC-RAS. Format:DD Mon YYYY HH:MM:SS(e.g.03Jan2000 00:00:00).
- property n_detailed_timestamps: int | None¶
Number of detailed output time steps, or
Noneif absent.Reads only the shape of the DSS Profile
Time Date Stampdataset.
- property n_mapping_timestamps: int | None¶
Number of mapping output time steps, or
Nonefor steady-flow plans.Reads only the dataset shape – no timestamp data is loaded.
- property n_output_timestamps: int | None¶
Number of DSS hydrograph output time steps, or
Noneif absent.Reads only the dataset shape – no timestamp data is loaded.
- property output_interval: timedelta | None¶
DSS hydrograph output interval, or
Noneif absent.Derived from the difference between the first two hydrograph time stamps.
- property output_timestamps: DatetimeIndex¶
DSS hydrograph output time stamps as a
pd.DatetimeIndex.Parsed from
Results/.../DSS Hydrograph Output/Unsteady Time Series/Time Date Stamp. Format:DD Mon YYYY HH:MM:SS.
- property ras_version: str¶
HEC-RAS version string from the plan HDF root attribute.
Returns the
File Versionroot attribute, e.g.'HEC-RAS 6.6 September 2024'.
- runtime_log()[source]¶
Read the runtime compute log from
Results/Summary/.- Returns:
Log container with the full text/RTF compute messages, the compute-process table, and unsteady-specific parsing methods such as
max_iterations()andadaptive_timesteps().- Return type:
UnsteadyRuntimeLog
- Raises:
KeyError – If
Results/Summaryis absent from the HDF file.
- sa2d_connections(output='output')[source]¶
SA/2D hydraulic connections keyed by geometry name.
Convenience delegate to
structures(output).connections.- Parameters:
output ({"mapping", "output", "profile", "post_process"}, optional) – Passed through to
structures(). Defaults to"output".- Returns:
Items are
SA2DConnectionResultswhen plan output is present, plainSA2DConnectionotherwise.- Return type:
- storage_areas(output='mapping')[source]¶
Access storage areas with geometry and plan results.
- Parameters:
output ({"mapping", "output", "profile", "post_process"}, optional) –
Which output block to read. Defaults to
"mapping"."mapping"— Base Output (includes summary max/min WSE)."output"— DSS Hydrograph Output."profile"— DSS Profile Output; timestamps =detailed_timestamps."post_process"— Post Process Profiles; timestamps =detailed_timestamps; row 0 (Max WS envelope) is excluded from all time-series arrays. Summarymax_wse/min_wseraiseKeyError(summary group absent from this block).- Returns:
Exposes a
timestampsproperty with the block’spd.DatetimeIndex, shared as the index of every per-SApd.Seriesproperty.- Return type:
- structures(output='output')[source]¶
Access all structures with geometry and plan results.
Returns a
StructureResultsCollectionwhere each item is upgraded to the matching results class when plan output is present.- Parameters:
output ({"mapping", "output", "profile", "post_process"}, optional) –
Which output block to read. Defaults to
"output"."mapping"— Base Output (all four structure types)."output"— DSS Hydrograph Output (all four structure types)."profile"— DSS Profile Output (all four structure types)."post_process"— Post Process Profiles; Lateral and SA/2D connections only. Inline and Bridge items fall back to plain geometry objects.- Returns:
Exposes a
timestampsproperty with the block’spd.DatetimeIndex, shared as the index of every per-structurepd.Seriesproperty. Useconnections,inlines,laterals, andbridgesfor filtered access.- Return type:
- class rivia.hdf.unsteady_plan.VolumeAccounting(units, vol_start, vol_end, inflow, outflow, error, error_pct)[source]¶
Bases:
objectOverall volume accounting from
Results/Unsteady/Summary/Volume Accounting.Covers the full model (1D + 2D combined).
- Variables:
units – Volume units string written by HEC-RAS, e.g.
"Acre Feet"or"1000 m^3".vol_start – Total storage volume at the start of the simulation.
vol_end – Total storage volume at the end of the simulation.
inflow – Total boundary flux of water into the model.
outflow – Total boundary flux of water out of the model.
error – Volume balance error (
vol_start + inflow - outflow - vol_end).error_pct – Volume balance error as a percentage of total inflow.
- Parameters:
- class rivia.hdf.unsteady_plan.VolumeAccounting1D(units, reach_vol_start, reach_vol_end, sa_vol_start, sa_vol_end, flow_us_in, flow_ds_out, hydro_lat, hydro_sa, diversions, groundwater, precip_excess)[source]¶
Bases:
object1-D component volume accounting from
Volume Accounting 1D.- Variables:
units – Volume units string, e.g.
"Acre Feet"or"1000 m^3".reach_vol_start – Total 1-D reach storage at simulation start.
reach_vol_end – Total 1-D reach storage at simulation end.
sa_vol_start – Storage-area volume at simulation start.
sa_vol_end – Storage-area volume at simulation end.
flow_us_in – Cumulative upstream inflow across all reaches.
flow_ds_out – Cumulative downstream outflow across all reaches.
hydro_lat – Cumulative lateral hydrograph exchange (positive = into model).
hydro_sa – Cumulative storage-area hydrograph exchange.
diversions – Cumulative diversions (negative = water removed).
groundwater – Cumulative groundwater exchange.
precip_excess – Cumulative precipitation excess (rainfall-runoff applied to reaches).
- Parameters:
- class rivia.hdf.unsteady_plan.VolumeAccounting2DArea(units, vol_start, vol_end, cum_inflow, cum_outflow, error, error_pct)[source]¶
Bases:
objectVolume accounting for one named 2-D flow area.
One instance per child group under
Results/Unsteady/Summary/Volume Accounting/Volume Accounting 2D.- Variables:
units – Volume units string, e.g.
"Acre Feet"or"1000 m^3".vol_start – 2-D flow area storage at simulation start.
vol_end – 2-D flow area storage at simulation end.
cum_inflow – Cumulative inflow into this 2-D area.
cum_outflow – Cumulative outflow out of this 2-D area.
error – Volume balance error for this area.
error_pct – Volume balance error as a percentage of cumulative inflow.
- Parameters: