fema-ffrd / rashdf

Read data from HEC-RAS HDF files.
MIT License
8 stars 1 forks source link

Extract 2D Summary Output Data #52

Closed thwllms closed 5 months ago

thwllms commented 5 months ago

Closes: #37, #38, #39, #40

Example Usage

API

>>> from rashdf import RasPlanHdf, SummaryOutputVar
>>> plan_hdf = RasPlanHdf("tests/data/ras/BaldEagleDamBrk.p18.hdf")
>>> plan_hdf.mesh_max_ws()
          mesh_name  cell_id      max_ws         max_ws_time
0       BaldEagleCr        0  658.762207 1999-01-01 12:00:00
1       BaldEagleCr        1  648.673340 1999-01-01 12:00:00
2       BaldEagleCr        2  609.591919 1999-01-01 12:00:00
3       BaldEagleCr        3  622.499756 1999-01-01 12:00:00
4       BaldEagleCr        4  639.792175 1999-01-01 12:00:00
...             ...      ...         ...                 ...
4420  Upper 2D Area     1061  725.042358 1999-01-01 12:00:00
4421  Upper 2D Area     1062  694.854187 1999-01-01 12:00:00
4422  Upper 2D Area     1063  680.246826 1999-01-03 05:30:00
4423  Upper 2D Area     1064  680.081848 1999-01-03 05:32:00
4424  Upper 2D Area     1065  712.027466 1999-01-01 12:00:00

[4425 rows x 4 columns]
>>> plan_hdf.mesh_last_iter()
          mesh_name  cell_id  last_iter
0       BaldEagleCr        0          0
1       BaldEagleCr        1          0
2       BaldEagleCr        2          0
3       BaldEagleCr        3          0
4       BaldEagleCr        4          0
...             ...      ...        ...
4420  Upper 2D Area     1061          0
4421  Upper 2D Area     1062          0
4422  Upper 2D Area     1063         26
4423  Upper 2D Area     1064         11
4424  Upper 2D Area     1065          0
>>> # provide a list of outputs to include in the GeoDataFrame
>>> plan_hdf.mesh_cell_points(include_output=["Maximum Water Surface", SummaryOutputVar.CELL_MAXIMUM_WATER_SURFACE_ERROR])
          mesh_name  cell_id                        geometry      max_ws         max_ws_time  max_ws_err     max_ws_err_time
0       BaldEagleCr        0  POINT (2083680.700 370757.583)  658.762207 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
1       BaldEagleCr        1  POINT (2084180.700 370757.583)  648.673340 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
2       BaldEagleCr        2  POINT (2080680.700 370257.583)  609.591919 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
3       BaldEagleCr        3  POINT (2081180.700 370257.583)  622.499756 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
4       BaldEagleCr        4  POINT (2081680.700 370257.583)  639.792175 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
...             ...      ...                             ...         ...                 ...         ...                 ...
4420  Upper 2D Area     1061  POINT (1969828.738 290877.786)  725.042358 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
4421  Upper 2D Area     1062  POINT (1970328.738 290877.786)  694.854187 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00
4422  Upper 2D Area     1063  POINT (1968828.738 290377.786)  680.246826 1999-01-03 05:30:00    0.008994 1999-01-01 15:47:00
4423  Upper 2D Area     1064  POINT (1969328.738 290377.786)  680.081848 1999-01-03 05:32:00    0.009122 1999-01-01 15:47:00
4424  Upper 2D Area     1065  POINT (1969828.738 290377.786)  712.027466 1999-01-01 12:00:00    0.000000 1999-01-01 12:00:00

[4425 rows x 7 columns]
>>> # if "include_output" is True (default), return a GeoDataFrame with all available extractable summary output data
>>> plan_hdf.mesh_cell_faces()
          mesh_name  face_id                                           geometry  max_v          max_v_time  min_v          min_v_time
0       BaldEagleCr        0  LINESTRING (2065761.791 364007.583, 2066430.70...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
1       BaldEagleCr        1  LINESTRING (2066430.700 364007.583, 2066430.70...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
2       BaldEagleCr        2  LINESTRING (2066430.700 364695.876, 2066419.85...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
3       BaldEagleCr        3  LINESTRING (2047430.700 362507.583, 2047631.91...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
4       BaldEagleCr        4  LINESTRING (2047631.916 362708.798, 2047460.00...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
...             ...      ...                                                ...    ...                 ...    ...                 ...
9576  Upper 2D Area     2281  LINESTRING (1969578.738 289639.123, 1969608.17...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
9577  Upper 2D Area     2282  LINESTRING (2002308.817 323619.882, 2002136.09...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
9578  Upper 2D Area     2283  LINESTRING (2008279.679 319853.804, 2007812.00...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
9579  Upper 2D Area     2284  LINESTRING (1995261.183 317513.689, 1995038.21...    0.0 1999-01-01 12:00:00    0.0 1999-01-01 12:00:20
9580  Upper 2D Area     2285  LINESTRING (1966078.738 291981.202, 1966868.69...    0.0 1999-01-01 12:00:00   -0.0 1999-01-01 12:00:20

[9581 rows x 7 columns]

CLI

python src/cli.py mesh_cell_polygons ./tests/data/ras/BaldEagleDamBrk.p18.hdf \
  bald-eagle-mesh-cell-polygons.parquet --parquet
codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 99.39394% with 1 line in your changes missing coverage. Please review.

Files Coverage Δ
src/rashdf/geom.py 81.05% <100.00%> (ø)
src/rashdf/plan.py 99.43% <100.00%> (+3.27%) :arrow_up:
src/rashdf/utils.py 90.10% <100.00%> (+0.22%) :arrow_up:
src/cli.py 88.31% <87.50%> (+0.64%) :arrow_up:
thwllms commented 5 months ago

@sray014 @zherbz @slawler this is a pretty large PR and @bates-j is out on leave for a while. Figured we'd have a better chance of keeping stuff moving into main if I tagged 3 people for potential review instead of 2.