Skip to content

Repository files navigation

rashdf

CIReleasePyPI versioncodecovDocumentation Status

Read data from HEC-RASHDF files.

Pronunciation: raz·aitch·dee·eff

Documentation

rashdf on ReadTheDocs

Install

$ pip install rashdf

Usage

RasGeomHdf and RasPlanHdf are extensions of h5py.File. They contain methods to export HEC-RAS model geometry as GeoDataFrame objects.

>>>fromrashdfimportRasGeomHdf>>>geom_hdf=RasGeomHdf("path/to/rasmodel/Muncie.g04.hdf")
>>>mesh_cells=geom_hdf.mesh_cell_polygons() # export a GeoDataFrame>>>mesh_cellsmesh_namecell_idgeometry02DInteriorArea0POLYGON ((406025.0001805015.237, 406025.0001...
12DInteriorArea1POLYGON ((406075.0001805018.545, 406075.0001...
22DInteriorArea2POLYGON ((406075.0001804975.000, 406075.0001...
32DInteriorArea3POLYGON ((406125.0001804975.000, 406125.0001...
42DInteriorArea4POLYGON ((406175.0001804975.000, 406175.0001...
... ... ... ...
53862DInteriorArea5386POLYGON ((409163.4021802463.621, 409175.0001...
53872DInteriorArea5387POLYGON ((409160.9531802374.120, 409125.0001...
53882DInteriorArea5388POLYGON ((409163.4021802463.621, 409161.9061...
53892DInteriorArea5389POLYGON ((409112.4801802410.114, 409112.0461...
53902DInteriorArea5390POLYGON ((409112.4801802410.114, 409063.0391...
>>>mesh_cells.to_file("mucie-mesh-cell-polygons.shp")

Also, methods to extract certain HDF group attributes as dictionaries:

>>>fromrashdfimportRasPlanHdf>>>withRasPlanHdf("path/to/rasmodel/Muncie.p04.hdf") asplan_hdf:
>>>results_unsteady_summary_attrs=plan_hdf.get_results_unsteady_summary_attrs()
>>>results_unsteady_summary_attrs
{'Computation Time DSS': datetime.timedelta(0),
'Computation Time Total': datetime.timedelta(seconds=23),
'Maximum WSEL Error': 0.0099277812987566,
'Maximum number of cores': 6,
'Run Time Window': [datetime.datetime(2024, 3, 27, 9, 31, 52),
datetime.datetime(2024, 3, 27, 9, 32, 15)],
'Solution': 'Unsteady Finished Successfully',
'Time Solution Went Unstable': None,
'Time Stamp Solution Went Unstable': 'Not Applicable'}

CLI

The rashdf command-line interface allows export directly to a variety of formats, enabled by GeoPandas.

$ rashdf <sub-command> <hdf-file> [<output-path>] [<options>]

CLI help:

$ rashdf --help

Print the output formats supported by pyorgio:

$ rashdf --pyogrio-drivers

Help for a specific subcommand:

$ rashdf mesh_cell_polygons --help

Example: export mesh cell faces to an ESRI Shapefile

$ rashdf mesh_cell_faces BigRiver.g01.hdf big-river-mesh-cell-faces.shp

Example: export mesh cell points to GeoParquet

$ rashdf mesh_cell_points LittleCreek.g01.hdf --parquet little-creek-mesh-cell-points.parquet

Example: export breaklines to OGC GeoPackage and reproject to a different CRS

$ rashdf breaklines Whitemarsh.p01.hdf whitemarsh-breaklines.gpkg --to-crs EPSG:4326

Example: write structures GeoJSON to stdout:

$ rashdf structures Potomac.p01.hdf

Developer Setup

Create a virtual environment in the project directory:

$ python -m venv venv-rashdf

Activate the virtual environment:

# For macOS/Linux
$ source ./venv-rashdf/bin/activate
(venv-rashdf) $
# For Windows
> ./venv-rashdf/Scripts/activate

Install dev dependencies:

(venv-rashdf) $ pip install ".[dev]"

Install git hook scripts (used for automatic liniting/formatting)

(venv-rashdf) $ pre-commit install

With the virtual environment activated, run the tests:

(venv-rashdf) $ pytest

About

Read data from HEC-RAS HDF files.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages