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, Bridge

Geometry and time-series results for one HEC-RAS bridge structure.

Inherits geometry from Bridge and shared HDF result access from _StructureResultsMixin.

The HDF group is at Results/.../DSS Hydrograph Output/.../Bridge/<river reach rs>.

Parameters:
  • geom (Bridge) – Geometry object from StructureCollection.

  • group (Group) – h5py.Group at the bridge result path.

  • timestamps (DatetimeIndex) – Output timestamps for this block; index for all pd.Series properties.

property flow_total: Series

Total flow through the bridge, indexed by timestamps.

property stage_hw: Series

Headwater stage (upstream side), indexed by timestamps.

property stage_tw: Series

Tailwater stage (downstream side), indexed by timestamps.

property structure_variables: Dataset

All bridge variables as a lazy h5py.Dataset, shape (n_t, 3).

property variable_names: list[str]

Column names from the Bridge Variables Variable_Unit attribute.

class rivia.hdf.unsteady_plan.ComputeSummary(run, volume, volume_1d, volume_2d)[source]

Bases: object

Full 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:
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). None when 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/Summary volume 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. supply is 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. Returns nan when 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:

dict[str, float]

See also

ok

Quality-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 True if 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 at WARNING.

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:

True if the simulation is stable and all metrics are within bounds; False otherwise.

Return type:

bool

See also

errors

Raw error metric values.

run: RunStatus
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.

Return type:

dict[str, Any]

volume: VolumeAccounting
volume_1d: VolumeAccounting1D
volume_2d: dict[str, VolumeAccounting2DArea]
class rivia.hdf.unsteady_plan.CrossSectionMappingResults(geom, hdf, index, root, timestamps)[source]

Bases: _CrossSectionResultsBase

Geometry 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-indexed pd.Series.

Parameters:
  • geom (CrossSection) – Geometry object from CrossSectionCollection.

  • hdf (File) – Open h5py.File – kept alive by the parent UnsteadyPlan context.

  • 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.

property flow: Series

Flow time series, indexed by timestamps.

property flow_cumulative: Series

Cumulative flow volume time series, indexed by timestamps.

property flow_lateral: Series

Lateral flow time series, indexed by timestamps.

property velocity_channel: Series

Channel velocity time series, indexed by timestamps.

property velocity_total: Series

Total velocity time series, indexed by timestamps.

property wse: Series

Water surface elevation time series, indexed by timestamps.

class rivia.hdf.unsteady_plan.CrossSectionOutputResults(geom, hdf, index, root, timestamps)[source]

Bases: _CrossSectionResultsBase

Geometry 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 from CrossSectionCollection.

  • hdf (File) – Open h5py.File – kept alive by the parent UnsteadyPlan context.

  • 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.

property flow: Series

Flow time series, indexed by timestamps.

property flow_cumulative: Series

Cumulative flow volume time series, indexed by timestamps.

property wse: Series

Water surface elevation time series, indexed by timestamps.

class rivia.hdf.unsteady_plan.CrossSectionPostProcessResults(geom, hdf, index, root, timestamps)[source]

Bases: _CrossSectionResultsBase

Geometry 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 to CrossSectionMappingResults and CrossSectionOutputResults:

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 from CrossSectionCollection.

  • hdf (File) – Open h5py.File – kept alive by the parent UnsteadyPlan context.

  • 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, length n).

property alpha: Series

Velocity-head correction factor alpha, indexed by timestamps.

property beta: Series

Momentum correction factor beta, indexed by timestamps.

property conveyance_channel: Series

Channel conveyance (m³/s), indexed by timestamps.

property conveyance_left_ob: Series

Left overbank conveyance (m³/s), indexed by timestamps.

property conveyance_right_ob: Series

Right overbank conveyance (m³/s), indexed by timestamps.

property conveyance_total: Series

Total conveyance (m³/s), indexed by timestamps.

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 energy_grade: Series

Energy grade line elevation time series, indexed by timestamps.

property energy_grade_slope: Series

Energy grade slope (m/m), indexed by timestamps.

property flow: Series

Flow time series, indexed by timestamps.

property flow_area_channel: Series

Channel flow area time series (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 flow_area_total: Series

Total flow area time series (m²), indexed by timestamps.

property flow_channel: Series

Channel flow (m³/s), indexed by timestamps.

property flow_left_ob: Series

Left overbank flow (m³/s), indexed by timestamps.

property flow_right_ob: Series

Right overbank flow (m³/s), indexed by timestamps.

property flow_total: Series

Total flow (m³/s), indexed by timestamps.

property friction_slope: Series

Friction slope (m/m), indexed by timestamps.

property hydraulic_depth_channel: Series

Channel hydraulic depth (m), indexed by timestamps.

property hydraulic_depth_left_ob: Series

Left overbank hydraulic depth (m), indexed by timestamps.

property hydraulic_depth_right_ob: Series

Right overbank hydraulic depth (m), indexed by timestamps.

property hydraulic_depth_total: Series

Total hydraulic depth (m), indexed by timestamps.

property hydraulic_radius_channel: Series

Channel hydraulic radius (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 hydraulic_radius_total: Series

Total 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 mannings_n_channel: Series

Weighted channel Manning’s n, indexed by timestamps.

property mannings_n_left_ob: Series

Left overbank Manning’s n, indexed by timestamps.

property mannings_n_right_ob: Series

Right overbank Manning’s n, indexed by timestamps.

property mannings_n_total: Series

Total weighted Manning’s n, indexed by timestamps.

property max_depth_total: Series

Total maximum water depth (m), indexed by timestamps.

property shear: Series

Bed shear stress (N/m²), indexed by timestamps.

property top_width_channel: Series

Channel top width (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: Series

Left overbank top width (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: Series

Right overbank top width (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: Series

Total top width (m), indexed by timestamps.

property top_width_total_with_ineffective: Series

Total top width incl. ineffective areas (m), indexed by timestamps.

property velocity_channel: Series

Channel velocity (m/s), indexed by timestamps.

property velocity_left_ob: Series

Left overbank velocity (m/s), indexed by timestamps.

property velocity_right_ob: Series

Right overbank velocity (m/s), indexed by timestamps.

property velocity_total: Series

Total velocity (m/s), indexed by timestamps.

property wetted_perimeter_channel: Series

Channel wetted perimeter (m), indexed by timestamps.

property wetted_perimeter_left_ob: Series

Left overbank wetted perimeter (m), indexed by timestamps.

property wetted_perimeter_right_ob: Series

Right overbank wetted perimeter (m), indexed by timestamps.

property wetted_perimeter_total: Series

Total wetted perimeter (m), indexed by timestamps.

property wse: Series

Water-surface elevation time series, indexed by timestamps.

property wse_total: Series

Total WSE from Additional Variables (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: CrossSectionResultsCollection

Cross-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.DataFrame is labeled ["max_wse", 0, 1, …, n-1] where "max_wse" is the Max WS envelope (HDF index 0) and integers 0 n-1 are the instantaneous profiles aligned with timestamps.

Parameters:
  • hdf (File) – Open h5py.File handle.

  • 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 returning instantaneous_timestamps.

property alpha: DataFrame

Velocity-head correction factor alpha, location × profiles.

property beta: DataFrame

Momentum correction factor beta, location × profiles.

property conveyance_channel: DataFrame

Channel conveyance, location × profiles (m³/s).

property conveyance_left_ob: DataFrame

Left overbank conveyance, location × profiles (m³/s).

property conveyance_right_ob: DataFrame

Right overbank conveyance, location × profiles (m³/s).

property conveyance_total: DataFrame

Total conveyance, location × profiles (m³/s).

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 energy_grade_slope: DataFrame

Energy grade slope, location × profiles (m/m).

property flow: DataFrame

Flow, location × profiles (m³/s).

Returns:

Columns ["max_wse", 0, 1, …].

Return type:

pd.DataFrame

property flow_area_channel: DataFrame

Channel flow area, location × profiles (m²).

property flow_area_left_ob: DataFrame

Left overbank flow area, location × profiles (m²).

property flow_area_right_ob: DataFrame

Right overbank flow area, location × profiles (m²).

property flow_area_total: DataFrame

Total flow area, location × profiles (m²).

property flow_channel: DataFrame

Channel flow, location × profiles (m³/s).

property flow_left_ob: DataFrame

Left overbank flow, location × profiles (m³/s).

property flow_right_ob: DataFrame

Right overbank flow, location × profiles (m³/s).

property flow_total: DataFrame

Total flow, location × profiles (m³/s).

property friction_slope: DataFrame

Friction slope, location × profiles (m/m).

property hydraulic_depth_channel: DataFrame

Channel hydraulic depth, location × profiles (m).

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_depth_total: DataFrame

Total hydraulic depth, location × profiles (m).

property hydraulic_radius_channel: DataFrame

Channel hydraulic radius, 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 hydraulic_radius_total: DataFrame

Total 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²).

property mannings_n_channel: DataFrame

Weighted channel Manning’s n, location × profiles.

property mannings_n_left_ob: DataFrame

Left overbank Manning’s n, location × profiles.

property mannings_n_right_ob: DataFrame

Right overbank Manning’s n, location × profiles.

property mannings_n_total: DataFrame

Total weighted Manning’s n, location × profiles.

property max_depth_total: DataFrame

Total maximum water depth, location × profiles (m).

profile_table(variable)[source]

Return a location × profiles pd.DataFrame for 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, then Additional Variables/<variable>.

Returns:

  • Indexpd.MultiIndex with 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 into timestamps.

  • Valuesfloat.

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 shear: DataFrame

Bed shear stress, location × profiles (N/m²).

property top_width_channel: DataFrame

Channel top width, location × profiles (m).

property top_width_channel_with_ineffective: DataFrame

Channel top width including ineffective areas, location × profiles (m).

property top_width_left_ob: DataFrame

Left overbank top width, 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: DataFrame

Right overbank top width, 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: DataFrame

Total top width, location × profiles (m).

property top_width_total_with_ineffective: DataFrame

Total top width including ineffective areas, location × profiles (m).

property velocity_channel: DataFrame

Channel velocity, location × profiles (m/s).

property velocity_left_ob: DataFrame

Left overbank velocity, location × profiles (m/s).

property velocity_right_ob: DataFrame

Right overbank velocity, location × profiles (m/s).

property velocity_total: DataFrame

Total velocity, location × profiles (m/s).

property wetted_perimeter_channel: DataFrame

Channel wetted perimeter, 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).

property wetted_perimeter_total: DataFrame

Total wetted perimeter, location × profiles (m).

property wse: DataFrame

Water-surface elevation, location × profiles (m).

Returns:

Columns ["max_wse", 0, 1, …].

Return type:

pd.DataFrame

property wse_total: DataFrame

Total WSE from Additional Variables, location × profiles (m).

class rivia.hdf.unsteady_plan.CrossSectionProfileResults(geom, hdf, index, root, timestamps)[source]

Bases: _CrossSectionResultsBase

Geometry 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 the Cross Section Attributes structured array unique to this block.

Parameters:
  • geom (CrossSection) – Geometry object from CrossSectionCollection.

  • hdf (File) – Open h5py.File – kept alive by the parent UnsteadyPlan context.

  • 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.

property cross_section_attributes: void | None

Structured-array row for this XS from Cross Section Attributes.

Contains River, Reach, Station, and Name fields. Returns None when the dataset is absent from this HDF file.

property flow: Series

Flow time series, indexed by timestamps.

property wse: Series

Water surface elevation time series, indexed by timestamps.

class rivia.hdf.unsteady_plan.CrossSectionResultsCollection(hdf, root, result_cls=<class 'rivia.hdf.unsteady_plan.CrossSectionMappingResults'>, attrs_path=None, timestamps_fn=None)[source]

Bases: CrossSectionCollection

Plan-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) – Open h5py.File handle.

  • 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, or CrossSectionPostProcessResults.

  • attrs_path (str | None) – HDF path to the Cross Section Attributes structured array used to map (river, reach, station) -> column index. Defaults to f"{root}/Cross Section Attributes", which is correct for Base Output and DSS blocks. Pass _POSTPROC_GEOM_ATTRS for the Post Process block, where attributes live outside the XS result group.

  • timestamps_fn (Callable[[], DatetimeIndex] | None) – Zero-argument callable that returns the pd.DatetimeIndex for this block. Resolved lazily on first access; the result is cached on timestamps.

property names: list[str]

Cross section keys available in this result block.

Returns:

Keys of the form "<river> <reach> <station>".

Return type:

list[str]

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_fn was supplied.

class rivia.hdf.unsteady_plan.FlowAreaResults(geom_group, ts_group, sum_group, name, n_cells)[source]

Bases: _FlowAreaResultsDerived

Geometry and time-series results for one named 2-D flow area.

Inherits all geometry properties from FlowArea and all derived/computed methods from _FlowAreaResultsDerived.

Method naming conventions

Raw dataset propertiesh5py.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:
  • geom_group (Group) – h5py.Group at Geometry/2D Flow Areas/<name>.

  • ts_group (Group) – h5py.Group at the time-series result path for this area.

  • sum_group (Group) – h5py.Group at the summary result path for this area.

  • name (str) – Flow area name.

  • n_cells (int) – Number of real computational cells.

property cell_velocity: Dataset | None

HEC-RAS cell-velocity speed scalar, or None if not output.

h5py.Dataset, shape (n_timesteps, n_cells). This is the optional output enabled in the HDF Write Parameters; see get_cell_velocity() for the derived vector field.

property face_flow: Dataset | None

Volumetric face-flow time series, or None if 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 Stamp dataset (sibling of the 2D Flow Areas group under Unsteady Time Series). Used as the index for all time-series results returned by get_* 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: FlowAreaCollection

Collection of FlowAreaResults objects backed by a plan HDF file.

Overrides FlowAreaCollection to return FlowAreaResults instead of plain FlowArea instances.

Parameters:

hdf (h5py.File)

class rivia.hdf.unsteady_plan.InlineResults(geom, group, timestamps)[source]

Bases: _StructureResultsMixin, InlineStructure

Geometry and time-series results for one HEC-RAS inline structure.

Inherits geometry from InlineStructure and 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 from StructureCollection.

  • group (Group) – h5py.Group at the inline structure result path.

  • timestamps (DatetimeIndex) – Output timestamps for this block; index for all pd.Series properties.

class rivia.hdf.unsteady_plan.LateralResults(geom, group, timestamps, skip_row0=False)[source]

Bases: _StructureResultsMixin, LateralStructure

Geometry and time-series results for one HEC-RAS lateral structure.

Inherits geometry from LateralStructure and shared HDF result access from _StructureResultsMixin.

The HDF group is at Results/.../DSS Hydrograph Output/.../Lateral Structures/<river reach rs>.

downstream_node is 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 from StructureCollection.

  • group (Group) – h5py.Group at the lateral structure result path.

  • timestamps (DatetimeIndex) – Output timestamps for this block; index for all pd.Series properties.

  • skip_row0 (bool)

property flow_hw_ds: Series

Flow at the downstream bounding cross section, indexed by timestamps.

property flow_hw_us: Series

Flow at the upstream bounding cross section, indexed by timestamps.

property stage_hw_ds: Series

Stage at the downstream bounding cross section, indexed by timestamps.

property stage_hw_us: Series

Stage at the upstream bounding cross section, indexed by timestamps.

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: object

Overall 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 None when the simulation went unstable before convergence.

  • time_unstable – Elapsed simulation time (days) when the solution went unstable, or None if the run finished successfully.

  • timestamp_unstable – HEC-RAS date/time string for the instability, or None if the run finished successfully (HEC-RAS writes "Not Applicable").

Parameters:
  • solution (str)

  • run_window (str)

  • compute_time_total (str)

  • compute_time_dss (str)

  • max_cores (int)

  • max_wsel_error (float | None)

  • time_unstable (float | None)

  • timestamp_unstable (str | None)

compute_time_dss: str
compute_time_total: str
max_cores: int
max_wsel_error: float | None
parse_run_window()[source]

Parse run_window into (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-naive datetime.datetime objects, or None when 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
run_window: str
solution: str
time_unstable: float | None
timestamp_unstable: str | None
to_dict()[source]

Return a dict with short, meaningful keys.

Return type:

dict[str, Any]

class rivia.hdf.unsteady_plan.SA2DConnectionResults(geom, group, timestamps, skip_row0=False)[source]

Bases: _StructureResultsMixin, SA2DConnection

Geometry and time-series results for one HEC-RAS SA/2D connection.

Inherits geometry from SA2DConnection and shared HDF result access (structure_variables, total_flow, stage_hw, stage_tw, weir_variables, flow_gate) from _StructureResultsMixin.

Parameters:
  • geom (SA2DConnection) – Geometry object from StructureCollection.

  • group (Group) – h5py.Group at -/SA 2D Area Conn/<plan_name>.

  • timestamps (DatetimeIndex) – Output timestamps for this block; index for all pd.Series properties.

  • skip_row0 (bool)

property breaching_variables: Dataset | None

Breach geometry and flow time series, or None if 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 None if absent.

Shape (n_faces,).

property tailwater_cells: ndarray | None

2-D mesh cell indices on the tailwater side, or None if absent.

For 2D<->2D connections (levees) these are stored as a flat int32 dataset 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 in HW TW Segments/Tailwater Cells and 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: StorageArea

Geometry 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.Series indexed by timestamps.

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 under Storage Areas/.

  • ts_sa_group (Group | None) – h5py.Group at -/Unsteady Time Series/Storage Areas, or None when the plan has no SA results.

  • sum_sa_group (Group | None) – h5py.Group at -/Summary Output/Storage Areas, or None.

  • timestamps (DatetimeIndex) – Output timestamps for the block this SA was loaded from; used as the index for all pd.Series time-series properties.

  • skip_row0 (bool)

property connection_names: list[str]

Names of the inflow connection sources (from HDF Connections attribute).

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), or None when no connection data is stored. Column names are in connection_names.

property flow: Series

Net inflow rate (positive = into SA), indexed by timestamps.

property inflow: Series

Total inflow rate (sum of all inflow sources), indexed by timestamps.

property inflow_net: Series

Net inflow rate, indexed by timestamps.

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.

property min_wse: DataFrame

Minimum WSE. Same column layout as max_wse.

property outflow: Series

Total outflow rate (sum of all outflow sinks), indexed by timestamps.

property surface_area: Series

Water-surface area time series (model area units), indexed by timestamps.

property volume: Series

Stored volume time series (model volume units), indexed by timestamps.

property wse: Series

Water-surface elevation time series, indexed by timestamps.

class rivia.hdf.unsteady_plan.StorageAreaResultsCollection(hdf, output='mapping')[source]

Bases: StorageAreaCollection

Collection of StorageAreaResults backed by a plan HDF file.

Overrides StorageAreaCollection to return StorageAreaResults with both geometry and plan results.

The timestamps property exposes the output block’s time axis as a pd.DatetimeIndex; it is also passed into each StorageAreaResults item so per-SA pd.Series properties share the same index.

Parameters:
  • hdf (File) – Open h5py.File handle.

  • 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: StructureCollection

Plan-enriched structure collection: all structure types with results.

Overrides StructureCollection so each item carries both geometry attributes and time-series result access.

Parameters:
  • hdf (File) – Open h5py.File handle.

  • 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, Geometry

Read HEC-RAS plan HDF5 output files (*.p*.hdf).

A plan HDF file contains the same Geometry/ data as a geometry HDF file, plus Results/Unsteady/... time-series and summary output.

Parameters:
  • filename (str | Path) – Path to the plan HDF file. The .hdf suffix is appended automatically if absent.

  • program_directory (str | Path | None)

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 None if absent.

Read from Plan Data/Plan Information attribute Computation 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 to ComputeSummary.errors(). See that method for full documentation.

See also

ComputeSummary.errors

Full documentation and return-value details.

compute_ok

Quality-control pass/fail check with threshold logging.

Return type:

dict[str, float]

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 True if the simulation completed stably and all error metrics are within their thresholds.

Convenience wrapper: calls compute_summary() and delegates to ComputeSummary.ok(). See that method for full documentation, including parameter descriptions and logging behaviour.

Return type:

bool

Parameters:
  • wse_threshold (float)

  • volume_error_pct_threshold (float)

  • volume_1d_error_pct_threshold (float)

  • volume_2d_error_pct_threshold (float)

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.ok

Full documentation and parameter descriptions.

compute_errors

Raw error metric values.

compute_summary()[source]

Return the full unsteady simulation summary.

Reads all groups under Results/Unsteady/Summary and returns a ComputeSummary dataclass 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:

ComputeSummary

Raises:

KeyError – If Results/Unsteady/Summary is 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. Returns CrossSectionResultsCollection whose items are CrossSectionMappingResults. Per-XS pd.Series properties: wse, flow, flow_lateral, velocity_channel, velocity_total, flow_cumulative.

"output" — DSS Hydrograph Output at the hydrograph interval. Returns CrossSectionResultsCollection whose items are CrossSectionOutputResults. Per-XS pd.Series properties: wse, flow, flow_cumulative.

"profile" — DSS Profile Output at the detailed interval. Returns CrossSectionResultsCollection whose items are CrossSectionProfileResults. Per-XS pd.Series properties: wse, flow, cross_section_attributes.

"post_process" — Post Process Profiles. Returns a CrossSectionPostProcessResultsCollection with collection-level profile_table(variable) method and named properties (wse, flow, velocity_channel, …) each returning a location × profiles pd.DataFrame. [key] returns a CrossSectionPostProcessResults whose named properties (wse, flow, velocity_channel, …) each return a pd.Series indexed by pd.DatetimeIndex (timeseries only, Max WS envelope excluded).

Returns:

Collection supporting [key], integer index, and names. Timestamps are available as coll.timestamps.

Return type:

CrossSectionResultsCollection

Raises:

ValueError – If output is not one of the four recognised values.

property detailed_interval: timedelta | None

Detailed output interval, or None if absent.

Derived from the difference between the first two timestamps in the DSS Profile Output Time Date Stamp dataset. 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 Stamp dataset. Both cross_sections("profile") / storage_areas("profile") and cross_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 None if absent.

Read from Plan Data/Plan Information attribute Base 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 Stamp dataset 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 None if absent.

Reads only the shape of the DSS Profile Time Date Stamp dataset.

property n_mapping_timestamps: int | None

Number of mapping output time steps, or None for 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 None if absent.

Reads only the dataset shape – no timestamp data is loaded.

property output_interval: timedelta | None

DSS hydrograph output interval, or None if 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 Version root 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() and adaptive_timesteps().

Return type:

UnsteadyRuntimeLog

Raises:

KeyError – If Results/Summary is 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 SA2DConnectionResults when plan output is present, plain SA2DConnection otherwise.

Return type:

dict[str, SA2DConnection]

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. Summary max_wse / min_wse raise KeyError (summary group absent from this block).

Returns:

Exposes a timestamps property with the block’s pd.DatetimeIndex, shared as the index of every per-SA pd.Series property.

Return type:

StorageAreaResultsCollection

structures(output='output')[source]

Access all structures with geometry and plan results.

Returns a StructureResultsCollection where 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 timestamps property with the block’s pd.DatetimeIndex, shared as the index of every per-structure pd.Series property. Use connections, inlines, laterals, and bridges for filtered access.

Return type:

StructureResultsCollection

class rivia.hdf.unsteady_plan.VolumeAccounting(units, vol_start, vol_end, inflow, outflow, error, error_pct)[source]

Bases: object

Overall 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:
error: float
error_pct: float
inflow: float
outflow: float
to_dict()[source]

Return a dict with short, meaningful keys.

Return type:

dict[str, Any]

units: str
vol_end: float
vol_start: float
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: object

1-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:
diversions: float
flow_ds_out: float
flow_us_in: float
groundwater: float
hydro_lat: float
hydro_sa: float
precip_excess: float
reach_vol_end: float
reach_vol_start: float
sa_vol_end: float
sa_vol_start: float
to_dict()[source]

Return a dict with short, meaningful keys.

Return type:

dict[str, Any]

units: str
class rivia.hdf.unsteady_plan.VolumeAccounting2DArea(units, vol_start, vol_end, cum_inflow, cum_outflow, error, error_pct)[source]

Bases: object

Volume 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:
cum_inflow: float
cum_outflow: float
error: float
error_pct: float
to_dict()[source]

Return a dict with short, meaningful keys.

Return type:

dict[str, Any]

units: str
vol_end: float
vol_start: float