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

[1pt] PR: Update benchmark flows in AHPS domain #1094

Merged
merged 16 commits into from
May 17, 2024

Conversation

mluck
Copy link
Contributor

@mluck mluck commented Mar 14, 2024

Extends flows (i.e., discharge) to stream segments missing from NWS or USGS validation flow files. The levelpath associated with existing flows in the AHPS domain is identified, and any stream segments of the levelpath in the domain missing from the flow file are added to the flow file by assigning the existing flow (this is a constant value regardless of other tributaries including other levelpaths in the domain).

Closes #1089 and closes #1092.

Additions

  • data/extend_benchmark_flows.py: Adds missing flows to NWS or USGS benchmark flow files. The original flow file is saved with an appended .bak.

Changes

  • tools/tools_shared_variables.py: Removed corrected flow files from BAD_SITES list.

Testing

Verified that the new flow files contain the added feature_id/discharge values from missing stream segments. Also ran synthesize_test_cases.py to generate inundation agreement rasters.

Example results from sweg1 (HUC8 03130001, major flow category)

Flow file (added segments in red)
image
Inundation agreement raster (before/after)
image

Issuer Checklist (For developer use)

You may update this checklist before and/or after creating the PR. If you're unsure about any of them, please ask, we're here to help! These items are what we are going to look for before merging your code.

  • Informative and human-readable title, using the format: [_pt] PR: <description>
  • Links are provided if this PR resolves an issue, or depends on another other PR
  • If submitting a PR to the dev branch (the default branch), you have a descriptive Feature Branch name using the format: dev-<description-of-change> (e.g. dev-revise-levee-masking)
  • Changes are limited to a single goal (no scope creep)
  • The feature branch you're submitting as a PR is up to date (merged) with the latest dev branch
  • pre-commit hooks were run locally
  • Any change in functionality is tested
  • Passes all unit tests locally (inside interactive Docker container, at /foss_fim/, run: pytest unit_tests/)
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • CHANGELOG updated with template version number, e.g. 4.x.x.x
  • Reviewers requested
  • Add yourself as an assignee in the PR as well as the FIM Technical Lead

Merge Checklist (For Technical Lead use only)

  • Update CHANGELOG with latest version number and merge date
  • Update the Citation.cff file to reflect the latest version number in the CHANGELOG
  • If applicable, update README with major alterations

@mluck mluck added bug Something isn't working testing Evaluation and testing related labels Mar 14, 2024
@mluck mluck linked an issue Mar 14, 2024 that may be closed by this pull request
@mluck
Copy link
Contributor Author

mluck commented Mar 21, 2024

Since the AHPS benchmark flows seem to be (always?) constant within a flow file and there are other sites that seem to be missing flows in the domain (e.g., chin7), what about applying this to all of the AHPS benchmark flows rather than just the ones in the BAD_SITES list?

@CarsonPruitt-NOAA
Copy link
Collaborator

That makes sense to me.

@CarsonPruitt-NOAA
Copy link
Collaborator

@mluck Can you add cart2 to the BAD_SITES list? @derekgiardino has identified this a site on which we shouldn't be doing evaluations.

@mluck
Copy link
Contributor Author

mluck commented Mar 26, 2024

Updated so that all NWS and USGS benchmark flows are updated (not just those in BAD_SITES).

An input to this is a FIM run (e.g., BED) since it uses the derived levelpaths.

@RyanSpies-NOAA
Copy link
Collaborator

I have a new error -->
Traceback (most recent call last):
File "//foss_fim/data/update_benchmark_flows.py", line 134, in
update_benchmark_flows(**args)
File "//foss_fim/data/update_benchmark_flows.py", line 81, in update_benchmark_flows
assert os.path.exists(levelpath_file), f"Levelpath file {levelpath_file} does not exist"
AssertionError: Levelpath file data/previous_fim/fim_4_4_5_0/04300109/nwm_subset_streams_levelPaths.gpkg does not exist

@mluck
Copy link
Contributor Author

mluck commented Apr 10, 2024

Previously, it was checking to make sure the input file existed, and if it didn't then it threw the AssertionError. Now, if an input file doesn't exist for a location, updating the flows are skipped for that location.

I was able to run this PR on the full set of AHPS benchmarks using fim_4_4_0_0.

@RyanSpies-NOAA
Copy link
Collaborator

Successfully ran the script for FIM 4.4.3.0
image

@RyanSpies-NOAA
Copy link
Collaborator

Confirmed that CBST2 flow file is unchanged with this feature branch. The flow file currently includes erroneous main stem flow values for the tributary river reaches (order=4). Will likely need a new ticket to address this.
image

@RyanSpies-NOAA
Copy link
Collaborator

RGDT2 (13090001) shows a slight regression with the new flow file. It appears that the tributary was erroneously added to the flow file -->
image
image

@mluck
Copy link
Contributor Author

mluck commented Apr 16, 2024

It looks like that's happening because the tributary is where the levelpath is designated. The levelpaths appear to be incorrect as the green levelpath is order 8 as well as the connected mainstem segment of the blue levelpath, but the tributary portion of the blue levelpath is order 4.

image

@mluck
Copy link
Contributor Author

mluck commented Apr 16, 2024

The stream segments are disconnected which is why the flow is being continued up the tributary instead of the mainstem
image

@mluck
Copy link
Contributor Author

mluck commented Apr 16, 2024

Would it make sense to add a feature to remove flows from feature_ids not on the mainstem levelpath (i.e., tributaries) as part of this PR?

@CarsonPruitt-NOAA
Copy link
Collaborator

Yeah, I think we could include removing the tributaries as part of this PR. It'll be sort of a benchmark flows overhaul.

@RyanSpies-NOAA
Copy link
Collaborator

Couple more plots to add here for future reference. The aggregate alpha test scores (NWS & USGS sites) show a nice MCC and CSI improvement as expected:
image
image

@mluck mluck changed the title [1pt] PR: Extend benchmark flows in AHPS domain [1pt] PR: Update benchmark flows in AHPS domain Apr 17, 2024
@mluck
Copy link
Contributor Author

mluck commented Apr 17, 2024

Flows in tributaries (not on the main levelpath) are now removed from the flow file. Example: flows from cbst2 NWS moderate magnitude (left: original, right: corrected)
image

@CarsonPruitt-NOAA
Copy link
Collaborator

Wow, that's a pretty major reduction in feature_ids. Did you confirm that these are accurate?

@mluck
Copy link
Contributor Author

mluck commented Apr 17, 2024

Yeah I checked that it's accurate. In addition to the tributary segments, a lot of the segments that are removed are up- and downstream of the AHPS domain (this seems to be the case for most of the flow files).
image

@RyanSpies-NOAA
Copy link
Collaborator

RyanSpies-NOAA commented Apr 18, 2024

With Matt's latest change nearly all of the flow files have been modified (as expected):
image

@mluck
Copy link
Contributor Author

mluck commented Apr 18, 2024

kcdm7 (USGS, HUC 10300101) looks like a bad case. The matching feature_ids in the flow file (highlighted in yellow) are all on the mainstem, but the domain (black) is on the tributary and none of the tributary segments have flow.
image
image

@mluck
Copy link
Contributor Author

mluck commented Apr 19, 2024

I used stream order to differentiate the tributary levelpath from the mainstem levelpath, but I found at least one case where there were two levelpaths of the same order in the domain. In case this happens, the flow is attributed to the longer levelpath (length in the domain) and not to the shorter levelpath. This agrees with the validation raster (gett2, HUC 12070205):
image

@RobHanna-NOAA
Copy link
Contributor

I need more information about deployment. I think it needs a full scale run to get new data, although I think Ryan might have this already completed. If that was time, I need time to deploy to all enviros prior to merge. Do I have it right that we create a new set of benchmark data we need for Alpha testing? Same.. I will need time to get it deployed. Do you it to be deployed ahead of any particular build? I am worried about too much coming in one build. Can someone clarify deployment for me?

@mluck
Copy link
Contributor Author

mluck commented Apr 23, 2024

This will generate an updated set of AHPS (NWS and USGS) benchmark flow files based on the current benchmark flow files. For testing, the outputs are all saved to a single folder, but on the actual (i.e., post-testing) run, do NOT set the output option -o which will force the new benchmark flow files to overwrite the existing benchmark flow files (after a copy of the originals are saved with a .bak extension in the same folder).

Then the new benchmark flow files will need replace the old benchmark flow files (and possibly also copy over the original .bak backup copies as well) the enviros prior to alpha testing.

@RyanSpies-NOAA
Copy link
Collaborator

Latest version of the alpha test metrics results look good (improved scores across the board).

NWS aggregate metrics (current vs. new eval flows):
image

USGS aggregate metrics (current vs. new eval flows):
image

@CarsonPruitt-NOAA
Copy link
Collaborator

Great news! I wasn't expecting to see any increased overprediction as shown in the Action stages. I'm guessing that's coming from the previously-labeled BAD_SITES that we added upstream flows to?

@RyanSpies-NOAA
Copy link
Collaborator

CBST2 (12090301) now shows a much improved agreement raster which can be attributed to the reduction in FP scores for the tributary domain:
image

@RyanSpies-NOAA
Copy link
Collaborator

RyanSpies-NOAA commented Apr 23, 2024

Regarding the increased false alarm values (especially for the USGS sites) - it appears there are a couple of factors at play. I think @CarsonPruitt-NOAA is correct that including some of the previous "bad sites" is a key contributor. Here is NMSO1 as an example:
Previous flow file was not providing flow for the reaches within the evaluation domain (purple flow lines show where the flow file has values) which yielded a lot of false negative scores:
image

Modified flow file is now providing flows for the appropriate reaches (green reaches) and there is a sizeable increase in the false positive scores:
image

image

@mluck
Copy link
Contributor Author

mluck commented May 6, 2024

AHPS data for Alaska are also being processed in #1130.

RyanSpies-NOAA
RyanSpies-NOAA previously approved these changes May 6, 2024
Copy link
Collaborator

@RyanSpies-NOAA RyanSpies-NOAA left a comment

Choose a reason for hiding this comment

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

Generated new flow files, successfully ran synthesize test case, and produced eval plots using existing 4.4.13.0 FIM outputs.

Locations that need to receive updated benchmark flow files (@RobHanna-NOAA):

  • EFS
  • Dev1
  • ESIP S3
  • ras2fim S3

@RobHanna-NOAA
Copy link
Contributor

Copy the efs.. /usgs_test_cases/validation_data_usgs/ to all enviros, correct?

@mluck
Copy link
Contributor Author

mluck commented May 6, 2024

@RobHanna-NOAA This will update both usgs_test_cases/validation_data_usgs/ and nws_test_cases/validation_data_nws/

@RobHanna-NOAA
Copy link
Contributor

Forgot to update. The data has been pushed to all enviros including ras2fim and ras2fim-dev

@CarsonPruitt-NOAA CarsonPruitt-NOAA merged commit ed703a2 into dev May 17, 2024
1 check passed
@CarsonPruitt-NOAA CarsonPruitt-NOAA deleted the dev-extend-benchmark-flow-files branch May 17, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing Evaluation and testing related
Projects
None yet
4 participants