Skip to content

Commit

Permalink
updates to run NHD (NOAA-OWP#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
AminTorabi-NOAA authored Jan 5, 2024
1 parent eb2f2ea commit 4ef96b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/troute-network/troute/NHDNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def read_geo_file(self,):
self._dataframe = self.dataframe.set_index("key").sort_index()

# get and apply domain mask
if "mask_file_path" in self.supernetwork_parameters:
if self.supernetwork_parameters["mask_file_path"]:
data_mask = nhd_io.read_mask(
pathlib.Path(self.supernetwork_parameters["mask_file_path"]),
layer_string=self.supernetwork_parameters.get("mask_layer_string", None),
Expand Down
6 changes: 5 additions & 1 deletion src/troute-network/troute/nhd_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ def read_lakeparm(
# TODO: avoid or parameterize "feature_id" or ... return to name-blind dataframe version
with xr.open_dataset(parm_file) as ds:
ds = ds.swap_dims({"feature_id": lake_index_field})
df1 = ds.sel({lake_index_field: list(lake_id_mask)}).to_dataframe()
lake_id_values = list(lake_id_mask)
ds_filtered = ds.where(ds.lake_id.isin(lake_id_values), drop=True)
df1 = ds_filtered.to_dataframe()
# df1 = ds.sel({lake_index_field: list(lake_id_mask)}).to_dataframe()

df1 = df1.sort_index(axis="index")
return df1

Expand Down

0 comments on commit 4ef96b4

Please sign in to comment.