Skip to content

Commit

Permalink
self-driving: all but channel budget
Browse files Browse the repository at this point in the history
  • Loading branch information
jmccreight committed May 9, 2023
1 parent 03d9f68 commit 9848b90
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion autotest/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_init(self, domain, tmp_path, calc_method):
channel = PRMSChannel(
control,
**input_variables,
budget_type="error",
budget_type="warn",
calc_method=calc_method,
)
nc_parent = tmp_path / domain["domain_name"]
Expand Down
17 changes: 10 additions & 7 deletions pywatershed/hydrology/PRMSChannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def outflow_mask(self):

def _set_initial_conditions(self) -> None:
# initialize channel segment storage
self.seg_outflow = self.segment_flow_init
self.seg_outflow[:] = self.segment_flow_init
return

def _initialize_channel_data(self) -> None:
Expand Down Expand Up @@ -360,16 +360,19 @@ def _calculate(self, simulation_time: float) -> None:
# mass is being discarded in a way that has to be coordinated
# with other parts of the code.
# This code shuold be removed evenutally.
self.sroff_vol[ihru] = zero
self.ssres_flow_vol[ihru] = zero
self.gwres_flow_vol[ihru] = zero
_sroff_vol = zero
_ssres_flow_vol = zero
_gwres_flow_vol = zero
continue

else:
_sroff_vol = self.sroff_vol[ihru]
_ssres_flow_vol = self.ssres_flow_vol[ihru]
_gwres_flow_vol = self.gwres_flow_vol[ihru]

# cubicfeet to cfs
lateral_inflow = (
self.sroff_vol[ihru]
+ self.ssres_flow_vol[ihru]
+ self.gwres_flow_vol[ihru]
_sroff_vol + _ssres_flow_vol + _gwres_flow_vol
) / (s_per_time)

self.seg_lateral_inflow[iseg] += lateral_inflow
Expand Down
4 changes: 3 additions & 1 deletion pywatershed/hydrology/PRMSRunoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def _calculate(self, time_length, vectorized=False):
self.dprst_stor_hru - self.dprst_stor_hru_old
)

self.sroff_vol = self.sroff * self.control.params.hru_in_to_cf
self.sroff_vol[:] = self.sroff * self.control.params.hru_in_to_cf

return

Expand Down Expand Up @@ -1276,6 +1276,7 @@ def perv_comp(

if ca_fraction > carea_max:
ca_fraction = carea_max

srpp = ca_fraction * pptp
infil = infil - srpp
srp = srp + srpp
Expand All @@ -1295,6 +1296,7 @@ def check_capacity(
if excess > snowinfil_max:
srp = srp + excess - snowinfil_max
infil = snowinfil_max + capacity

return infil, srp

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion pywatershed/hydrology/PRMSSoilzone.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_init_values() -> dict:
"soil_lower_ratio": zero,
"soil_lower_max": nan, # completely set later
"soil_moist": nan, # sm_climateflow
"soil_moist_prev": nan, # sm_climateflow
"soil_moist_prev": zero, # sm_climateflow
"soil_moist_tot": nan, # completely set later
"soil_rechr": nan, # sm_climateflow
"soil_rechr_change": nan, # sm_climateflow
Expand Down
2 changes: 1 addition & 1 deletion pywatershed/parameters/prms_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def from_nc_files(
for proc, file in proc_param_nc_file_dict.items()
}
if merge:
params = PrmsParameters.merge(list(prams.values()))
params = PrmsParameters.merge(list(params.values()))

return params

Expand Down

0 comments on commit 9848b90

Please sign in to comment.