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

simple fix for empty lastobs_df when streamnudging unknowingly turned on while no usgs data is available #732

Merged
merged 4 commits into from
Feb 5, 2024

Conversation

kumdonoaa
Copy link
Contributor

@kumdonoaa kumdonoaa commented Jan 30, 2024

This fix provides a solution when lastobs_df is empty because no usgs data is available while stream nudging is unknowingly activated in the config file. More solid solution will be provided soon. Also, in diffusive_routing mainstem_list now has a list of stream segments aligned in order from upstream to downstream. Moreover, missing topobathy data for a stream segment get filled in by looking up the newly aligned list.

Additionns

AbstractRouting.py

  • removed sort() to mainstem_list to align a list of stream segments in order from upstream to downstream
  • modified the way to search for an upstream segment id for a given mainstem segment that has no channel xsec topobathy data

DataAssimilation.py

  • Added a condition not to call new_lastobs function when there is no lastobs related values updated from mc_reach.pyx

output.py

  • Added a condition not to call lastobs_df_output when there is no lastobs related values updated from mc_reach.pyx

Removals

Changes

Testing

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Windows
  • Linux
  • Browser

Accessibility

  • Keyboard friendly
  • Screen reader friendly

Other

  • Is useable without CSS
  • Is useable without JS
  • Flexible from small to large screens
  • No linting errors or warnings
  • JavaScript tests are passing

if streamflow_da_parameters:
if streamflow_da_parameters.get('streamflow_nudging', False):
self._last_obs_df = new_lastobs(run_results, time_increment)
if not run_results[0][3][0].size == 0:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check needs to be modified. This only checks if the first object in run_results has no gage information. But this varies for each object:

(Pdb) [rr[3][0].size for rr in run_results]
[2,2,0,2,0,1,0,0,3,0,17,1,1,4,3,1,0,0,0,2,0,1,2,0,0,0,1,0,3,1,2,1,1,0,1,1,0,1,0,1,3,0,0,0,0,0,0,0,3,1,0,11,0,2,0,0,3,1,0,0,0,2,4,0,0,3,0,0,0,0]
(Pdb)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what about checking self._last_obs_df? If it is empty in the first place, then we expect nothing will come out for lastobs values from mc_reach.pyx.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we say something like:

for rr in range(len(run_results[0][3])): 
      if not run_results[0][3][rr].size == 0:
          self._last_obs_df = new_lastobs(run_results, time_increment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your suggestion.

…to downstream and revised filling up missing topobathy data
position_upstream_mainstem_segment = position_mainstem_segment
while temp_df.empty:
try:
position_upstream_mainstem_segment = position_upstream_mainstem_segment - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you decrease it by 1 here? Are the IDs always consecutive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That does not decreasing flowpath ID number but the position of stream segment in the mainstem segment list that has aligned the list from upstream to downstream.

Copy link
Contributor

Choose a reason for hiding this comment

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

True that's correct. Just a very small suggestion, its more readable to write it like position_upstream_mainstem_segment -= 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks and updated.

@kumdonoaa kumdonoaa merged commit 00f1f1b into NOAA-OWP:master Feb 5, 2024
4 checks passed
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.

3 participants