Skip to content

Commit

Permalink
Add input types fr get_test_decision_matrix, remove `criteria_names…
Browse files Browse the repository at this point in the history
…` output +formatting
  • Loading branch information
Rosejoycrocker committed Jan 23, 2024
1 parent f6e8972 commit 31841f6
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions test/site_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function test_site_ranks(
mcda_func::Function,
inv::Float64,
)
S = ADRIA.decision.mcda_normalize(A)
S[:, 1] .= A[:, 1]
S = ADRIA.decision.mcda_normalize(A)
S[:, 1] .= A[:, 1]
criteria_names = [
"heat stress",
"wave stress",
Expand Down Expand Up @@ -68,32 +68,31 @@ function test_mcda_funcs(rankings::Matrix{Int64}, S::Matrix{Float64},
end
end

function get_test_decision_matrix(dom)
cover = sum(dom.init_coral_cover; dims=:species)[species=1]
leftover_space = 1 .- cover
k_area = dom.site_data.area .* dom.site_data.k
dhw_av = ADRIA.decision.summary_stat_env(dom.dhw_scens, (:timesteps, :scenarios))
wave_av = ADRIA.decision.summary_stat_env(dom.wave_scens, (:timesteps, :scenarios))
depth_med = dom.site_data.depth_med
function get_test_decision_matrix(dom::Domain)::Matrix{Float64}
cover = sum(dom.init_coral_cover; dims = :species)[species = 1]
leftover_space = 1 .- cover
k_area = dom.site_data.area .* dom.site_data.k
dhw_av = ADRIA.decision.summary_stat_env(dom.dhw_scens, (:timesteps, :scenarios))
wave_av = ADRIA.decision.summary_stat_env(dom.wave_scens, (:timesteps, :scenarios))
depth_med = dom.site_data.depth_med

TP_data = ADRIA.connectivity_strength(
dom.TP_data .* ADRIA.site_k_area(dom), collect(cover), dom.TP_data
)
TP_data = ADRIA.connectivity_strength(
dom.TP_data .* ADRIA.site_k_area(dom), collect(cover), dom.TP_data
)

site_ids = dom.site_data.site_id
site_ids = dom.site_data.site_id

heat_stress =
1 .- vec((dhw_av .- minimum(dhw_av)) ./ (maximum(dhw_av) - minimum(dhw_av)))
wave_stress =
1 .- vec((wave_av .- minimum(wave_av)) ./ (maximum(wave_av) - minimum(wave_av)))
space_area = leftover_space .* k_area
in_conn = TP_data.in_conn
out_conn = TP_data.out_conn
heat_stress =
1 .- vec((dhw_av .- minimum(dhw_av)) ./ (maximum(dhw_av) - minimum(dhw_av)))
wave_stress =
1 .- vec((wave_av .- minimum(wave_av)) ./ (maximum(wave_av) - minimum(wave_av)))
space_area = leftover_space .* k_area
in_conn = TP_data.in_conn
out_conn = TP_data.out_conn

A = hcat(site_ids, heat_stress, wave_stress, depth_med, space_area, in_conn, out_conn)
A = hcat(site_ids, heat_stress, wave_stress, depth_med, space_area, in_conn, out_conn)

return A
return A, criteria_names
end

@testset "site selection" begin
Expand Down

0 comments on commit 31841f6

Please sign in to comment.