Skip to content

Commit

Permalink
temporary fix to qlats to run both NHD with syn/natural x-sec and HYf…
Browse files Browse the repository at this point in the history
…eature only with syn x-sec for now
  • Loading branch information
kumdonoaa committed Dec 8, 2023
1 parent 5981e51 commit 07d511b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/troute-routing/troute/routing/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1485,9 +1485,9 @@ def compute_diffusive_routing(
# diffusive streamflow DA activation switch
#if da_parameter_dict['diffusive_streamflow_nudging']==True:
if 'diffusive_streamflow_nudging' in da_parameter_dict:
diff_usgs_df = usgs_df
diffusive_usgs_df = usgs_df
else:
diff_usgs_df = pd.DataFrame()
diffusive_usgs_df = pd.DataFrame()

# tw in refactored hydrofabric
if refactored_diffusive_domain:
Expand All @@ -1504,6 +1504,11 @@ def compute_diffusive_routing(
else:
coastal_boundary_depth_bytw_df = pd.DataFrame()

# temporary: column names of qlats from HYfeature are currently timestamps. To be consistent with qlats from NHD
# the column names need to be changed to intergers from zero incrementing by 1
diffusive_qlats = qlats.copy()
diffusive_qlats.columns = range(diffusive_qlats.shape[1])

# build diffusive inputs
diffusive_inputs = diff_utils.diffusive_input_data_v02(
tw,
Expand All @@ -1514,7 +1519,7 @@ def compute_diffusive_routing(
diffusive_network_data[tw]['tributary_segments'],
None, # place holder for diffusive parameters
diffusive_network_data[tw]['param_df'],
qlats,
diffusive_qlats,
q0,
junction_inflows,
qts_subdivisions,
Expand All @@ -1523,7 +1528,7 @@ def compute_diffusive_routing(
dt,
waterbodies_df,
topobathy_bytw,
diff_usgs_df,
diffusive_usgs_df,
refactored_diffusive_domain_bytw,
refactored_reaches_byrftw,
coastal_boundary_depth_bytw_df,
Expand Down
13 changes: 7 additions & 6 deletions src/troute-routing/troute/routing/diffusive_utils_v02.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def fp_qlat_map(
-----
data in qlat_g are normalized by segment length with units of m2/sec = m3/sec/m
"""

frj = -1
for x in range(mx_jorder, -1, -1):
for head_segment, reach in ordered_reaches[x]:
Expand Down Expand Up @@ -534,10 +533,13 @@ def fp_da_map(

usgs_df_complete = usgs_df.replace(np.nan, -4444.0)

for i in range(len(timestamps)):
if timestamps[i] not in usgs_df.columns:
usgs_df_complete.insert(i, timestamps[i], -4444.0*np.ones(len(usgs_df)), allow_duplicates=False)

missing_timestamps = [ts for ts in timestamps if ts not in usgs_df.columns]
missing_data = pd.DataFrame(-4444.0*np.ones((len(usgs_df), len(missing_timestamps))),
columns=missing_timestamps,
index=usgs_df.index)
usgs_df_complete = pd.concat([usgs_df_complete, missing_data], axis=1)
usgs_df_complete = usgs_df_complete[timestamps]

frj = -1
for x in range(mx_jorder, -1, -1):
for head_segment, reach in ordered_reaches[x]:
Expand Down Expand Up @@ -683,7 +685,6 @@ def diffusive_input_data_v02(
-------
diff_ins -- (dict) formatted inputs for diffusive wave model
"""

# lateral inflow timestep (sec). Currently, lateral flow in CHAROUT files at one hour time step
dt_ql_g = 3600.0
# upstream boundary condition timestep = MC simulation time step (sec)
Expand Down

0 comments on commit 07d511b

Please sign in to comment.