Skip to content

Commit

Permalink
try findfirst
Browse files Browse the repository at this point in the history
  • Loading branch information
szy21 committed Jul 9, 2024
1 parent 15cf4d4 commit da4e460
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ function set_insolation_variables!(Y, p, t, ::TimeVaryingInsolation)
end
end

# function set_aerosol_type(;
# DST01 = 0,
# SSLT01 = 0,
# SO4 = 0,
# CB1 = 0,
# CB2 = 0,
# OC1 = 0,
# OC2 = 0,
# _...,
# )
# _, index = findmax((DST01, SSLT01, SO4, CB1, CB2, OC1, OC2))
# return index
# end

function set_aerosol_type(;
DST01 = 0,
SSLT01 = 0,
Expand All @@ -262,8 +276,12 @@ function set_aerosol_type(;
OC2 = 0,
_...,
)
_, index = findmax((DST01, SSLT01, SO4, CB1, CB2, OC1, OC2))
return index
maxval = max(DST01, SSLT01, SO4, CB1, CB2, OC1, OC2)
i = findfirst(
c -> c == maxval,
(DST01, SSLT01, SO4, CB1, CB2, OC1, OC2),
)::Int
return i
end
set_aerosol_type(NT) = set_aerosol_type(; NT...)

Expand Down

0 comments on commit da4e460

Please sign in to comment.