Results Queries¶
For repeatable batch plots, start with the 2D profile and reference workflow guide. The classes below separate cell sampling, native Mapper rendering, geometry reference-feature authoring, and reading recorded solver output. These methods do not themselves run a hydraulic simulation.
Runtime and output contracts¶
| Surface | Input | Return | Requirements |
|---|---|---|---|
| Offline point/straight-profile sampling | Completed plan HDF, model-coordinate points/endpoints, variable and stored time selector | Dictionary or DataFrame of values and nearest-cell provenance | Python/HDF; reconstructed quantities are not a Mapper renderer |
| Native polyline profile | Plan HDF, LineString/coordinates, time index, spacing, optional terrain HDF | DataFrame: station, x, y, mesh_name, face_id, variable fields; WSE/velocity/flow profiles also include depth, terrain_elev |
pythonnet and compatible installed HEC-RAS libraries |
| Native polyline time series | Same inputs, optional time_range |
Long DataFrame, or wide=True station-by-time_index pivot of the selected variable |
Same native runtime; saved result times only |
| Stored reference output | Completed plan HDF, optional variable names | xarray Dataset; lines use time, refln_id and coordinate refln_name; points use refpt_id and refpt_name; both include mesh_name |
Reference locations present during computation; offline reader |
| Reference-feature generation/writing | Longitudinal coordinates, spacing/length, geometry file, target 2D area | Reviewable dictionaries or write count | Writes geometry, not computed results |
Native terrain_raster arguments currently resolve a RAS terrain HDF.
Coordinates must already match the model; the query does not reproject them.
sample_spacing=None requests 50 model coordinate units. Returned stations need
not be uniformly spaced at that request and may repeat. Native minimum-spacing
and sample-count limits also apply. wide=True uses a first-value aggregation
for repeated station/time-index pairs; keep long output to inspect all samples.
Native polyline
methods require a concrete output index and reject "max"; time-series ranges
are start-inclusive/stop-exclusive. The current shared input path rejects 2D
bridge groups. There is no public render-mode selector in these methods.
face_id in native sampled profiles is nearest-face metadata, not a guarantee
that a renderer used only that face. Preserve DataFrame attrs alongside CSV
exports for source/version/unit information. See the guide for terrain,
maximum-envelope and timestamp comparisons.
Offline spatial sampling¶
Spatial query utilities for 2D HEC-RAS results.
query_point
staticmethod
¶
query_point(hdf_path: Path, x: float, y: float, variable: str = 'wse', time_index: Union[int, str] = -1, method: str = 'nearest', ras_object: Optional[Any] = None) -> Dict[str, Any]
Query one arbitrary point against the nearest mesh cell or IDW.
At integer time indexes, unsteady velocity queries prefer stored
Cell Velocity - Velocity X/Y
components with validated cell/time axes, Location and velocity units.
Speed is their magnitude. Legacy components and face reconstruction
remain fallbacks when the stored pair is incomplete. Vector queries select
a complete pair from one source per mesh; direct single-component
queries may use a qualified stored axis alone. Invalid present schemas
raise ValueError rather than silently falling back.
Returns:
| Type | Description |
|---|---|
dict with keys
|
value, cell_id, mesh_name, distance, x, y |
Source code in ras_commander/hdf/HdfResultsQuery.py
query_points
staticmethod
¶
query_points(hdf_path: Path, points: Any, variable: str = 'wse', time_index: Union[int, str] = -1, method: str = 'nearest', ras_object: Optional[Any] = None) -> pd.DataFrame
Query many points against the nearest mesh cells in one call.
At integer time indexes, unsteady velocities use the stored-component precedence and validation
documented by :meth:query_point, independently for each mesh.
Accepted point formats: - list of (x, y) tuples - numpy array with shape (N, 2) - GeoDataFrame with Point geometries
Source code in ras_commander/hdf/HdfResultsQuery.py
query_profile
staticmethod
¶
query_profile(hdf_path: Path, x1: float, y1: float, x2: float, y2: float, variable: str = 'wse', n_points: int = 100, time_index: Union[int, str] = -1, ras_object: Optional[Any] = None) -> pd.DataFrame
Sample evenly spaced points along a transect.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with station, x, y, value, cell_id, mesh_name, distance |
Source code in ras_commander/hdf/HdfResultsQuery.py
query_transverse_profile
staticmethod
¶
query_transverse_profile(hdf_path: Path, x: float, y: float, time_index: Union[int, str] = -1, max_steps: int = 25, min_velocity: float = 0.05, mesh_name: Optional[str] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
March cell-by-cell across local flow to build an approximate velocity transect.
.. warning::
This method reconstructs cell-centered velocities from stored HDF
face-normal components via least-squares. It does not have access
to the internal solver state that HEC-RAS uses when computing
Reference Line output. Treat this as an approximate cell-based
transect. query_polyline_velocity_profile provides native
RASMapper station-wise postprocessing; it is not a reader for
solver-recorded Reference Line hydrographs. For those hydrographs,
define Reference Lines before computing the plan, then use
HdfResultsXsec.get_ref_lines_timeseries to read the recorded
variables. A station profile and a line-integrated or line-averaged
time series answer different questions; neither is a substitute
for checking the model and the quantity required by the study.
The seed point is snapped to the nearest 2D cell. The seed cell's
velocity vector defines the transverse axis, and the marcher advances
across adjacent mesh faces in both directions until it reaches a mesh
boundary, an already visited cell, max_steps, or a cell below
min_velocity.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with station, x, y, cell_id, mesh_name, velocity, |
DataFrame
|
velocity_x, velocity_y, side, step, entry_face_id, and |
DataFrame
|
distance_from_seed. |
Source code in ras_commander/hdf/HdfResultsQuery.py
| Python | |
|---|---|
2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 | |
Native mapped profiles and time series¶
The flow sample column is not automatically whole-line Q. Use recorded
reference-line flow for that quantity when available; do not sum station samples.
Spatial query utilities for 2D HEC-RAS results.
query_polyline_wse_profile
staticmethod
¶
query_polyline_wse_profile(hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Extract RAS Mapper WSE/depth/terrain samples along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_velocity_profile
staticmethod
¶
query_polyline_velocity_profile(hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Extract RAS Mapper velocity/depth/terrain samples along a profile line.
This method delegates velocity computation to
RasMapperLib.Render.VelocityRenderer.Compute through pythonnet.
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with station, x, y, mesh_name, face_id, velocity_x, |
DataFrame
|
velocity_y, velocity_mag, depth, and terrain_elev columns. |
Source code in ras_commander/hdf/HdfResultsQuery.py
| Python | |
|---|---|
1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 | |
query_polyline_flow_profile
staticmethod
¶
query_polyline_flow_profile(hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Extract RAS Mapper flow/depth/terrain samples along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_wse_timeseries
staticmethod
¶
query_polyline_wse_timeseries(hdf_path: Path, polyline: Any, time_range: Optional[tuple[int, int]] = None, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None, wide: bool = False) -> pd.DataFrame
Extract RAS Mapper WSE time series along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_velocity_timeseries
staticmethod
¶
query_polyline_velocity_timeseries(hdf_path: Path, polyline: Any, time_range: Optional[tuple[int, int]] = None, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None, wide: bool = False) -> pd.DataFrame
Extract RAS Mapper velocity time series along a profile line.
time_range uses Python slicing semantics: (start, stop) includes
start and excludes stop. None returns all profiles.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_flow_timeseries
staticmethod
¶
query_polyline_flow_timeseries(hdf_path: Path, polyline: Any, time_range: Optional[tuple[int, int]] = None, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None, wide: bool = False) -> pd.DataFrame
Extract RAS Mapper flow time series along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_wse_difference
staticmethod
¶
query_polyline_wse_difference(base_hdf_path: Path, compare_hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Compare RAS Mapper water-surface profiles between two plan HDFs.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_velocity_difference
staticmethod
¶
query_polyline_velocity_difference(base_hdf_path: Path, compare_hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Compare RAS Mapper velocity profiles between two plan HDFs.
Source code in ras_commander/hdf/HdfResultsQuery.py
| Python | |
|---|---|
2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 | |
query_polyline_pipe_velocity_profile
staticmethod
¶
query_polyline_pipe_velocity_profile(hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Extract RAS Mapper pipe velocity samples along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_pipe_flow_profile
staticmethod
¶
query_polyline_pipe_flow_profile(hdf_path: Path, polyline: Any, time_index: int, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None) -> pd.DataFrame
Extract RAS Mapper pipe flow samples along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_pipe_velocity_timeseries
staticmethod
¶
query_polyline_pipe_velocity_timeseries(hdf_path: Path, polyline: Any, time_range: Optional[tuple[int, int]] = None, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None, wide: bool = False) -> pd.DataFrame
Extract RAS Mapper pipe velocity time series along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
query_polyline_pipe_flow_timeseries
staticmethod
¶
query_polyline_pipe_flow_timeseries(hdf_path: Path, polyline: Any, time_range: Optional[tuple[int, int]] = None, sample_spacing: Optional[float] = None, terrain_raster: Optional[Union[str, Path]] = None, ras_object: Optional[Any] = None, wide: bool = False) -> pd.DataFrame
Extract RAS Mapper pipe flow time series along a profile line.
Source code in ras_commander/hdf/HdfResultsQuery.py
Recorded reference hydrographs¶
These methods read HDF datasets recorded during computation, including 2D
reference results despite the class name. An absent group or no matching numeric
variables produces an empty Dataset; a present group missing required Name or
timestamps raises KeyError. Missing or malformed output is not zero flow. Use list(result.data_vars) to discover
available variables and retain their unit/source attributes. Feature names are
coordinates, not necessarily xarray indexes; use isel(refln_id=...) or
explicit coordinate filtering instead of assuming .sel(refln_name=...) works.
A static class for extracting and processing 1D results data from HEC-RAS HDF files.
This class provides methods to extract and process unsteady flow simulation results for cross-sections, reference lines, and reference points. All methods are static and designed to be used without class instantiation.
The class handles: - Cross-section timeseries (water surface, velocity, flow) - Reference line timeseries - Reference point timeseries
Dependencies
- HdfBase: Core HDF file operations
- HdfUtils: Utility functions for HDF processing
get_ref_lines_timeseries
staticmethod
¶
get_ref_lines_timeseries(hdf_path: Path, variables: Optional[Union[str, Sequence[str]]] = None) -> xr.Dataset
Extract timeseries output data for reference lines from HEC-RAS HDF file.
Parameters:¶
hdf_path : Path Path to the HEC-RAS results HDF file variables : str or sequence of str, optional HDF dataset names to include. If omitted, all numeric datasets with shape (time, reference_line) are returned.
Returns:¶
xr.Dataset Dataset containing numeric native HDF time-series data for reference lines. Returns empty dataset if reference line data not found.
Raises:¶
FileNotFoundError If the specified HDF file is not found KeyError If required datasets are missing from the HDF file
Source code in ras_commander/hdf/HdfResultsXsec.py
get_ref_points_timeseries
staticmethod
¶
get_ref_points_timeseries(hdf_path: Path, variables: Optional[Union[str, Sequence[str]]] = None) -> xr.Dataset
Extract timeseries output data for reference points from HEC-RAS HDF file.
This method extracts flow, velocity, and water surface elevation data for all reference points defined in the model. Reference points are user-defined locations where detailed output is desired.
Parameters:¶
hdf_path : Path Path to the HEC-RAS results HDF file variables : str or sequence of str, optional HDF dataset names to include. If omitted, all numeric datasets with shape (time, reference_point) are returned.
Returns:¶
xr.Dataset Dataset containing numeric native HDF time-series variables for each reference point.
The dataset includes coordinates:
- time: Simulation timesteps
- refpt_id: Unique identifier for each reference point
- refpt_name: Name of each reference point
- mesh_name: Associated 2D mesh area name
Returns empty dataset if reference point data not found.
Raises:¶
FileNotFoundError If the specified HDF file is not found KeyError If required datasets are missing from the HDF file
Examples:¶
ds = HdfResultsXsec.get_ref_points_timeseries("path/to/plan.hdf")
Get water surface timeseries for first reference point¶
ws = ds['Water Surface'].isel(refpt_id=0)
Get all data for a specific reference point by name¶
point_data = ds.where(ds['refpt_name'] == 'Point1', drop=True)
Source code in ras_commander/hdf/HdfResultsXsec.py
For a tidy DataFrame instead of xarray, use
HdfResultsPlan.get_reference_timeseries(hdf_path, reftype="lines") (or
"points"). It delegates to the reference readers and returns one row per
stored time/feature pair. An empty DataFrame can mean missing output or a
caught read error; inspect logged diagnostics rather than interpreting absence
as zero flow or stage.
Handles extraction of results data from HEC-RAS plan HDF files.
This class provides static methods for accessing and analyzing
- Unsteady flow results
- Volume accounting data
- Runtime statistics
- Reference line/point time series outputs
All methods use
- @standardize_input decorator for consistent file path handling
- @log_call decorator for operation logging
- HdfUtils class for common HDF operations
Note
No instantiation required - all methods are static.
get_reference_timeseries
staticmethod
¶
Get reference-line or reference-point time series as a tidy DataFrame.
Modern HEC-RAS HDF files store a Name vector plus shared
(time, feature) matrices such as Flow, Velocity, and Water Surface.
This compatibility method delegates schema handling to
:class:HdfResultsXsec and converts its native xarray Dataset to one
row per time/feature pair. It therefore supports all numeric variables
present in the HDF instead of assuming one dataset per feature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hdf_path
|
Path
|
Path to HEC-RAS plan HDF file |
required |
reftype
|
str
|
Type of reference data ('lines' or 'points') |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Tidy frame containing time, reference ID/name, mesh name, and every numeric native result variable. Returns an empty frame when the requested reference output is absent or an error is caught, including an invalid reftype. Inspect log diagnostics; an empty result is not a zero-valued hydrograph. |
Source code in ras_commander/hdf/HdfResultsPlan.py
Named-line Q and extraction provenance¶
The canonical method needs RasMapperLib. It first attempts a native-associated
precomputed hydrograph via ObservedDataLayer.TryReadRefLineFlow, then falls
back to face aggregation. This native-associated hydrograph's provenance has
not been independently qualified as solver output and may be observed data.
Use HdfResultsXsec.get_ref_lines_timeseries for explicit solver-recorded HDF
Reference Lines datasets. Inspect selection_source in
the returned DataFrame: try_read_ref_line_flow is distinct from
reference_line_internal_faces and rasmapper_perimeter_faces.
For native-associated hydrographs, direction="absolute" takes abs(Q); for aggregated
faces it sums abs(Q_face). The latter is not a net flux. The signed face
fallback sums native face signs without a common line-normal correction or
solver projected-length weighting. _legacy is the explicit offline path,
not an automatic fallback when the native runtime is unavailable.
The workflow guide
provides the interpretation table. The native-associated lookup is by name only,
so duplicate names across meshes are ambiguous. Its face_count=0 and empty
face_ids identify the lookup path, not a physical face count; an omitted
mesh_name is reported as an empty string.
Handles mesh-related results from HEC-RAS HDF files.
Provides methods to extract and analyze: - Mesh summary outputs - Timeseries data - Water surface elevations - Velocities - Error metrics
Works with HEC-RAS 6.0+ plan HDF files.
get_profile_line_flow_timeseries
staticmethod
¶
get_profile_line_flow_timeseries(hdf_path: Path, line_name: str, mesh_name: Optional[str] = None, profile_lines_path: Optional[Union[str, Path]] = None, direction: str = 'absolute', truncate: bool = False, ras_object: Optional[Any] = None) -> pd.DataFrame
Return a flow time series across a RAS Mapper profile/reference line.
Recorded computed reference-line Flow is read first through
HdfResultsXsec.get_ref_lines_timeseries(), without pythonnet or
face-output requirements. Observed Event Conditions data is not used.
Otherwise native reference-line faces and ad-hoc profile lines are read through
RASResults.ReadUnsteadyTimeSeries() after selecting ad-hoc faces
with MeshFV2D.PerimeterFacesAlongPolyline().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hdf_path
|
Path
|
Completed plan HDF, with the matching geometry available. |
required |
line_name
|
str
|
Exact reference-line or profile-layer feature name. |
required |
mesh_name
|
Optional[str]
|
Optional 2D flow area selector. |
None
|
profile_lines_path
|
Optional[Union[str, Path]]
|
Optional external profile-line layer. Coordinates must match the model CRS; project metadata can resolve this path. |
None
|
direction
|
str
|
|
'absolute'
|
truncate
|
bool
|
Trim leading and trailing zero-flow samples when true. |
False
|
ras_object
|
RasPrj
|
Optional initialized project context. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with |
DataFrame
|
|
include units, variable and face IDs. Preserve this provenance
|
|
DataFrame
|
|
DataFrame
|
reference matrix, with its dataset path and reference ID in attrs; |
DataFrame
|
face-selection routes identify |
DataFrame
|
aggregation of stored face output, not a new solver calculation. |
DataFrame
|
Missing units are not inferred. |
Notes
Face fallbacks require pythonnet and compatible RasMapperLib. For an
offline approximation use get_profile_line_flow_timeseries_legacy.
To read recorded reference matrices directly without native mapping,
use HdfResultsXsec.get_ref_lines_timeseries. Reading an HDF cannot
create reference output that was not recorded by the model run.
Source code in ras_commander/hdf/HdfResultsMesh.py
| Python | |
|---|---|
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | |
get_profile_line_flow_timeseries_legacy
staticmethod
¶
get_profile_line_flow_timeseries_legacy(hdf_path: Path, line_name: str, mesh_name: Optional[str] = None, profile_lines_path: Optional[Union[str, Path]] = None, direction: str = 'absolute', truncate: bool = False, ras_object: Optional[Any] = None) -> pd.DataFrame
Return a legacy pure-Python profile/reference-line flow time series.
This method predates the pythonnet/RasMapperLib profile API. It selects
native reference-line internal faces when available, otherwise reads a
RAS Mapper Profile Lines feature file and uses
HdfMesh.get_faces_along_profile_line() plus direct HDF Face Flow
time series. Keep using it for offline analysis without a HEC-RAS
install or to reproduce pre-CLB-852 results; it is retained for
backward compatibility.
Parameters¶
hdf_path : Path
Plan HDF path, plan number, or other input accepted by
@standardize_input(file_type='plan_hdf').
line_name : str
Profile/reference line name to extract.
mesh_name : Optional[str], optional
2D flow area name. Required when the line resolves to more than one
mesh area.
profile_lines_path : Optional[Union[str, Path]], optional
Explicit RAS Mapper Profile Lines feature path. If omitted, the
method attempts to use ras_object.rasmap_df.profile_lines_path.
direction : str, default "absolute"
"absolute" sums absolute face flows to avoid face-normal sign
cancellation. "signed" preserves native HEC-RAS face-flow signs;
orientation is controlled by the underlying face normals.
truncate : bool, default False
Passed to get_mesh_timeseries().
ras_object : Optional[Any], optional
RAS project object used for plan-number and rasmap path resolution.
Returns¶
pd.DataFrame
Columns: time, flow, line_name, mesh_name,
direction, face_count, and selection_source.
Source code in ras_commander/hdf/HdfResultsMesh.py
| Python | |
|---|---|
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 | |
get_profile_line_peak_flow
staticmethod
¶
get_profile_line_peak_flow(hdf_path: Path, line_name: str, mesh_name: Optional[str] = None, profile_lines_path: Optional[Union[str, Path]] = None, direction: str = 'absolute', ras_object: Optional[Any] = None) -> pd.DataFrame
Return peak flow across a RAS Mapper profile/reference line.
For direction="absolute", the peak is the maximum of the selected
extraction route's absolute-flow series: absolute recorded reference
hydrograph flow or a sum of absolute face flows. Preserve selection_source to
distinguish these quantities. For direction="signed", the peak timestep is selected by
maximum signed-flow magnitude and the returned peak_flow preserves
the native sign at that timestep. A peak from saved output times need
not equal a peak over every computational timestep.
Source code in ras_commander/hdf/HdfResultsMesh.py
Reference-feature authoring¶
Generate proposed lines first, inspect them, then write to a working geometry.
Recompute and inspect the resulting reference output groups. In particular,
add_reference_points writes native Reference Point Name/Position records with
literal names. Notebook 207 demonstrates a fresh 6.6 compute and native HDF reads.
Example 314's retained historical IC-authored run is separate evidence.
Authored point records plus a successful run do not guarantee recorded point
results. A profile line
used only for postprocessing does not retroactively become a recorded reference
location. Reference areas are not covered by these point/line writers.
Insert reference lines and reference points into .g## geometry files.
generate_reference_lines_from_longitudinal_line
staticmethod
¶
generate_reference_lines_from_longitudinal_line(longitudinal_lines: Any, spacing: float, line_length: float, *, longitudinal_line_name: Optional[str] = None, name_column: str = 'Name', name_template: str = '{source_name}_Ref_{index:03d}', start_station: float = 0.0, end_station: Optional[float] = None, include_end: bool = False, tangent_sample_distance: Optional[float] = None, extend_by: float = 0.0, orientation: str = 'normal', orientation_plan_hdf: Optional[Union[str, Path]] = None, orientation_time_index: Union[int, str] = -1, orientation_query_method: str = 'nearest', orientation_angle_callback: Optional[Callable[[dict], Optional[float]]] = None, orientation_fallback: str = 'normal', velocity_min: float = 1e-06, depth_min: float = 0.0, ras_object: Optional[Any] = None, storage_area: Optional[str] = None) -> List[dict]
Generate transverse reference lines along longitudinal/profile lines.
This creates the same {"name", "coordinates"} dictionaries accepted
by :meth:add_reference_lines, so callers can review the generated
transects before writing them to a HEC-RAS plain text geometry file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
longitudinal_lines
|
Any
|
A Shapely LineString, GeoDataFrame, coordinate
array, dict with |
required |
spacing
|
float
|
Station interval along each longitudinal line, in model units. |
required |
line_length
|
float
|
Generated transverse reference-line length, in model units. |
required |
longitudinal_line_name
|
Optional[str]
|
Optional name of the source line to select from GeoDataFrame/list inputs. |
None
|
name_column
|
str
|
Preferred source-name column for GeoDataFrame inputs. |
'Name'
|
name_template
|
str
|
Format string for generated line names. Available
fields are |
'{source_name}_Ref_{index:03d}'
|
start_station
|
float
|
First station along the source line. |
0.0
|
end_station
|
Optional[float]
|
Last station along the source line. Defaults to the source line length. |
None
|
include_end
|
bool
|
Include |
False
|
tangent_sample_distance
|
Optional[float]
|
Half-window used to compute the local tangent direction. Defaults to half the spacing. |
None
|
extend_by
|
float
|
Extra length added to each side of the generated line. |
0.0
|
orientation
|
str
|
|
'normal'
|
orientation_plan_hdf
|
Optional[Union[str, Path]]
|
Plan/result HDF used when |
None
|
orientation_time_index
|
Union[int, str]
|
Time index passed to |
-1
|
orientation_query_method
|
str
|
Query method passed to |
'nearest'
|
orientation_angle_callback
|
Optional[Callable[[dict], Optional[float]]]
|
Optional callable receiving a context
dict and returning a reference-line angle in degrees. Returning
|
None
|
orientation_fallback
|
str
|
|
'normal'
|
velocity_min
|
float
|
Minimum sampled velocity magnitude for velocity-based orientation. |
1e-06
|
depth_min
|
float
|
Minimum sampled depth for |
0.0
|
ras_object
|
Optional[Any]
|
Optional |
None
|
storage_area
|
Optional[str]
|
Optional 2D flow area name included in returned metadata for review. |
None
|
Returns:
| Type | Description |
|---|---|
List[dict]
|
List of reference-line dictionaries. Each dictionary includes |
List[dict]
|
|
List[dict]
|
metadata for review. |
Example
ref_lines = GeomReferenceFeatures.generate_reference_lines_from_longitudinal_line( ... centerlines_gdf, ... longitudinal_line_name="Main River", ... spacing=500, ... line_length=1500, ... ) GeomReferenceFeatures.add_reference_lines("model.g01", ref_lines, "Perimeter 1")
Source code in ras_commander/geom/GeomReferenceFeatures.py
| Python | |
|---|---|
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 | |
add_reference_lines_from_longitudinal_line
staticmethod
¶
add_reference_lines_from_longitudinal_line(geom_file: Union[str, Path], longitudinal_lines: Any, storage_area: str, spacing: float, line_length: float, **kwargs: Any) -> int
Generate and insert transverse reference lines into a geometry file.
This is a convenience wrapper around
:meth:generate_reference_lines_from_longitudinal_line and
:meth:add_reference_lines. Use the generator directly when manual
review of the proposed coordinates is needed before writing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_file
|
Union[str, Path]
|
Path to geometry file (.g##). |
required |
longitudinal_lines
|
Any
|
Source line input accepted by
|
required |
storage_area
|
str
|
Name of the 2D flow area receiving the reference lines. |
required |
spacing
|
float
|
Station interval along each source line. |
required |
line_length
|
float
|
Generated transverse reference-line length. |
required |
**kwargs
|
Any
|
Additional generator options such as
|
{}
|
Returns:
| Type | Description |
|---|---|
int
|
Number of reference lines inserted. |
Source code in ras_commander/geom/GeomReferenceFeatures.py
add_reference_lines
staticmethod
¶
Insert reference lines into a plain text geometry file.
Reference lines are inserted after BC Lines and before IC Points or LCMann sections. They persist through HEC-RAS recomputation because HEC-RAS reads them from the plain text file during geometry preprocessing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geom_file
|
Union[str, Path]
|
Path to geometry file (.g##) |
required |
lines
|
List[dict]
|
List of dicts with: - 'name': str -- unique reference line name - 'coordinates': list of (x,y) tuples or array (N,2) |
required |
storage_area
|
str
|
Name of the 2D flow area (e.g., 'BaldEagleCr') |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of reference lines inserted |
Example
GeomReferenceFeatures.add_reference_lines( ... "model.g01", ... lines=[ ... {"name": "Gauge_01", "coordinates": [(1000, 2000), (1100, 2000)]}, ... ], ... storage_area="MyMesh", ... )
Source code in ras_commander/geom/GeomReferenceFeatures.py
| Python | |
|---|---|
992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | |
replace_reference_lines
staticmethod
¶
replace_reference_lines(geom_file: Union[str, Path], storage_area: str, reference_lines: Sequence[Mapping[str, Any]], *, expected_existing_names: Optional[Sequence[str]] = None, create_backup: bool = True) -> Optional[Path]
Atomically replace one 2D area's complete reference-line collection.
This is the safe mutation for reduced 2D domains: callers can remove parent reference lines that no longer intersect the retained mesh and optionally clip the survivors before replacing them. Reference lines belonging to other 2D areas are preserved byte-for-byte.
Names may contain commas, parentheses and spaces. Unchanged named lines retain their original records, including padding, positions and coordinate precision. Changed collections are written with CRLF. An unchanged ordered collection is not rewritten, preserving all bytes and its placement in the file.
expected_existing_names is an optional ordered optimistic-
concurrency guard. An empty reference_lines sequence removes all
reference lines associated with storage_area. Returns the backup
path when create_backup is true, otherwise None.
Source code in ras_commander/geom/GeomReferenceFeatures.py
| Python | |
|---|---|
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 | |
get_reference_lines
staticmethod
¶
Read named area-associated lines; reject malformed coordinate blocks.
Source code in ras_commander/geom/GeomReferenceFeatures.py
add_reference_points
staticmethod
¶
Append native Reference Point Name/Position records to geometry.
points contains unique name (at most 40 UTF-8 bytes), finite x and y in project coordinates. Names are preserved without a prefix. Native records are placed before LCMann, after existing reference features. An existing .bak is preserved; validation completes before writing. Returns the number inserted. Duplicate names, invalid fields or coordinates raise ValueError.
Before this fix the method wrote IC Point records. Existing IC Points are preserved and are not converted or returned as native reference points. To migrate, explicitly supply desired names/coordinates to this method. Mesh membership and solver-recorded output require preprocessing and a new computation; a text round trip alone does not establish output validity.
Source code in ras_commander/geom/GeomReferenceFeatures.py
get_reference_points
staticmethod
¶
Read native Reference Point records as name/x/y dictionaries.
IC Point records are separate initial-condition features and are ignored, even when their names start with 'Reference Point'. No inferred conversion occurs. Malformed native records or duplicate names raise ValueError.
Source code in ras_commander/geom/GeomReferenceFeatures.py
Inspect geometry and output settings¶
A class for handling boundary-related data from HEC-RAS HDF files.
This class provides methods to extract and process various boundary elements such as boundary condition lines, breaklines, refinement regions, and reference lines/points from HEC-RAS geometry HDF files.
Methods in this class return data primarily as GeoDataFrames, making it easy to work with spatial data in a geospatial context.
Note
This class relies on the HdfBase and HdfUtils classes for some of its functionality. Ensure these classes are available in the same package.
get_reference_lines
staticmethod
¶
Return the reference lines geometry and attributes.
Parameters¶
hdf_path : Path Path to the HEC-RAS geometry HDF file. mesh_name : Optional[str], optional Name of the mesh to filter by. Default is None.
Returns¶
gpd.GeoDataFrame A GeoDataFrame containing the reference lines. If mesh_name is provided, returns only lines for that mesh.
Source code in ras_commander/hdf/HdfBndry.py
| Python | |
|---|---|
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | |
get_reference_points
staticmethod
¶
Return the reference points geometry and attributes.
Parameters¶
hdf_path : Path Path to the HEC-RAS geometry HDF file. mesh_name : Optional[str], optional Name of the mesh to filter by. Default is None.
Returns¶
gpd.GeoDataFrame A GeoDataFrame containing the reference points. If mesh_name is provided, returns only points for that mesh.
Source code in ras_commander/hdf/HdfBndry.py
| Python | |
|---|---|
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 | |
A class for handling mesh-related operations on HEC-RAS HDF files.
This class provides methods to extract and analyze mesh data from HEC-RAS HDF files, including mesh area names, mesh areas, cell polygons, cell points, cell faces, and 2D flow area attributes.
Methods in this class are designed to work with the mesh geometry data stored in HEC-RAS HDF files, providing functionality to retrieve and process various aspects of the 2D flow areas and their associated mesh structures.
Note: This class relies on HdfBase and HdfUtils for some underlying operations.
get_reference_line_internal_faces
staticmethod
¶
get_reference_line_internal_faces(hdf_path: Path, mesh_name: Optional[str] = None) -> pd.DataFrame
Return internal mesh faces associated with native HEC-RAS reference lines.
Parameters¶
hdf_path : Path Path to the HEC-RAS geometry HDF file. mesh_name : Optional[str], optional If provided, return only reference-line faces for this 2D flow area.
Returns¶
pd.DataFrame
Rows keyed by reference line and face with columns such as
reference_line_id, profile_name, mesh_name, face_id,
fp_start_index, fp_end_index, station_start,
station_end, station_length, face_length, and
station_fraction where source fields are available. Returns an
empty DataFrame when reference lines or internal faces are absent.
station_fraction is the raw HDF-derived fraction and may be
outside [0, 1] for unusual station data; consumers should validate
or clip it before using it as a multiplier.
Source code in ras_commander/hdf/HdfMesh.py
| Python | |
|---|---|
2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 | |
Saved output intervals are distinct from the computation timestep. Updating a plan's settings does not change an existing result HDF: recompute to produce the new output, then inspect the timestamps actually written.
A class for operations on HEC-RAS plan files.
update_plan_intervals
staticmethod
¶
update_plan_intervals(plan_number_or_path: Union[str, Path], computation_interval: Optional[str] = None, output_interval: Optional[str] = None, instantaneous_interval: Optional[str] = None, mapping_interval: Optional[str] = None, ras_object=None, *, validate: bool = True) -> None
Update the computation, output, detailed and mapping intervals in a plan file.
Parameters:
plan_number_or_path (Union[str, Path]): The plan number (1 to 99) or full path to the plan file
computation_interval (Optional[str]): New computation interval. Valid entries are
RasPlan.VALID_PLAN_INTERVALS ('0.1SEC' ... '1SEC' ... '1MIN' ... '1HOUR' ...
'1DAY', '1WEEK', '1MON', '1YEAR').
output_interval (Optional[str]): Hydrograph Output Interval (Output Interval=).
instantaneous_interval (Optional[str]): Detailed Output Interval (Instantaneous Interval=).
mapping_interval (Optional[str]): Mapping Output Interval (Mapping Interval=).
ras_object (RasPrj, optional): Specific RAS object to use. If None, uses the global ras instance.
validate (bool): Keyword-only. Check the relationships described in
validate_plan_intervals against the resulting plan (new values merged
with those already in the file, including values you did not change, plus
the simulation start time). Default True.
Raises: ValueError: If the plan file is not found or if an invalid/inconsistent interval is provided IOError: If there's an error reading or writing the plan file
Notes
Lines that are not intervals are written back untouched (line endings are
normalised to CRLF like every other ras-commander writer). A missing
interval key is inserted after the last existing interval key.
Short output/mapping intervals enlarge the plan HDF; see
set_hdf_compression.
Example:
RasPlan.update_plan_intervals("01", computation_interval="30SEC", output_interval="15MIN", instantaneous_interval="1HOUR", mapping_interval="15MIN")
Source code in ras_commander/RasPlan.py
| Python | |
|---|---|
2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 | |
get_hdf_output_options
staticmethod
¶
get_hdf_output_options(plan_number_or_path: Union[str, Number, Path], ras_object=None) -> Dict[str, Optional[Any]]
Get HDF output options configured in a HEC-RAS plan file.
Alias for get_hdf_write_parameters() using output-control naming.
Source code in ras_commander/RasPlan.py
set_hdf_output_options
staticmethod
¶
set_hdf_output_options(plan_number_or_path: Union[str, Number, Path], write_warmup: Optional[bool] = None, write_time_slices: Optional[bool] = None, hdf_flush: Optional[bool] = None, compression: Optional[int] = None, chunk_size_mb: Optional[int] = None, spatial_parts: Optional[int] = None, use_max_rows: Optional[bool] = None, fixed_rows: Optional[int] = None, ras_object=None) -> bool
Set HDF output options in a HEC-RAS plan file.
Alias for set_hdf_write_parameters() using output-control naming.
Source code in ras_commander/RasPlan.py
apply_hdf_output_profile
staticmethod
¶
apply_hdf_output_profile(plan_number_or_path: Union[str, Number, Path], profile: str = 'balanced', additional_variables: Optional[List[str]] = None, ras_object=None, *, target_ras_version: Optional[Union[str, float, Path]] = None) -> bool
Apply a named HDF write-parameter profile and optional output variables.
All requested labels and version gates are checked before any writes;
see add_hdf_output_variable for normalization and physics limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan_number_or_path
|
Union[str, Number, Path]
|
Plan number or path to the plan file. |
required |
profile
|
str
|
One of |
'balanced'
|
additional_variables
|
Optional[List[str]]
|
Optional additional HDF output variables to enable. |
None
|
ras_object
|
RasPrj
|
Optional RAS project object. If None, uses global |
None
|
target_ras_version
|
str, float, or Path
|
HEC-RAS version
that will run the plan ( |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True when all requested updates succeeded. |
Source code in ras_commander/RasPlan.py
| Python | |
|---|---|
4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 | |