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

Abstract network update #600

Merged
merged 56 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
aafe865
initial commit
shorvath-noaa Dec 8, 2022
d910718
updated Abstract and HyFeatures network objects to use new functions
shorvath-noaa Dec 9, 2022
4c5e60e
bug fixes to get hyfeatures to run properly
shorvath-noaa Dec 12, 2022
edfd873
updates to NHDNetwork and functions in AbstractNetwork
shorvath-noaa Dec 15, 2022
1cffd02
moved renaming param_df column into individual networks, removed cols…
shorvath-noaa Dec 16, 2022
82f4ac2
move renaming dataframe columns and terminal codes/connections creati…
shorvath-noaa Dec 16, 2022
830c6ef
move functions from ..._preprocess.py files into the network objects …
shorvath-noaa Dec 21, 2022
e2f0687
fixed errors in data_assimilation.update() function
shorvath-noaa Dec 21, 2022
2e64b78
t-route on larger hyfeature domain with hybrid routing (#602)
kumdonoaa Dec 23, 2022
7373800
add 'RoutingScheme' subclass of AbstractNetwork to set MC/diffusive r…
shorvath-noaa Dec 27, 2022
f96e902
bug fixes to get test HYfeatures with MC only run working
shorvath-noaa Dec 28, 2022
7b73ab0
move build_qlateral_array function from AbstractNetwork to individual…
shorvath-noaa Dec 30, 2022
b3822a1
bug fixes to get NHDNetwork working with new configuration
shorvath-noaa Dec 30, 2022
327854c
modified routing classes to be separate from network classes
shorvath-noaa Jan 5, 2023
54b9714
edited names of routing objects, consolidated inputs to nwm_route int…
shorvath-noaa Jan 10, 2023
527b5bd
edits to diffusive routing
shorvath-noaa Jan 23, 2023
f33f2a7
temporary fix for writing CHRTOUT files in serial rather than parallel
shorvath-noaa Jan 23, 2023
d5fbb14
minor updates to previous push
shorvath-noaa Jan 25, 2023
bc71522
Delete RoutingScheme.py
shorvath-noaa Jan 25, 2023
11ca4ac
Delete nhd_preprocess.py
shorvath-noaa Jan 27, 2023
9d9a5a2
Delete hyfeature_preprocess.py
shorvath-noaa Jan 27, 2023
adb9903
more updates to address comments above
shorvath-noaa Jan 27, 2023
dcbb793
deleted files
shorvath-noaa Jan 27, 2023
0ee7a9c
Merge branch 'abstract_network_update' of https://github.com/shorvath…
shorvath-noaa Jan 27, 2023
4f13af1
Fix troute-nwm package setup.cfg (#603)
hellkite500 Feb 2, 2023
89eea67
removed loading nhd_preprocess.py as this file was removed
shorvath-noaa Feb 10, 2023
651745f
reverse changes to compute_nhd_routing_v02 input arguments
shorvath-noaa Feb 10, 2023
68fe63d
edit to work with redesigned initial_warmstate_preprocess function
shorvath-noaa Feb 10, 2023
c2006d1
move build_forcing_sets() to AbstractNetwork. abstractnetwork_preproc…
shorvath-noaa Feb 10, 2023
f1be8cd
Delete abstractnetwork_preprocess.py
shorvath-noaa Feb 10, 2023
3927cee
initial commit
shorvath-noaa Dec 8, 2022
119b6c3
updated Abstract and HyFeatures network objects to use new functions
shorvath-noaa Dec 9, 2022
4ffeeb8
bug fixes to get hyfeatures to run properly
shorvath-noaa Dec 12, 2022
d2cfe51
updates to NHDNetwork and functions in AbstractNetwork
shorvath-noaa Dec 15, 2022
32c2fbd
moved renaming param_df column into individual networks, removed cols…
shorvath-noaa Dec 16, 2022
00adf80
move renaming dataframe columns and terminal codes/connections creati…
shorvath-noaa Dec 16, 2022
ed9db17
move functions from ..._preprocess.py files into the network objects …
shorvath-noaa Dec 21, 2022
e68eaa6
fixed errors in data_assimilation.update() function
shorvath-noaa Dec 21, 2022
07a7d0a
add 'RoutingScheme' subclass of AbstractNetwork to set MC/diffusive r…
shorvath-noaa Dec 27, 2022
8213c77
bug fixes to get test HYfeatures with MC only run working
shorvath-noaa Dec 28, 2022
c0c0c91
move build_qlateral_array function from AbstractNetwork to individual…
shorvath-noaa Dec 30, 2022
6da91c1
bug fixes to get NHDNetwork working with new configuration
shorvath-noaa Dec 30, 2022
e4015c8
modified routing classes to be separate from network classes
shorvath-noaa Jan 5, 2023
d68d840
edited names of routing objects, consolidated inputs to nwm_route int…
shorvath-noaa Jan 10, 2023
127e37c
edits to diffusive routing
shorvath-noaa Jan 23, 2023
7df99c0
temporary fix for writing CHRTOUT files in serial rather than parallel
shorvath-noaa Jan 23, 2023
2a02439
minor updates to previous push
shorvath-noaa Jan 25, 2023
96bf87c
Delete RoutingScheme.py
shorvath-noaa Jan 25, 2023
e8f19d5
Delete nhd_preprocess.py
shorvath-noaa Jan 27, 2023
4f12e4e
Delete hyfeature_preprocess.py
shorvath-noaa Jan 27, 2023
ffa0f26
more updates to address comments above
shorvath-noaa Jan 27, 2023
25f8cff
removed loading nhd_preprocess.py as this file was removed
shorvath-noaa Feb 10, 2023
857bfd1
reverse changes to compute_nhd_routing_v02 input arguments
shorvath-noaa Feb 10, 2023
724b400
edit to work with redesigned initial_warmstate_preprocess function
shorvath-noaa Feb 10, 2023
a2dca46
move build_forcing_sets() to AbstractNetwork. abstractnetwork_preproc…
shorvath-noaa Feb 10, 2023
5ba06a3
resolve conflicts
shorvath-noaa Feb 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/troute-network/troute/AbstractNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from troute.nhd_network import extract_connections, replace_waterbodies_connections, reverse_network, reachable_network, split_at_waterbodies_and_junctions, split_at_junction, dfs_decomposition
from troute.nhd_network_utilities_v02 import organize_independent_networks, build_channel_initial_state, build_refac_connections
import troute.nhd_io as nhd_io
from .AbstractRouting import *
from .AbstractRouting import MCOnly, MCwithDiffusive, MCwithDiffusiveNatlXSectionNonRefactored, MCwithDiffusiveNatlXSectionRefactored

LOG = logging.getLogger('')

Expand All @@ -20,7 +20,7 @@ class AbstractNetwork(ABC):
"""
__slots__ = ["_dataframe", "_waterbody_connections", "_gages",
"_terminal_codes", "_connections", "_waterbody_df",
"_waterbody_types_df", "_waterbody_type_specified",
"_waterbody_types_df", "_waterbody_type_specified", "_link_gage_df",
"_independent_networks", "_reaches_by_tw", "_flowpath_dict",
"_reverse_network", "_q0", "_t0", "_link_lake_crosswalk",
"_qlateral", "_break_segments", "_segment_index", "_coastal_boundary_depth_df",
Expand All @@ -36,6 +36,7 @@ def __init__(self,):
self._q0 = None
self._t0 = None
self._qlateral = None
self._link_gage_df = None
#qlat_const = forcing_parameters.get("qlat_const", 0)
#FIXME qlat_const
""" Figure out a good way to default initialize to qlat_const/c
Expand Down Expand Up @@ -239,11 +240,11 @@ def reaches_by_tailwater(self):

@property
def waterbody_dataframe(self):
return self._waterbody_df.sort_index()
return self._waterbody_df

@property
def waterbody_types_dataframe(self):
return self._waterbody_types_df.sort_index()
return self._waterbody_types_df

@property
def waterbody_type_specified(self):
Expand Down Expand Up @@ -319,9 +320,10 @@ def segment_index(self):

@property
def link_gage_df(self):
link_gage_df = pd.DataFrame.from_dict(self._gages)
link_gage_df.index.name = 'link'
return link_gage_df
if self._link_gage_df is None:
self._link_gage_df = pd.DataFrame.from_dict(self._gages)
self._link_gage_df.index.name = 'link'
return self._link_gage_df

@property
@abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion src/troute-network/troute/AbstractRouting.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def unrefactored_topobathy_df(self):
class MCOnly(AbstractRouting):

def __init__(self, hybrid_params):
self.hybrid_params = hybrid_params
self.hybrid_params = None

super().__init__()

Expand Down
15 changes: 8 additions & 7 deletions src/troute-network/troute/HYFeaturesNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np
import geopandas as gpd
import time
import os
import json
from pathlib import Path
import pyarrow.parquet as pq
Expand Down Expand Up @@ -54,10 +53,10 @@ def read_ngen_waterbody_df(parm_file, lake_index_field="wb-id", lake_id_mask=Non
for level-pool reservoir computation.
"""
def node_key_func(x):
return int(x[3:])
if os.path.splitext(parm_file)[1]=='.gpkg':
return int( x.split('-')[-1] )
if Path(parm_file).suffix=='.gpkg':
df = gpd.read_file(parm_file, layer="lake_attributes").set_index('id')
elif os.path.splitext(parm_file)[1]=='.json':
elif Path(parm_file).suffix=='.json':
df = pd.read_json(parm_file, orient="index")

df.index = df.index.map(node_key_func)
Expand All @@ -75,11 +74,11 @@ def read_ngen_waterbody_type_df(parm_file, lake_index_field="wb-id", lake_id_mas
# layer, but as of now (Nov 22, 2022) there doesn't seem to be a differentiation
# between USGS reservoirs, USACE reservoirs, or RFC reservoirs...
def node_key_func(x):
return int(x[3:])
return int( x.split('-')[-1] )

if os.path.splitext(parm_file)[1]=='.gpkg':
if Path(parm_file).suffix=='.gpkg':
df = gpd.read_file(parm_file, layer="crosswalk").set_index('id')
elif os.path.splitext(parm_file)[1]=='.json':
elif Path(parm_file).suffix=='.json':
df = pd.read_json(parm_file, orient="index")

df.index = df.index.map(node_key_func)
Expand Down Expand Up @@ -306,6 +305,7 @@ def read_geo_file(self,):
self.waterbody_dataframe.reset_index()
.drop_duplicates(subset=lake_id)
.set_index(lake_id)
.sort_index()
)

try:
Expand All @@ -319,6 +319,7 @@ def read_geo_file(self,):
self.waterbody_types_dataframe.reset_index()
.drop_duplicates(subset=lake_id)
.set_index(lake_id)
.sort_index()
)

except ValueError:
Expand Down
1 change: 1 addition & 0 deletions src/troute-network/troute/NHDNetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def read_geo_file(self,):
self.waterbody_dataframe.reset_index()
.drop_duplicates(subset="lake_id")
.set_index("lake_id")
.sort_index()
)

# Declare empty dataframe
Expand Down
1 change: 1 addition & 0 deletions src/troute-network/troute/nhd_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def read_reservoir_parameter_file(
df1 = (df1.reset_index()
.drop_duplicates(subset="lake_id")
.set_index("lake_id")
.sort_index()
)

# recode to levelpool (1) for reservoir DA types set to false
Expand Down