Skip to content

Commit

Permalink
remove explicit tnex/tnx, fix flowpath dict
Browse files Browse the repository at this point in the history
  • Loading branch information
hellkite500 committed Nov 4, 2022
1 parent 29560ba commit f1b7a18
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/troute-network/troute/HYFeaturesNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,11 @@ def __init__(self, supernetwork_parameters, waterbody_parameters=None, restart_p
raise RuntimeError("Unsupported file type: {}".format(file_type))

#Don't need the string prefix anymore, drop it
mask = ~ self._dataframe['toid'].str.startswith("tnex")
self._dataframe = self._dataframe.apply(numeric_id, axis=1)
#make the flowpath linkage, ignore the terminal nexus
self._flowpath_dict = dict(zip(self._dataframe.loc[mask].toid, self._dataframe.loc[mask].id))
#make the flowpath linkage. Since we can/do add flow at terminal nodes,
#we include all nodes here, even if the qlat of that terminal is adjusted
#to another node upstream later.
self._flowpath_dict = dict(zip(self._dataframe.toid, self._dataframe.id))
self._waterbody_types_df = pd.DataFrame()
self._waterbody_df = pd.DataFrame()
#FIXME the base class constructor is finiky
Expand Down Expand Up @@ -358,9 +359,11 @@ def make_list(s):
print("channel initial states complete")
if __showtiming__:
print("... in %s seconds." % (time.time() - start_time))
terminal = self._dataframe[
~self._dataframe["downstream"].isin(self._dataframe.index)
]["downstream"]
#This is NEARLY redundant to the self.terminal_codes property, but in this case
#we actually need the mapping of what is upstream of that terminal node as well.
#we also only want terminals that actually exist based on definition, not user input
terminal_mask = ~self._dataframe["downstream"].isin(self._dataframe.index)
terminal = self._dataframe.loc[ terminal_mask ]["downstream"]
upstream_terminal = dict()
for key, value in terminal.items():
upstream_terminal.setdefault(value, set()).add(key)
Expand Down

0 comments on commit f1b7a18

Please sign in to comment.