HDF Modules¶
Classes for reading and processing HEC-RAS HDF result files.
Core Classes¶
HdfBase¶
Base functionality for HDF file operations.
get_dataset_info(hdf_path, group_path=None)- Print HDF structureget_attrs(hdf_path, path)- Get attributes at pathget_projection(hdf_path)- Get coordinate systemget_result_unit_metadata(hdf_path, strict=True)- Read normalized unit metadata and source evidence from a standalone plan-result HDFparse_ras_datetime(datetime_str)- Parse HEC-RAS datetime stringparse_ras_datetime_ms(datetime_bytes)- Parse datetime with milliseconds
get_result_unit_metadata() is deliberately a result-HDF fallback. When the
full project is available, use RasPrj.get_project_units() and treat the text
.prj marker as authoritative. The HDF reader never defaults missing metadata
to English units. It raises on missing, unrecognized, geometry-only, or
contradictory metadata unless strict=False, which returns the raw evidence
and an unresolved status for audit workflows.
HdfPlan¶
Plan-level information from HDF files.
get_plan_info(hdf_path)- Get plan metadataget_simulation_times(hdf_path)- Get start/end timesget_plan_parameters(hdf_path)- Get computation parametersget_2d_flow_options(hdf_path)- Get 2D equation set, initial condition time, tolerances, and solver options from computed HDF output
HdfProject¶
Project-wide extent and coordinate-system helpers.
get_project_extent(hdf_path=None, include_1d=True, include_2d=True, include_storage=True, buffer_percent=50.0, buffer_x_percent=None, buffer_y_percent=None, geometry_type="footprint", fill_holes=True, *, geom_path=None, fallback_to_plaintext=True, ras_object=None)- Return a footprint or buffered bounding box and its project-coordinate bounds.get_project_bounds_latlon(hdf_path=None, buffer_percent=50.0, include_1d=True, include_2d=True, include_storage=True, project_crs=None, *, geom_path=None, fallback_to_plaintext=True, ras_object=None)- Return the project bounds in WGS84.export_extent_geojson(hdf_path, output_path, buffer_percent=50.0, *, geom_path=None, fallback_to_plaintext=True, ras_object=None)- Export the project extent as GeoJSON.
Extent extraction prefers usable HDF geometry independently for 1D reaches,
2D flow areas, and storage areas. With the default
fallback_to_plaintext=True, a matching plain-text .g## file supplies only
components unavailable from HDF; a text-only 1D footprint is constructed from
cross-section cut-line endpoints. Set fallback_to_plaintext=False for strict
HDF-only behavior. include_storage=True is also component-aware: HDF storage
polygons are preferred and companion text geometry is used only when needed.
Mesh Operations¶
HdfMesh¶
Mesh geometry data.
get_mesh_area_names(hdf_path)- List 2D flow areasget_mesh_cell_polygons(hdf_path)- Get cell polygons as GeoDataFrameget_mesh_cell_faces(hdf_path)- Get cell face linesget_mesh_cell_points(hdf_path)- Get cell center pointsget_mesh_perimeter(hdf_path)- Get mesh perimeter polygonget_mesh_cell_count(hdf_path)- Get number of cellsget_nearest_cell(hdf_path, point)- Find nearest cell to pointget_nearest_face(hdf_path, point)- Find nearest face to pointget_mesh_face_property_tables(hdf_path)- Read face elevation/area/wetted-perimeter/Manning tables
EXPERIMENTAL — not recommended for production or any other non-experimental use. These direct writes have been tested only with HEC-RAS 7.0 April 2026 in one Windows-preprocess/Linux-solve
*.p##.tmp.hdfworkflow. All other HEC-RAS versions and workflows are untested. They are not general land-cover or geometry-authoring APIs.
The methods require acknowledge_unsupported=True, validate the exact
temporary-result role and schema, retain a unique full-file backup, emit a
runtime warning, and verify readback:
write_linux_tmp_face_property_tables(...)- Replace selected temporary face tablesextend_linux_tmp_face_property_tables(...)- Extend temporary tables and return a structured reporttransform_linux_tmp_face_mannings_n(...)- Transform only the temporary-table Manning columnsample_linux_tmp_face_mannings_n_from_landcover_curves(...)- Apply the documented equal-class land-cover sampling heuristicset_mesh_pinned_attribute(...)- Set informationalPinnedmetadata; this does not protect edits from Windows preprocessing
The former names remain compatibility wrappers through v1.1.x and will not be removed before v1.2.0:
| Compatibility name | Canonical replacement |
|---|---|
set_mesh_face_property_tables() |
write_linux_tmp_face_property_tables() |
extend_face_property_tables() |
extend_linux_tmp_face_property_tables() |
set_face_mannings_n_values() |
transform_linux_tmp_face_mannings_n() |
recompute_face_mannings_n_from_landcover_curves() |
sample_linux_tmp_face_mannings_n_from_landcover_curves() |
pin_property_tables() |
set_mesh_pinned_attribute() |
HdfResultsMesh¶
2D mesh results.
get_mesh_max_ws(hdf_path)- Maximum water surface elevationget_mesh_max_ws_time(hdf_path)- Time of maximum WSEget_mesh_max_depth(hdf_path)- Maximum depth from stored HEC-RASDepthwhen present, otherwise derived in memory fromWater Surface - Cells Minimum Elevationget_mesh_max_face_v(hdf_path)- Maximum face velocityget_mesh_timeseries(hdf_path, mesh, var)- Time series for meshget_mesh_cells_timeseries(hdf_path, mesh, cell_ids, var)- Cell time seriesget_mesh_faces_timeseries(hdf_path, mesh, face_ids, var)- Face time seriesget_profile_line_flow_timeseries(hdf_path, line_name, mesh_name=None, profile_lines_path=None, direction="absolute")- Flow time series across a RAS Mapper profile/reference lineget_profile_line_peak_flow(hdf_path, line_name, mesh_name=None, profile_lines_path=None, direction="absolute")- Peak Q and peak time for a profile/reference line
get_mesh_max_depth() logs one INFO source message per mesh. Stored Depth is
read only. The fallback is computed only in memory and does not create or write
Depth in the HDF. Temporary synthetic test HDFs are test artifacts; they are
not producer output and are labeled separately from pre-existing HEC-RAS result
fixtures.
HdfResultsProducts¶
Inspection and deterministic product contracts for completed unsteady result HDFs.
inspect_result(hdf_path)- Read an existing result HDF without mutation and fail closed on incomplete or conflicting completion evidence, inconsistent time axes, missing CRS or units, and mesh/result/topology misalignmentexport(hdf_path, output_directory, *, resolution=None, max_dimension=2048, nodata=-9999.0, include_preview=True)- Generate a checksum-pinned hydraulic product package without modifying the producer HDF
Current HEC-RAS results can establish completion with
Event Conditions/Completed Successfully=True. Older producer HDFs that do
not contain that attribute can establish completion with their embedded
Complete Process compute-message marker. An explicit false or malformed
attribute is never overridden by messages.
The returned inspection identifies whether maximum depth will be read from the
stored HEC-RAS Depth time series or derived in memory from Water Surface -
Cells Minimum Elevation. It also records hydraulic_qaqc: not_evaluated:
mechanical completion and product readiness are not engineering acceptance.
from ras_commander import HdfResultsProducts
inspection = HdfResultsProducts.inspect_result("project.p02.hdf")
manifest = HdfResultsProducts.export(
"project.p02.hdf",
"project-p02-hydraulic-products",
)
export() supports completed unsteady HDFs with 2D flow areas. It writes a
common-grid trio of Cloud Optimized GeoTIFFs for maximum WSE, maximum depth, and
maximum adjacent-face velocity; a fixed-schema Arrow/Parquet boundary
hydrograph table; result metadata; numerical evidence; a WGS84 GeoJSON
footprint; and, by default, a depth preview. pyarrow>=14.0 is a required core
dependency because Arrow and Parquet are part of the modern geospatial product
contract, not an optional fallback.
Raster dimensions are bounded twice: neither width nor height may exceed
max_dimension, and the total raster contains at most 16,777,216 cells. The
nodata argument is normalized to float32 before collision checks so a nearby
double-precision value cannot silently become equal to valid stored data.
Pixels are square at the exact selected resolution; when a footprint span is
not evenly divisible, raster bounds expand by less than one pixel on the right
or bottom rather than silently changing the requested cell size.
The source HDF is opened read-only and protected by point-in-time digest checks.
The files in the output directory are newly generated ras-commander derivative
artifacts; they are not newly generated HEC-RAS model output. The output
directory must not already exist. Assets are published without overwriting and
hydraulic-products.json is linked last, so consumers must use that manifest as
the package-complete marker. A package that lacks the manifest is incomplete.
Publication requires same-filesystem hard-link support and fails closed when
the destination filesystem cannot provide it.
The exporter preserves valid negative-datum WSE and uses 2D flow-area
footprints as raster support. It does not infer hydraulic acceptability:
numerical-qaqc.json preserves evidence while the manifest remains
hydraulic_qaqc: not_evaluated. A result with no boundary-condition series gets
a valid, empty Parquet table with the same schema rather than losing the asset.
Synthetic HDFs created by focused tests are labeled test artifacts. Real-file integration uses pre-existing producer HDFs read-only and does not run HEC-RAS or generate model output; it generates only temporary derivative packages.
Plan Results¶
HdfResultsPlan¶
Plan-level results.
get_runtime_data(hdf_path)- Runtime statisticsget_volume_accounting(hdf_path)- Volume accounting dataget_compute_messages(hdf_path)- Computation messagesget_compute_options(hdf_path)- Computation options usedis_steady_plan(hdf_path)- Check if steady stateget_steady_profile_names(hdf_path)- Get steady profile namesget_steady_wse(hdf_path)- Get steady water surface elevationsget_steady_info(hdf_path)- Get steady flow metadata
HdfResultsXsec¶
1D cross-section results.
get_xsec_timeseries(hdf_path)- All cross-section time seriesget_xsec_summary(hdf_path)- Cross-section summary data
1D Geometry¶
HdfXsec¶
Cross-section and river geometry extraction from HDF.
get_cross_sections(hdf_path, ras_object=None)- Extract cross-section geometries as a GeoDataFrame. Accepts a geometry HDF path or a plan selector; multipart cut lines are returned asMultiLineStringwithout synthetic connectors.get_xs_coords(hdf_path, river=None, reach=None, rs=None)- Extract native station/elevation points as XYZ with point/station order, cut-line distance, Manning's n, bank classification, coordinate metadata, and source provenanceget_river_centerlines(hdf_path)- Extract river centerlines asLineStringorMultiLineStringgeometriesget_river_stationing(hdf_path)- Calculate river stationing along centerlinesget_river_reaches(hdf_path)- Return model 1D river reach lines with stableriver_idand computedlengthcolumnsget_river_edge_lines(hdf_path)- Return river edge linesget_river_bank_lines(hdf_path)- Extract river bank lines
Structure Data¶
HdfStruc¶
Structure geometry and SA/2D connections.
get_connection_list(hdf_path)- List SA/2D connectionsget_connection_profile(hdf_path, name)- Get connection profileget_connection_gates(hdf_path, name)- Get gate dataget_storage_area_polygons(hdf_path, *, ras_object=None)- Extract storage area polygons and attributes from geometry or plan HDF files, including multi-ring polygons with interior rings; returns an empty GeoDataFrame when no storage areas are present.
HdfResultsBreach¶
Dam breach results.
get_breach_timeseries(hdf_path, structure)- Breach time seriesget_breach_summary(hdf_path, structure)- Breach summary statisticsget_breaching_variables(hdf_path, structure)- Breach geometry evolutionget_structure_variables(hdf_path, structure)- Structure flow variables
HdfStorageArea¶
Storage area volume-elevation curve extraction from HDF.
get_volume_elevation_curve(hdf_path, sa_name)- Get volume-elevation curve for a storage areaget_storage_area_names(hdf_path)- List storage areas in HDF
HdfChannelCapacity¶
1D channel capacity analysis (multi-AEP).
get_channel_capacity(hdf_path, river=None, reach=None)- Compute channel capacity from cross-section geometry and resultsget_multi_aep_capacity(hdf_paths, aep_labels)- Compare capacity across multiple AEP simulations
HdfStruc1D¶
1D structure result extraction from plan HDF results.
get_structure_max_values(hdf_path, river, reach, rs)- Extract maximum headwater, tailwater, and flow for a bridge, culvert, inline weir, or inline control structure. Raises an actionableValueErrorwhen the plan HDF has no steady/unsteady results, required cross-section result datasets are absent, or the requested structure is not present in the results.list_1d_structures(hdf_path)- List 1D structures identified from result markers. Returns an empty DataFrame quietly when no structures are present in an otherwise readable HDF.
For steady plans, get_structure_max_values() can use the flanking cross sections when the structure is represented in HDF Node Info instead of Cross Section Attributes. The returned hw_source, tw_source, and flow_source fields identify the result locations used.
HdfHydraulicTables¶
Cross section property tables (HTAB).
get_xs_htab(hdf_path, river, reach, station)- Get HTAB data
Infrastructure¶
HdfPipe¶
Pipe network analysis.
get_pipe_conduits(hdf_path)- Get conduit geometryget_pipe_nodes(hdf_path)- Get node locationsget_pipe_network_timeseries(hdf_path, var)- Network time seriesget_pipe_network_summary(hdf_path)- Network summaryget_pipe_profile(hdf_path, conduit_id)- Get conduit profile
HdfPump¶
Pump station analysis.
get_pump_stations(hdf_path)- Get station locationsget_pump_groups(hdf_path)- Get pump groupsget_pump_station_timeseries(hdf_path, name)- Station time seriesget_pump_station_summary(hdf_path)- Station summaryget_pump_operation_timeseries(hdf_path, name)- Operation history
Analysis¶
HdfFluvialPluvial¶
Fluvial-pluvial boundary analysis.
calculate_fluvial_pluvial_boundary(hdf_path, delta_t)- Calculate boundary
HdfInfiltration¶
Native infiltration authoring and read-only inspection.
Geometry File Operations:
get_preprocessed_infiltration(hdf_path, mesh_name=None, variable=...)- Read solver-owned per-cell infiltration arraysget_infiltration_baseoverrides(hdf_path)- Retrieve the geometry-wide class-to-parameter fallback tableget_infiltration_calibration_regions(hdf_path)- Read every region table in the bulk variable-oriented HDF viewget_infiltration_region_overrides(hdf_path, region_name=..., hecras_version=...)- Read one selected region in the class-ordered native viewget_infiltration_region_names(hdf_path)- Read stable region namesget_infiltration_region_polygons(hdf_path)- Read stable region IDs, names, and polygon geometrycreate_infiltration_override_regions(hdf_path, region_names, hecras_version=...)- Create native geometry override regions from existing Manning-region polygonsset_infiltration_base_overrides(hdf_path, data, hecras_version=...)- Set the native geometry-wide Base Overrides fallbackscale_infiltration_base_overrides(hdf_path, data, scale_factors, hecras_version=...)- Scale active geometry-wide Base Overrides while preserving sentinel valuesset_infiltration_region_overrides(hdf_path, data, region_name=..., hecras_version=...)- Set one native region's parameter table without changing Base Overrides or other regionsscale_infiltration_region_overrides(hdf_path, data, scale_factors, region_name=..., hecras_version=...)- Scale one selected region while preserving sentinel values
Raster and Layer Operations:
get_infiltration_layer_data(hdf_path)- Get infiltration layer data from HDFset_infiltration_sidecar_parameters(hdf_path, data, hecras_version=...)- Set sidecar parameters through native RASMapper serializationscale_infiltration_sidecar_parameters(hdf_path, data, scale_factors, hecras_version=...)- Scale and save sidecar parameters nativelyget_classification_polygons(hdf_path)- Read infiltration sidecar classification polygon overridesget_infiltration_map(hdf_path=None, ras_object=None)- Read the infiltration raster map; without an explicit path, resolve the first usablerasmap_df["infiltration_hdf_path"]calculate_soil_statistics(hdf_path)- Process zonal statistics for soil analysisget_soils_raster_stats(geom_hdf_path, soil_hdf_path=None, ras_object=None)- Resolve the soil sidecar consistently; lookup failures retain the empty-frame recovery contractget_soil_raster_stats(...),get_infiltration_stats(...), andget_landcover_raster_stats(...)- Use the same status-aware sidecar resolver and empty-frame recovery contract
The compatibility names create_infiltration_group(),
set_infiltration_baseoverrides(), set_infiltration_layer_data(), and
scale_infiltration_baseoverrides() delegate to the canonical native APIs
through the v1.1.x compatibility window. The historical
scale_infiltration_data() name was ambiguous between a geometry HDF and an
infiltration sidecar and now fails closed with three explicit choices: the
geometry-wide, selected-region, or sidecar scaler.
These compatibility names will not be removed before v1.2.0.
Ras Commander never hand-authors or selectively deletes
/Geometry/Infiltration datasets.
Soil Analysis:
get_significant_mukeys(hdf_path, threshold)- Identify mukeys above percentage thresholdcalculate_total_significant_percentage(hdf_path)- Compute total coverageget_infiltration_parameters(hdf_path=None, mukey=None, ras_object=None)- Get parameters for a specific mukey, with the same optionalrasmap_dflookupcalculate_weighted_parameters(hdf_path)- Compute weighted average parameters
Data Export:
save_statistics(data, path)- Export soil statistics to CSV
HdfLandCover¶
Land-cover sidecar and final Manning's n extraction.
get_landcover_raster_map(hdf_path)- Read land-cover class IDs, names, and Manning's n valuesset_landcover_mannings_n(hdf_path, mapping, hecras_version=...)- Set sidecar Manning's n through native RASMapper serializationget_classification_polygons(hdf_path)- Read land-cover sidecar classification polygon overridesget_preprocessed_mannings_n(hdf_path)- Read preprocessed cell-center Manning's n values from geometry HDFaudit_final_mannings_n(hdf_path, ...)- Strictly audit solver-owned final cell/face Manning arraysestimate_final_mannings_raster(hdf_path, ...)- Build a non-authoritative visualization estimate
Compatibility mappings are retained through v1.1.x and will not be removed before v1.2.0:
| Compatibility name | Canonical replacement |
|---|---|
set_landcover_raster_map() |
set_landcover_mannings_n() |
compute_final_mannings_raster() |
estimate_final_mannings_raster() for visualization, or audit_final_mannings_n() for solver evidence |
HdfBndry¶
Boundary condition geometry.
get_bc_lines(hdf_path)- Get BC linesget_breaklines(hdf_path)- Get breaklines
Utilities¶
HdfUtils¶
Utility class for HDF file operations.
Data Conversion:
convert_ras_string(value)- Convert RAS HDF strings to Python objectsconvert_ras_hdf_value(value)- Convert general HDF values to Python objectsconvert_df_datetimes_to_str(df)- Convert DataFrame datetime columns to stringsconvert_hdf5_attrs_to_dict(attrs)- Convert HDF5 attributes to dictionaryconvert_timesteps_to_datetimes(timesteps)- Convert timesteps to datetime objects
Spatial Operations:
perform_kdtree_query(source, target)- KDTree search between datasetsfind_nearest_neighbors(data, k)- Find nearest neighbors within dataset
DateTime Parsing:
parse_ras_datetime(datetime_str)- Parse RAS datetime (ddMMMYYYY HH:MM:SS)parse_ras_window_datetime(datetime_str)- Parse simulation window datetimeparse_duration(duration_str)- Parse duration strings (HH:MM:SS)parse_ras_datetime_ms(datetime_bytes)- Parse datetime with millisecondsparse_run_time_window(window_str)- Parse time window strings
Visualization¶
HdfPlot & HdfResultsPlot¶
Basic plotting utilities.
plot_results_max_wsel(gdf)- Plot maximum WSE map
Usage Example¶
from ras_commander import HdfResultsMesh, HdfResultsPlan, init_ras_project
init_ras_project("/path/to/project", "6.5")
# Get HDF path
hdf_path = ras.plan_df.loc[ras.plan_df['plan_number'] == '01', 'hdf_path'].iloc[0]
# Extract max WSE
max_wse = HdfResultsMesh.get_mesh_max_ws(hdf_path)
# Get runtime stats
runtime = HdfResultsPlan.get_runtime_data(hdf_path)