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

mask output #806

Merged
merged 11 commits into from
Jul 26, 2024
Merged

mask output #806

merged 11 commits into from
Jul 26, 2024

Conversation

AminTorabi-NOAA
Copy link
Contributor

This PR user can define some specific nexus points or flowpaths and based on that results will be filtered. It creates a crosswalk between nexus points and flowpaths and if there are more than one flowpaths going to a nexus points it add up the flowrate and average the waterdepth.
reading POI capability will be added soon (waiting for final version of gpkg)

Additions

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

@AminTorabi-NOAA AminTorabi-NOAA marked this pull request as ready for review July 17, 2024 15:30
Copy link
Contributor

@JurgenZach-NOAA JurgenZach-NOAA left a comment

Choose a reason for hiding this comment

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

Tested and approve.


def crosswalk_nex_flowpath_poi(self, flowpaths, nexus):

mask_flowpaths = flowpaths['toid'].str.startswith('nex-')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add toids that start with tnex- as well? We should capture these terminal nexus points as well.

@@ -414,7 +416,15 @@ def preprocess_network(self, flowpaths, nexus):
# Location information will be used to advertise tailwater locations of diffusive domains
# to the model engine/coastal models
self._nexus_latlon = nexus

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add this space back? Just for aesthetics.

if 'poi_id' in nexus.columns:
self._poi_nex_dict = nexus.groupby('poi_id')['id'].apply(list).to_dict()
else:
self._poi_nex_dict = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a space between functions. Just for aesthetics.

Comment on lines 2196 to 2215
if nex_id:
for nex_key, nex_val in nex_id.items():
new_index = pd.MultiIndex.from_tuples([(nex_key, 'nex')], names=['featureID', 'Type'])
flowveldepth_nex = flowveldepth[create_mask(nex_val)]

if not flowveldepth_nex.empty:
if len(flowveldepth_nex.index) > 1:
summed_data = flowveldepth_nex.sum()
new_data = pd.DataFrame([summed_data], index=new_index)
new_data.loc[(nex_key, 'nex'), filtered_v_columns] = np.nan
new_data.loc[(nex_key, 'nex'), filtered_d_columns] = flowveldepth_nex[filtered_d_columns].mean()
else:
new_data = flowveldepth_nex.copy()
new_data.index = new_index

nex_data_list.append(new_data)

all_nex_data = pd.concat(nex_data_list) if nex_data_list else pd.DataFrame()
else:
all_nex_data = pd.DataFrame()
Copy link
Contributor

Choose a reason for hiding this comment

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

This chunk seems quite slow if 9999 is included. I wonder if this could be sped up by adding a column to flowveldepth that is the toid for each wb- featureID. These would obviously be nex- IDs, then you could just group by the toid column and sum? Something like that.

@AminTorabi-NOAA AminTorabi-NOAA merged commit 11556c0 into NOAA-OWP:master Jul 26, 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