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

[21pt] src/hydrotable_flood_extent_polygons.py: Generate flood extent polygo… #941

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

hohe12ly
Copy link

Generate flood extent polygons for the synthetic river rating curve (hydroTable).

A python script is coded to implement a requested feature for generating flood extent polygon for each HydroID and each stage height in the hydroTable.csv. Instead of adding a WKT column to existing hydroTable, which would make hydroTable.csv big and less readable, the output is a GeoPackage file with attributes: HydroID, feature_id, stage, and stage_index (0-83). The usage of the script is documented in the python code.

Additions

src/hydrotable_flood_extent_polygons.py is added to implement this feature. It's a standalone python script and can be used as a bash command. Code is modularized into 3 python functions for further integration into FIM4 framework.

Testing

The performance of this script was tested on HUC8 12090205. Here is the overall performance in terms of computing time for each stage height. On average, each stage height takes about 1 minute to compute using 8 CPU cores.

image

The breakdowns of each component in the code is shown below. Note that polygonization is the most time-consuming step, consistently taking ~30 seconds:

image

…ns for the synthetic river rating curve (hydroTable)
@RobHanna-NOAA
Copy link
Contributor

Hi folks. In consistency with our new FIM patterns for .py files, we are now slowly changing our files to move any logic from "main" into a new function that can serve as an entry point.

Why? If you run this command from command line, the logic in "main" will execute, but what happens if this get linked up with another .py file. That other .py file would not be calling "main" and will miss critical logic. I can change this for Dr. Liu before we approve it. As we attempt to move away from bash, this new code pattern will become critical. :)

@RobHanna-NOAA RobHanna-NOAA added enhancement New feature or request FIM4 labels Jul 10, 2023
@RobHanna-NOAA RobHanna-NOAA changed the title src/hydrotable_flood_extent_polygons.py: Generate flood extent polygo… [21pt] src/hydrotable_flood_extent_polygons.py: Generate flood extent polygo… Jul 10, 2023
@hohe12ly
Copy link
Author

Hi folks. In consistency with our new FIM patterns for .py files, we are now slowly changing our files to move any logic from "main" into a new function that can serve as an entry point.

Why? If you run this command from command line, the logic in "main" will execute, but what happens if this get linked up with another .py file. That other .py file would not be calling "main" and will miss critical logic. I can change this for Dr. Liu before we approve it. As we attempt to move away from bash, this new code pattern will become critical. :)

Hi Rob,

Please feel free to refactor the code as you want to conform to the FIM patterns. The code has 3 functions and a main that can be easily wrapped into another function to stay away from being a standalone python application.

Thanks,
Yan

@RobHanna-NOAA
Copy link
Contributor

RobHanna-NOAA commented Jul 12, 2023 via email

@RobHanna-NOAA RobHanna-NOAA requested review from mluck and removed request for BradfordBates-NOAA and RobHanna-NOAA October 11, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request FIM4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants