@@ -34,27 +34,31 @@ include("Nodes/DamNode.jl")
3434include (" Nodes/EnsembleNode.jl" )
3535
3636
37- function timestep_value (timestep:: Int , gauge_id:: String , col_partial:: String ,
38- dataset:: Union{DataFrame, Vector, Number, Nothing} = nothing ):: Float64
39- amount:: Float64 = 0.0
40- if ! isnothing (dataset)
41- if dataset isa Vector
42- amount = dataset[ts]
43- elseif dataset isa DataFrame
44- # Extract data for time step based on partial match
45- target_col = filter (x -> occursin (gauge_id, x)
37+ function timestep_value (ts:: Int , gauge_id:: String , col_partial:: String , dataset:: DataFrame ):: Float64
38+ target_col = filter (x -> occursin (gauge_id, x)
4639 & occursin (col_partial, x),
47- names (dataset))
48- if ! isempty (target_col)
49- amount = checkbounds (Bool, dataset. Date, timestep) ? dataset[timestep, target_col][1 ] : 0.0
50- end
51- elseif dataset isa Number
52- amount = dataset
40+ names (dataset)
41+ )
42+
43+ if ! isempty (target_col)
44+ amount = if checkbounds (Bool, dataset. Date, timestep)
45+ dataset[timestep, target_col][1 ]
46+ else
47+ 0.0
5348 end
5449 end
5550
5651 return amount
5752end
53+ @inline function timestep_value (_:: Int , _:: String , _:: String , dataset:: Float64 ):: Float64
54+ return dataset
55+ end
56+ @inline function timestep_value (_:: Int , _:: String , _:: String , dataset:: Nothing ):: Float64
57+ return 0.0
58+ end
59+ @inline function timestep_value (ts:: Int , _:: String , _:: String , dataset:: Vector ):: Float64
60+ return dataset[ts]
61+ end
5862
5963
6064"""
0 commit comments