Skip to main content

Read data from HEC-RAS HDF files.

Project description

rashdf

CI Release PyPI version codecov Documentation Status

Read data from HEC-RAS HDF 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.

>>> from rashdf import RasGeomHdf
>>> geom_hdf = RasGeomHdf("path/to/rasmodel/Muncie.g04.hdf")
>>> mesh_cells = geom_hdf.mesh_cell_polygons()  # export a GeoDataFrame
>>> mesh_cells
             mesh_name  cell_id                                           geometry
0     2D Interior Area        0  POLYGON ((406025.000 1805015.237, 406025.000 1...
1     2D Interior Area        1  POLYGON ((406075.000 1805018.545, 406075.000 1...
2     2D Interior Area        2  POLYGON ((406075.000 1804975.000, 406075.000 1...
3     2D Interior Area        3  POLYGON ((406125.000 1804975.000, 406125.000 1...
4     2D Interior Area        4  POLYGON ((406175.000 1804975.000, 406175.000 1...
...                ...      ...                                                ...
5386  2D Interior Area     5386  POLYGON ((409163.402 1802463.621, 409175.000 1...
5387  2D Interior Area     5387  POLYGON ((409160.953 1802374.120, 409125.000 1...
5388  2D Interior Area     5388  POLYGON ((409163.402 1802463.621, 409161.906 1...
5389  2D Interior Area     5389  POLYGON ((409112.480 1802410.114, 409112.046 1...
5390  2D Interior Area     5390  POLYGON ((409112.480 1802410.114, 409063.039 1...
>>> mesh_cells.to_file("mucie-mesh-cell-polygons.shp")

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

>>> from rashdf import RasPlanHdf
>>> with RasPlanHdf("path/to/rasmodel/Muncie.p04.hdf") as plan_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rashdf-0.11.0.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rashdf-0.11.0-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

File details

Details for the file rashdf-0.11.0.tar.gz.

File metadata

  • Download URL: rashdf-0.11.0.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rashdf-0.11.0.tar.gz
Algorithm Hash digest
SHA256 1e3172f425109be5d29bd88659f1eb366d1adecf0be59abcece5445c404c82a4
MD5 2a5feb318f13115f38b42663e374d8f9
BLAKE2b-256 cbb0098d8efc4e621e7db7dcaf0ac2a4cb238b9819c6bb57b47ffd467854c2b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for rashdf-0.11.0.tar.gz:

Publisher: release.yml on fema-ffrd/rashdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rashdf-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: rashdf-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 30.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rashdf-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fede53b411455a32f796c0ff5cc5e6e33731f67e16fb1f2ed93cf2cd64856f9e
MD5 1c921f6d602ae65838cd55f5a06f29c7
BLAKE2b-256 25418ccfd4c07cca44e2233f5437f3819476a939d464241269707c75b5df9c0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rashdf-0.11.0-py3-none-any.whl:

Publisher: release.yml on fema-ffrd/rashdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page