Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference Lines, Reference Points + Summary Output, Timeseries Output #56

Merged
merged 10 commits into from
Jul 13, 2024

Conversation

thwllms
Copy link
Contributor

@thwllms thwllms commented Jun 17, 2024

  • Two new methods on RasGeomHdf:
    • reference_lines
    • reference_points
  • Include summary output data when reference lines/points are extracted via RasPlanHdf
  • Ability to extract timeseries output for reference lines / points as xarray Dataset:
    • RasPlanHdf.reference_lines_timeseries_output
    • RasPlanHdf.reference_points_timeseries_output
  • EDIT (7/2): reduces duplicate code by adding RasGeomHdf._get_polylines method to extract generic polyline geometry from the RAS HDF format. This is now used to extract geometry for reference lines, cross-sections, river reaches, and structures.

Example usage

Reference Lines/Points Names, Geometry

>>> from src.rashdf import RasGeomHdf, RasPlanHdf
>>> geom_hdf = RasGeomHdf("tests/data/ras/BaldEagleDamBrk.reflines-refpts.p18.hdf")
>>> geom_hdf.reference_points_names()
{'BaldEagleCr': ['Reference Point 2', 'Reference Point 3'], 'Upper 2D Area': ['Reference Point 1']}
>>> geom_hdf.reference_lines_names()
{'BaldEagleCr': ['Reference Line 1', 'Reference Line 2', 'Reference Line 3', 'Reference Line 4']}
>>> geom_hdf.reference_lines()
   refln_id        refln_name    mesh_name type                                           geometry
0         0  Reference Line 1  BaldEagleCr       LINESTRING (2010642.393 326795.304, 2012237.43...
1         1  Reference Line 2  BaldEagleCr       LINESTRING (2022720.029 334741.179, 2024381.11...
2         2  Reference Line 3  BaldEagleCr       LINESTRING (2069088.716 361473.929, 2073894.93...
3         3  Reference Line 4  BaldEagleCr       LINESTRING (2051470.370 349841.273, 2053372.10...
>>> geom_hdf.reference_points()
   refpt_id         refpt_name      mesh_name  cell_id                        geometry
0         0  Reference Point 1  Upper 2D Area       73  POINT (2006481.919 320490.113)
1         1  Reference Point 2    BaldEagleCr     3096  POINT (2011285.989 325294.328)
2         2  Reference Point 3    BaldEagleCr     1540  POINT (2041201.376 348238.471)

Summary output data

>>> plan_hdf = RasPlanHdf("tests/data/ras/BaldEagleDamBrk.reflines-refpts.p18.hdf")
>>> plan_hdf.reference_lines()
   refln_id        refln_name    mesh_name type                                           geometry         max_q          max_q_time  min_q          min_q_time      max_ws         max_ws_time      min_ws         min_ws_time
0         0  Reference Line 1  BaldEagleCr       LINESTRING (2010642.393 326795.304, 2012237.43...  95974.476562 1999-01-03 12:00:00    0.0 1999-01-01 12:00:00  599.296143 1999-01-03 12:00:00  576.704163 1999-01-01 12:00:00
1         1  Reference Line 2  BaldEagleCr       LINESTRING (2022720.029 334741.179, 2024381.11...  95644.906250 1999-01-03 12:00:00    0.0 1999-01-01 12:00:00  586.797913 1999-01-03 14:00:00  562.536316 1999-01-01 12:00:00
2         2  Reference Line 3  BaldEagleCr       LINESTRING (2069088.716 361473.929, 2073894.93...  92195.210938 1999-01-03 20:00:00    0.0 1999-01-01 12:00:00  552.891785 1999-01-03 22:00:00  527.840515 1999-01-01 12:00:00
3         3  Reference Line 4  BaldEagleCr       LINESTRING (2051470.370 349841.273, 2053372.10...  95034.984375 1999-01-03 16:00:00    0.0 1999-01-01 12:00:00  565.071350 1999-01-03 16:00:00  533.431396 1999-01-01 12:00:00
>>> plan_hdf.reference_points()
   refpt_id         refpt_name      mesh_name  cell_id                        geometry      max_ws         max_ws_time      min_ws         min_ws_time     max_v          max_v_time   min_v          min_v_time
0         0  Reference Point 1  Upper 2D Area       73  POINT (2006481.919 320490.113)  669.060791 1999-01-03 12:00:00  629.876831 1999-01-01 14:00:00  0.039321 1999-01-03 10:00:00  0.0111 1999-01-01 12:00:00
1         1  Reference Point 2    BaldEagleCr     3096  POINT (2011285.989 325294.328)  599.751038 1999-01-03 12:00:00  576.738037 1999-01-01 12:00:00  6.779099 1999-01-03 12:00:00  0.0000 1999-01-01 12:00:00
2         2  Reference Point 3    BaldEagleCr     1540  POINT (2041201.376 348238.471)  575.113708 1999-01-03 16:00:00  548.578491 1999-01-01 12:00:00  2.152658 1999-01-03 00:00:00  0.0000 1999-01-01 12:00:00

Timeseries output data

>>> plan_hdf.reference_lines_timeseries_output()
<xarray.Dataset> Size: 2kB
Dimensions:        (time: 37, refln_id: 4)
Coordinates:
  * time           (time) datetime64[ns] 296B 1999-01-01T12:00:00 ... 1999-01...
  * refln_id       (refln_id) int64 32B 0 1 2 3
    refln_name     (refln_id) <U16 256B 'Reference Line 1' ... 'Reference Lin...
    mesh_name      (refln_id) <U11 176B 'BaldEagleCr' ... 'BaldEagleCr'
Data variables:
    Flow           (time, refln_id) float32 592B 0.0 0.0 ... 7.751e+04 7.359e+04
    Water Surface  (time, refln_id) float32 592B 576.7 562.5 ... 551.5 564.1
>>> plan_hdf.reference_points_timeseries_output()
<xarray.Dataset> Size: 2kB
Dimensions:        (time: 37, refpt_id: 3)
Coordinates:
  * time           (time) datetime64[ns] 296B 1999-01-01T12:00:00 ... 1999-01...
  * refpt_id       (refpt_id) int64 24B 0 1 2
    refpt_name     (refpt_id) <U17 204B 'Reference Point 1' ... 'Reference Po...
    mesh_name      (refpt_id) <U13 156B 'Upper 2D Area' ... 'BaldEagleCr'
Data variables:
    Velocity       (time, refpt_id) float32 444B 0.0111 0.0 0.0 ... 5.812 0.826
    Water Surface  (time, refpt_id) float32 444B 630.0 576.7 ... 597.4 572.6

reference points geom

reflines, refpoints output

tests for reflines, refpoints
Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 13 lines in your changes missing coverage. Please review.

Files Coverage Δ
src/cli.py 88.31% <ø> (ø)
src/rashdf/plan.py 97.67% <92.40%> (-1.36%) ⬇️
src/rashdf/geom.py 88.57% <92.22%> (+4.05%) ⬆️

@thwllms thwllms requested a review from wolfpack-daragon July 9, 2024 18:56
@thwllms thwllms mentioned this pull request Jul 11, 2024
Copy link

@wolfpack-daragon wolfpack-daragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thomas and team, nice work. First time I've interacted with the code, but it's easy to use both in python and the CLI. It seems the new functionality isn't added to the CLI yet though? I didn't check the timseries stuff yet, fyi but approving assuming you've qc'd on your side. Note that the readme on main has some deprecated methods illustrated, I think.

@thwllms thwllms merged commit ac4b788 into main Jul 13, 2024
5 checks passed
@thwllms thwllms deleted the feature/reference-lines-points branch July 13, 2024 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants