From 213b596a69af0dd6fb959389d2857a991b070dd4 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Wed, 21 Aug 2024 10:24:28 +0200 Subject: [PATCH 1/2] refactor get_influx --- core/src/util.jl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/core/src/util.jl b/core/src/util.jl index 39de179a9..436c9ddb3 100644 --- a/core/src/util.jl +++ b/core/src/util.jl @@ -540,12 +540,19 @@ function get_influx(basin::Basin, node_id::NodeID)::Float64 end function get_influx(basin::Basin, basin_idx::Int; prev::Bool = false)::Float64 - (; vertical_flux, vertical_flux_prev, vertical_flux_from_input) = basin - vertical_flux = wrap_forcing(vertical_flux[parent(vertical_flux_from_input)]) - flux_vector = prev ? vertical_flux_prev : vertical_flux - (; precipitation, evaporation, drainage, infiltration) = flux_vector - return precipitation[basin_idx] - evaporation[basin_idx] + drainage[basin_idx] - - infiltration[basin_idx] + (; node_id, vertical_flux, vertical_flux_prev, vertical_flux_from_input) = basin + if prev + vertical_flux_prev.precipitation[basin_idx] - + vertical_flux_prev.evaporation[basin_idx] + vertical_flux_prev.drainage[basin_idx] - + vertical_flux_prev.infiltration[basin_idx] + else + n = length(node_id) + vertical_flux = vertical_flux[parent(vertical_flux_from_input)] + vertical_flux[basin_idx] - # precipitation + vertical_flux[n + basin_idx] + # evaporation + vertical_flux[2n + basin_idx] - # drainage + vertical_flux[3n + basin_idx] # infiltration + end end inflow_edge(graph, node_id)::EdgeMetadata = graph[inflow_id(graph, node_id), node_id] From 333ffa979aa9e1d1e8550930e6286bfc9860984a Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Tue, 27 Aug 2024 11:57:38 +0200 Subject: [PATCH 2/2] Comment adressed --- core/src/util.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/util.jl b/core/src/util.jl index 8497d51cc..42bd136ea 100644 --- a/core/src/util.jl +++ b/core/src/util.jl @@ -541,9 +541,10 @@ end function get_influx(basin::Basin, basin_idx::Int; prev::Bool = false)::Float64 (; node_id, vertical_flux, vertical_flux_prev, vertical_flux_from_input) = basin - if prev + influx = if prev vertical_flux_prev.precipitation[basin_idx] - - vertical_flux_prev.evaporation[basin_idx] + vertical_flux_prev.drainage[basin_idx] - + vertical_flux_prev.evaporation[basin_idx] + + vertical_flux_prev.drainage[basin_idx] - vertical_flux_prev.infiltration[basin_idx] else n = length(node_id) @@ -553,6 +554,7 @@ function get_influx(basin::Basin, basin_idx::Int; prev::Bool = false)::Float64 vertical_flux[2n + basin_idx] - # drainage vertical_flux[3n + basin_idx] # infiltration end + return influx end inflow_edge(graph, node_id)::EdgeMetadata = graph[inflow_id(graph, node_id), node_id]