ADRIA API
Metrics
ADRIA.metrics._absolute_juveniles
— Methodabsolute_juveniles(X::AbstractArray{T,3}, coral_spec::DataFrame, k_area::AbstractVector{T})::AbstractArray{T,2} where {T<:Real}
-absolute_juveniles(rs::ResultSet)::AbstractArray{<:Real,2}
Juvenile coral cover in m².
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations)
coral_spec
: Coral spec DataFramek_area
: The coral habitable area.
ADRIA.metrics._absolute_shelter_volume
— Methodabsolute_shelter_volume(X::YAXArray{T,3}, k_area::Vector{T}, inputs::DataFrameRow)::AbstractArray{T} where {T<:Real}
+absolute_juveniles(rs::ResultSet)::AbstractArray{<:Real,2}
Juvenile coral cover in m².
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations)
coral_spec
: Coral spec DataFramek_area
: The coral habitable area.
ADRIA.metrics._absolute_shelter_volume
— Methodabsolute_shelter_volume(X::YAXArray{T,3}, k_area::Vector{T}, inputs::DataFrameRow)::AbstractArray{T} where {T<:Real}
absolute_shelter_volume(X::YAXArray{T,4}, k_area::Vector{T}, inputs::DataFrame)::AbstractArray{T} where {T<:Real}
absolute_shelter_volume(X::YAXArray{T,3}, k_area::Vector{T}, inputs::YAXArray)::AbstractArray{T} where {T<:Real}
absolute_shelter_volume(X::YAXArray{T,4}, k_area::Vector{T}, inputs::YAXArray)::AbstractArray{T} where {T<:Real}
-absolute_shelter_volume(rs::ResultSet)
Provide indication of shelter volume in volume of cubic meters.
The metric applies log-log linear models developed by Urbina-Barreto et al., [1] which uses colony diameter and planar area (2D metrics) to estimate shelter volume (a 3D metric).
Arguments
X
: raw resultsk_area
: area in m^2 for each sitemax_cover
: maximum possible coral cover for each site (in percentage of loc_area)inputs
: DataFrame of scenario inputs
References
- Urbina-Barreto, I., Chiroleu, F., Pinel, R., Fréchon, L., Mahamadaly, V., Elise, S., Kulbicki, M., Quod, J.-P., Dutrieux, E., Garnier, R., Henrich Bruggemann, J., Penin, L., & Adjeroud, M. (2021). Quantifying the shelter capacity of coral reefs using photogrammetric 3D modeling: From colonies to reefscapes. Ecological Indicators, 121, 107151. https://doi.org/10.1016/j.ecolind.2020.107151
ADRIA.metrics._collate_ranked_locs
— Method_collate_ranked_locs(data::YAXArray)::Matrix{Int64}
Collates number of ranked locations.
ADRIA.metrics._collate_ranks
— Method_collate_ranks(rs, selected)
Collates ranks into seed/fog ranking results into a common structure.
ADRIA.metrics._colony_Lcm2_to_m3m2
— Method_colony_Lcm2_to_m3m2(inputs::DataFrame)::Tuple
-_colony_Lcm2_to_m3m2(inputs::YAXArray)::Tuple{Vector{Float64},Vector{Float64}}
Helper function to convert coral colony values from Litres/cm² to m³/m²
Arguments
inputs
: Scenario values for the simulation
Returns
Tuple : Assumed colony volume (m³/m²) for each species/size class, theoretical maximum for each species/size class
References
- Aston Eoghan A., Duce Stephanie, Hoey Andrew S., Ferrari Renata (2022). A Protocol for Extracting Structural Metrics From 3D Reconstructions of Corals. Frontiers in Marine Science, 9. https://doi.org/10.3389/fmars.2022.854395
ADRIA.metrics._coral_evenness
— Methodcoral_evenness(r_taxa_cover::AbstractArray{T})::AbstractArray{T} where {T<:Real}
-coral_evenness(rs::ResultSet)::AbstractArray{T} where {T}
Calculates evenness across functional coral groups in ADRIA as a diversity metric. Inverse Simpsons diversity indicator.
References
- Hill, M. O. (1973).
Diversity and Evenness: A Unifying Notation and Its Consequences. Ecology, 54(2), 427-432. https://doi.org/10.2307/1934352
ADRIA.metrics._get_ranks
— Method_get_ranks(rs::ResultSet, intervention::Int64; kwargs...)
Extracts results for a specific intervention (:seed or :fog)
ADRIA.metrics._juvenile_indicator
— Methodjuvenile_indicator(X::AbstractArray{T,3}, coral_spec::DataFrame, k_area::Vector{Float64})::AbstractArray{T,2} where {T<:Real}
-juvenile_indicator(rs::ResultSet)::AbstractArray{<:Real,2}
Indicator for juvenile density (0 - 1), where 1 indicates the maximum theoretical density for juveniles have been achieved.
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations).
coral_spec
: Coral spec DataFrame.k_area
: The coral habitable area.
Notes
Maximum density is 51.8 juveniles / m², where juveniles are defined as < 5cm diameter. See email correspondence from: Dr. A Thompson; to: Dr. K. Anthony Subject: RE: Max density of juvenile corals on the GBR Sent: Friday, 14 October 2022 2:58 PM
ADRIA.metrics._max_juvenile_area
— Function_max_juvenile_area(coral_params::DataFrame, max_juv_density::Float64=51.8)
Calculate the maximum possible area that can be covered by juveniles for a given m².
ADRIA.metrics._reef_condition_index
— Methodreef_condition_index(rc::AbstractArray, evenness::AbstractArray, sv::AbstractArray, juves::AbstractArray; threshold=2)::AbstractArray
-reef_condition_index(rs::ResultSet)::AbstractArray{<:Real}
Estimates a Reef Condition Index (RCI) providing a single value that indicates the condition of a reef across four metrics:
- coral cover
- evenness (coral diversity)
- shelter volume, and
- abundance of juveniles
Notes
Juveniles are made relative to maximum observed juvenile density (51.8/m²) See notes for juvenile_indicator()
Arguments
rc
: Relative coral cover across all groupsevenness
: Evenness across all coral groupssv
: Shelter volume based on coral sizes and abundancesjuves
: Abundance of coral juveniles < 5 cm diameter
Returns
YAXArray[timesteps ⋅ locations ⋅ scenarios]
ADRIA.metrics._reef_fish_index
— Methodreef_fish_index(rc::AbstractArray)
-reef_fish_index(rs::ResultSet)
The Reef Fish Index (RFI) estimates fish biomass from relative coral cover.
A linear regression (developed by Dr. R. Heneghan, Queensland University of Technology) is used to indicate the relationship between coral cover and fish biomass. The regression was developed with digitized data from Figures 4a and 6b in Graham & Nash (2013; see [1]).
Values are provided ∈ [0, 1], where 1 indicates maximum fish biomass.
Note: Coral cover here is relative to coral habitable area ($k$ area).
Arguments
rc
: Relative cover
Returns
YAXArray[timesteps ⋅ locations ⋅ scenarios], values in kg/km²
References
- Graham, N.A.J., Nash, K.L., 2013.
The importance of structural complexity in coral reef ecosystems. Coral Reefs 32, 315–326. https://doi.org/10.1007/s00338-012-0984-y
ADRIA.metrics._reef_tourism_index
— Methodreef_tourism_index(rc::AbstractArray, evenness::AbstractArray, sv::AbstractArray, juves::AbstractArray, intcp_u::Vector)::AbstractArray
-reef_tourism_index(rs::ResultSet; intcp_u::Bool=false)::AbstractArray
Estimate tourism index.
Note: This metric assumes all inputs (relative cover, evenness, shelter volume, coral juveniles) are scaled between 0 and 1. For evenness, shelter volume and coral juveniles, a value of 1 may represent a theoretical maximum.
Arguments
rc
: Relative coral cover across all groupsevenness
: Evenness across all coral groupssv
: Shelter volume based on coral sizes and abundancesjuves
: Abundance of coral juveniles < 5 cm diameterintcp_u
: ?
ADRIA.metrics._relative_cover
— Methodrelative_cover(X::AbstractArray{<:Real})::AbstractArray{<:Real}
-relative_cover(rs::ResultSet)::AbstractArray{<:Real}
Indicate coral cover relative to available hard substrate ($k$ area).
Arguments
X
: Matrix with dimensions (ntimesteps, nfunctionalgroups * nsize_classes,
n_locations) of raw model results (coral cover relative to available space)
Returns
Coral cover [0 - 1], relative to available $k$ area for a given location.
ADRIA.metrics._relative_juveniles
— Methodrelative_juveniles(X::AbstractArray{T,3}, coral_spec::DataFrame)::AbstractArray{T,2} where {T<:Real}
-relative_juveniles(rs::ResultSet)::AbstractArray{<:Real,2}
Juvenile coral cover relative to total site area.
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations)
coral_spec
: Coral spec DataFrame
ADRIA.metrics._relative_loc_taxa_cover
— Methodrelative_loc_taxa_cover(X::AbstractArray{T}, k_area::Vector{T}, n_groups::Int64)::AbstractArray{T,3} where {T<:Real}
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations)
k_area
: The coral habitable area.n_groups
: Number of function coral groups.
Returns
Coral cover, grouped by taxa for the given scenario, for each timestep and location, relative to location k area.
ADRIA.metrics._relative_shelter_volume
— Methodrelative_shelter_volume(X::AbstractArray{T,3}, k_area::Vector{T}, inputs::DataFrameRow)::AbstractArray{T} where {T<:Real}
+absolute_shelter_volume(rs::ResultSet)
Provide indication of shelter volume in volume of cubic meters.
The metric applies log-log linear models developed by Urbina-Barreto et al., [1] which uses colony diameter and planar area (2D metrics) to estimate shelter volume (a 3D metric).
Arguments
X
: raw resultsk_area
: area in m^2 for each sitemax_cover
: maximum possible coral cover for each site (in percentage of loc_area)inputs
: DataFrame of scenario inputs
References
- Urbina-Barreto, I., Chiroleu, F., Pinel, R., Fréchon, L., Mahamadaly, V., Elise, S., Kulbicki, M., Quod, J.-P., Dutrieux, E., Garnier, R., Henrich Bruggemann, J., Penin, L., & Adjeroud, M. (2021). Quantifying the shelter capacity of coral reefs using photogrammetric 3D modeling: From colonies to reefscapes. Ecological Indicators, 121, 107151. https://doi.org/10.1016/j.ecolind.2020.107151
ADRIA.metrics._collate_ranked_locs
— Method_collate_ranked_locs(data::YAXArray)::Matrix{Int64}
Collates number of ranked locations.
ADRIA.metrics._collate_ranks
— Method_collate_ranks(rs, selected)
Collates ranks into seed/fog ranking results into a common structure.
ADRIA.metrics._colony_Lcm2_to_m3m2
— Method_colony_Lcm2_to_m3m2(inputs::DataFrame)::Tuple
+_colony_Lcm2_to_m3m2(inputs::YAXArray)::Tuple{Vector{Float64},Vector{Float64}}
Helper function to convert coral colony values from Litres/cm² to m³/m²
Arguments
inputs
: Scenario values for the simulation
Returns
Tuple : Assumed colony volume (m³/m²) for each species/size class, theoretical maximum for each species/size class
References
- Aston Eoghan A., Duce Stephanie, Hoey Andrew S., Ferrari Renata (2022). A Protocol for Extracting Structural Metrics From 3D Reconstructions of Corals. Frontiers in Marine Science, 9. https://doi.org/10.3389/fmars.2022.854395
ADRIA.metrics._coral_evenness
— Methodcoral_evenness(r_taxa_cover::AbstractArray{T})::AbstractArray{T} where {T<:Real}
+coral_evenness(rs::ResultSet)::AbstractArray{T} where {T}
Calculates evenness across functional coral groups in ADRIA as a diversity metric. Inverse Simpsons diversity indicator.
References
- Hill, M. O. (1973).
Diversity and Evenness: A Unifying Notation and Its Consequences. Ecology, 54(2), 427-432. https://doi.org/10.2307/1934352
ADRIA.metrics._get_ranks
— Method_get_ranks(rs::ResultSet, intervention::Int64; kwargs...)
Extracts results for a specific intervention (:seed or :fog)
ADRIA.metrics._juvenile_indicator
— Methodjuvenile_indicator(X::AbstractArray{T,3}, coral_spec::DataFrame, k_area::Vector{Float64})::AbstractArray{T,2} where {T<:Real}
+juvenile_indicator(rs::ResultSet)::AbstractArray{<:Real,2}
Indicator for juvenile density (0 - 1), where 1 indicates the maximum theoretical density for juveniles have been achieved.
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations).
coral_spec
: Coral spec DataFrame.k_area
: The coral habitable area.
Notes
Maximum density is 51.8 juveniles / m², where juveniles are defined as < 5cm diameter. See email correspondence from: Dr. A Thompson; to: Dr. K. Anthony Subject: RE: Max density of juvenile corals on the GBR Sent: Friday, 14 October 2022 2:58 PM
ADRIA.metrics._max_juvenile_area
— Function_max_juvenile_area(coral_params::DataFrame, max_juv_density::Float64=51.8)
Calculate the maximum possible area that can be covered by juveniles for a given m².
ADRIA.metrics._reef_condition_index
— Methodreef_condition_index(rc::AbstractArray, evenness::AbstractArray, sv::AbstractArray, juves::AbstractArray; threshold=2)::AbstractArray
+reef_condition_index(rs::ResultSet)::AbstractArray{<:Real}
Estimates a Reef Condition Index (RCI) providing a single value that indicates the condition of a reef across four metrics:
- coral cover
- evenness (coral diversity)
- shelter volume, and
- abundance of juveniles
Notes
Juveniles are made relative to maximum observed juvenile density (51.8/m²) See notes for juvenile_indicator()
Arguments
rc
: Relative coral cover across all groupsevenness
: Evenness across all coral groupssv
: Shelter volume based on coral sizes and abundancesjuves
: Abundance of coral juveniles < 5 cm diameter
Returns
YAXArray[timesteps ⋅ locations ⋅ scenarios]
ADRIA.metrics._reef_fish_index
— Methodreef_fish_index(rc::AbstractArray)
+reef_fish_index(rs::ResultSet)
The Reef Fish Index (RFI) estimates fish biomass from relative coral cover.
A linear regression (developed by Dr. R. Heneghan, Queensland University of Technology) is used to indicate the relationship between coral cover and fish biomass. The regression was developed with digitized data from Figures 4a and 6b in Graham & Nash (2013; see [1]).
Values are provided ∈ [0, 1], where 1 indicates maximum fish biomass.
Note: Coral cover here is relative to coral habitable area ($k$ area).
Arguments
rc
: Relative cover
Returns
YAXArray[timesteps ⋅ locations ⋅ scenarios], values in kg/km²
References
- Graham, N.A.J., Nash, K.L., 2013.
The importance of structural complexity in coral reef ecosystems. Coral Reefs 32, 315–326. https://doi.org/10.1007/s00338-012-0984-y
ADRIA.metrics._reef_tourism_index
— Methodreef_tourism_index(rc::AbstractArray, evenness::AbstractArray, sv::AbstractArray, juves::AbstractArray, intcp_u::Vector)::AbstractArray
+reef_tourism_index(rs::ResultSet; intcp_u::Bool=false)::AbstractArray
Estimate tourism index.
Note: This metric assumes all inputs (relative cover, evenness, shelter volume, coral juveniles) are scaled between 0 and 1. For evenness, shelter volume and coral juveniles, a value of 1 may represent a theoretical maximum.
Arguments
rc
: Relative coral cover across all groupsevenness
: Evenness across all coral groupssv
: Shelter volume based on coral sizes and abundancesjuves
: Abundance of coral juveniles < 5 cm diameterintcp_u
: ?
ADRIA.metrics._relative_cover
— Methodrelative_cover(X::AbstractArray{<:Real})::AbstractArray{<:Real}
+relative_cover(rs::ResultSet)::AbstractArray{<:Real}
Indicate coral cover relative to available hard substrate ($k$ area).
Arguments
X
: Matrix with dimensions (ntimesteps, nfunctionalgroups * nsize_classes,
n_locations) of raw model results (coral cover relative to available space)
Returns
Coral cover [0 - 1], relative to available $k$ area for a given location.
ADRIA.metrics._relative_juveniles
— Methodrelative_juveniles(X::AbstractArray{T,3}, coral_spec::DataFrame)::AbstractArray{T,2} where {T<:Real}
+relative_juveniles(rs::ResultSet)::AbstractArray{<:Real,2}
Juvenile coral cover relative to total site area.
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations)
coral_spec
: Coral spec DataFrame
ADRIA.metrics._relative_loc_taxa_cover
— Methodrelative_loc_taxa_cover(X::AbstractArray{T}, k_area::Vector{T}, n_groups::Int64)::AbstractArray{T,3} where {T<:Real}
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations)
k_area
: The coral habitable area.n_groups
: Number of function coral groups.
Returns
Coral cover, grouped by taxa for the given scenario, for each timestep and location, relative to location k area.
ADRIA.metrics._relative_shelter_volume
— Methodrelative_shelter_volume(X::AbstractArray{T,3}, k_area::Vector{T}, inputs::DataFrameRow)::AbstractArray{T} where {T<:Real}
relative_shelter_volume(X::AbstractArray{T,3}, k_area::Vector{T}, inputs::DataFrame)::AbstractArray{T} where {T<:Real}
relative_shelter_volume(X::AbstractArray{T,3}, k_area::Vector{T}, inputs::YAXArray)::AbstractArray{T} where {T<:Real}
relative_shelter_volume(X::AbstractArray{T,4}, k_area::Vector{T}, inputs::DataFrameRow)::AbstractArray{T} where {T<:Real}
@@ -21,13 +21,13 @@
relative_shelter_volume(rs::ResultSet)
Provide indication of shelter volume relative to theoretical maximum volume for the area covered by coral.
The metric applies log-log linear models developed by Urbina-Barreto et al., [1] which uses colony diameter and planar area (2D metrics) to estimate shelter volume (a 3D metric).
\[RSV = \begin{cases} TASV / MSV & MSV > 0, \\ 0 & \text{otherwise} -\end{cases}\]
where $TASV$ represents Total Absolute Shelter Volume and $MSV$ represents the maximum shelter volume possible.
Arguments
X
: raw resultsk_area
: area in m^2 for each sitescens
: DataFrame of scenario inputs
Returns
Shelter volume relative to a theoretical maximum volume for the available $k$ area.
References
- Urbina-Barreto, I., Chiroleu, F., Pinel, R., Fréchon, L., Mahamadaly, V., Elise, S.,
Kulbicki, M., Quod, J.-P., Dutrieux, E., Garnier, R., Henrich Bruggemann, J., Penin, L., & Adjeroud, M. (2021). Quantifying the shelter capacity of coral reefs using photogrammetric 3D modeling: From colonies to reefscapes. Ecological Indicators, 121, 107151. https://doi.org/10.1016/j.ecolind.2020.107151
ADRIA.metrics._relative_taxa_cover
— Methodrelative_taxa_cover(X::AbstractArray{<:Real}, k_area::Vector{<:Real}, n_groups::Int64)::AbstractArray{<:Real,2}
-relative_taxa_cover(rs::ResultSet)::AbstractArray{<:Real,2}
Relative coral cover grouped by taxa/species sumed up across all locations.
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations).
k_area
: The coral habitable area.n_groups
: Number of function coral groups.
Returns
Coral cover, grouped by taxa for the given scenario, summed up across all locations, relative to total k area.
ADRIA.metrics._scenario_absolute_juveniles
— Methodscenario_absolute_juveniles(data::YAXArray, coral_spec::DataFrame, k_area::AbstractVector{<:Real}; kwargs...)::AbstractArray{<:Real}
-scenario_absolute_juveniles(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean absolute juvenile population for each scenario for the entire domain.
Arguments
X
: Raw data for a single scenario.coral_spec
: Coral spec DataFrame.k_area
: K_area.rs
: Resultset.
ADRIA.metrics._scenario_asv
— Methodscenario_asv(sv::YAXArray; kwargs...)::AbstractArray{<:Real}
-scenario_asv(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean absolute shelter volumes for each scenario for the entire domain.
Arguments
asv
: Absolute shelter volume.rs
: Resultset.
ADRIA.metrics._scenario_evenness
— Methodscenario_evenness(ev::YAXArray; kwargs...)::AbstractArray{<:Real}
-scenario_evenness(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean coral evenness for each scenario for the entire domain.
ADRIA.metrics._scenario_juvenile_indicator
— Methodscenario_juvenile_indicator(data::YAXArray, coral_spec::DataFrame, k_area::AbstractVector{<:Real}; kwargs...)::AbstractArray{<:Real}
-scenario_juvenile_indicator(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Determine juvenile indicator ∈ [0, 1], where 1 indicates maximum mean juvenile density (51.8) has been achieved.
Arguments
X
: Raw data for a single scenario.coral_spec
: Coral spec DataFrame.k_area
: K_area.rs
: Resultset.
ADRIA.metrics._scenario_rci
— Methodscenario_rci(rci::YAXArray, tac::YAXArray; kwargs...)
-scenario_rci(rs::ResultSet; kwargs...)
Extract the total populated area of locations with Reef Condition Index of "Good" or higher for each scenario for the entire domain.
ADRIA.metrics._scenario_relative_cover
— Methodscenario_relative_cover(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean relative coral cover for each scenario for the entire domain.
ADRIA.metrics._scenario_relative_juveniles
— Methodscenario_relative_juveniles(X::YAXArray{<:Real,3}, coral_spec::DataFrame, k_area::AbstractVector{<:Real}; kwargs...)::AbstractArray{<:Real}
+\end{cases}\]where $TASV$ represents Total Absolute Shelter Volume and $MSV$ represents the maximum shelter volume possible.
Arguments
X
: raw resultsk_area
: area in m^2 for each sitescens
: DataFrame of scenario inputs
Returns
Shelter volume relative to a theoretical maximum volume for the available $k$ area.
References
- Urbina-Barreto, I., Chiroleu, F., Pinel, R., Fréchon, L., Mahamadaly, V., Elise, S.,
Kulbicki, M., Quod, J.-P., Dutrieux, E., Garnier, R., Henrich Bruggemann, J., Penin, L., & Adjeroud, M. (2021). Quantifying the shelter capacity of coral reefs using photogrammetric 3D modeling: From colonies to reefscapes. Ecological Indicators, 121, 107151. https://doi.org/10.1016/j.ecolind.2020.107151
ADRIA.metrics._relative_taxa_cover
— Methodrelative_taxa_cover(X::AbstractArray{<:Real}, k_area::Vector{<:Real}, n_groups::Int64)::AbstractArray{<:Real,2}
+relative_taxa_cover(rs::ResultSet)::AbstractArray{<:Real,2}
Relative coral cover grouped by taxa/species sumed up across all locations.
Arguments
X
: Raw model results for a single scenario. Dimensions (ntimesteps, ngroup_sizes,
n_locations).
k_area
: The coral habitable area.n_groups
: Number of function coral groups.
Returns
Coral cover, grouped by taxa for the given scenario, summed up across all locations, relative to total k area.
ADRIA.metrics._scenario_absolute_juveniles
— Methodscenario_absolute_juveniles(data::YAXArray, coral_spec::DataFrame, k_area::AbstractVector{<:Real}; kwargs...)::AbstractArray{<:Real}
+scenario_absolute_juveniles(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean absolute juvenile population for each scenario for the entire domain.
Arguments
X
: Raw data for a single scenario.coral_spec
: Coral spec DataFrame.k_area
: K_area.rs
: Resultset.
ADRIA.metrics._scenario_asv
— Methodscenario_asv(sv::YAXArray; kwargs...)::AbstractArray{<:Real}
+scenario_asv(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean absolute shelter volumes for each scenario for the entire domain.
Arguments
asv
: Absolute shelter volume.rs
: Resultset.
ADRIA.metrics._scenario_evenness
— Methodscenario_evenness(ev::YAXArray; kwargs...)::AbstractArray{<:Real}
+scenario_evenness(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean coral evenness for each scenario for the entire domain.
ADRIA.metrics._scenario_juvenile_indicator
— Methodscenario_juvenile_indicator(data::YAXArray, coral_spec::DataFrame, k_area::AbstractVector{<:Real}; kwargs...)::AbstractArray{<:Real}
+scenario_juvenile_indicator(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Determine juvenile indicator ∈ [0, 1], where 1 indicates maximum mean juvenile density (51.8) has been achieved.
Arguments
X
: Raw data for a single scenario.coral_spec
: Coral spec DataFrame.k_area
: K_area.rs
: Resultset.
ADRIA.metrics._scenario_rci
— Methodscenario_rci(rci::YAXArray, tac::YAXArray; kwargs...)
+scenario_rci(rs::ResultSet; kwargs...)
Extract the total populated area of locations with Reef Condition Index of "Good" or higher for each scenario for the entire domain.
ADRIA.metrics._scenario_relative_cover
— Methodscenario_relative_cover(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean relative coral cover for each scenario for the entire domain.
ADRIA.metrics._scenario_relative_juveniles
— Methodscenario_relative_juveniles(X::YAXArray{<:Real,3}, coral_spec::DataFrame, k_area::AbstractVector{<:Real}; kwargs...)::AbstractArray{<:Real}
scenario_relative_juveniles(rs::ResultSet; kwargs...)::YAXArray
Calculate the mean relative juvenile population for each scenario for the entire domain.
Arguments
X
: Raw data for a single scenario.rs
: Resultset.coral_spec
: Coral spec DataFrame.k_area
: K_area.
Examples
num_scens = 2^5
scens = ADRIA.sample(dom, num_scens)
@@ -35,10 +35,10 @@
_k_area = site_k_area(dom)
# X contains raw coral cover results for a single scenario
-ADRIA.metrics.scenario_relative_juveniles(X, _coral_spec, _k_area)
ADRIA.metrics._scenario_rfi
— Methodscenariorfi(rfi::YAXArray; kwargs...) scenariorfi(rs::ResultSet; kwargs...)
Calculate the mean Reef Fish Index (RFI) for each scenario for the entire domain.
ADRIA.metrics._scenario_rsv
— Methodscenario_rsv(sv::YAXArray; kwargs...)::AbstractArray{<:Real}
-scenario_rsv(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean relative shelter volumes for each scenario for the entire domain.
ADRIA.metrics._scenario_rti
— Methodscenario_rti(rti::YAXArray; kwargs...)
-scenario_rti(rs::ResultSet; kwargs...)
Calculate the mean Reef Tourism Index (RTI) for each scenario for the entire domain.
ADRIA.metrics._scenario_total_cover
— Methodscenario_total_cover(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean absolute coral for each scenario for the entire domain.
Arguments
tac
: Total absolute coverrs
: ResultSet
ADRIA.metrics._shelter_species_loop!
— Methodshelterspeciesloop!(X::YAXArray, ASV::YAXArray, nspecies::Int64, colonyvolm3perm2::V, karea::V) where {V<:AbstractVector{<:Float64}}
Helper method to calculate absolute shelter volume metric across each species/size class for a given scenario.
Arguments
X
: raw results (proportional coral cover relative to full site area)ASV
: matrix to hold shelter volume resultsnspecies
: number of species (taxa and size classes) consideredscen
: scenario number to calculate metric forcolony_vol_m3_per_m2
: estimated cubic volume per m² of coverage for each species/size classk_area
: habitable area of site in m²
ADRIA.metrics._shelter_species_loop
— Method_shelter_species_loop(X::AbstractArray{T1,3}, n_species::Int64, colony_vol_m3_per_m2::Array{F}, max_colony_vol_m3_per_m2::Array{F}, k_area::Array{F})::YAXArray where {T1<:Real,F<:Float64}
Helper method to calculate relative shelter volume metric across each species/size class for a given scenario.
Note: Species dimension is an amalgamation of taxa and size class. e.g., X[species=1:6] is Taxa 1, size classes 1-6; X[species=7:12] is Taxa 2, size class 1-6, etc.
Arguments
X
: raw results (proportional coral cover relative to full site area)n_group_and_size
: number of species (taxa and size classes) consideredcolony_vol_m3_per_m2
: estimated cubic volume per m² of coverage for each species/size classmax_colony_vol_m3_per_m2
: theoretical maximum volume per m² of coverage for each taxak_area
: habitable area of site in m² (i.e.,k
area)
ADRIA.metrics._total_absolute_cover
— Methodtotal_absolute_cover(X::AbstractArray{<:Real}, k_area::Vector{<:Real})::AbstractArray{<:Real}
-total_absolute_cover(rs::ResultSet)::AbstractArray{<:Real}
The Total Absolute Coral Cover. Sum of proportional area taken up by all corals, multiplied by total site area.
Arguments
relative_cover
: Array with relative_coverk_area
: Site areas, with sites following the same order as given indicated in X.
Returns
Absolute coral cover for a given location in m².
ADRIA.metrics.axes_units
— Methodaxes_units(axes_names::Union{Vector{Symbol},Tuple})::Tuple
Get units for each metric axis.
ADRIA.metrics.call_metric
— Methodcall_metric(metric::Union{Function,Metric}, data::YAXArray, args...; kwargs...)
Convenience method that slices the data in the specified manner.
Arguments
metric
: Function, the metric function to apply to "raw" data.data
: YAXArray, data to pass intometric
args
: Additional positional arguments to pass intometric
kwargs
: Additional keyword arguments to pass intoslice_results
dims
: dummy keyword argument, not used but defined to allow use with other methods
ADRIA.metrics.dims
— Methoddims(m::Metric)::Tuple
Get dimension names for a given outcome/metric.
ADRIA.metrics.dominates
— Methoddominates(x::Vector{<:Real}, y::Vector{<:Real})::Vector
Adapted from: https://discourse.julialang.org/t/fast-optimized-non-dominated-sorting-algorithms/86793/7
Original function name is dominates2()
ADRIA.metrics.ensemble_loc_difference
— Methodensemble_loc_difference(outcome::YAXArray{T,3}, scens::DataFrame; agg_metric::Union{Function,AbstractFloat}=median, diff_target=:guided, conf::Float64=0.95, rng::AbstractRNG=Random.GLOBAL_RNG)::YAXArray where {T}
Mean bootstrapped difference (counterfactual - target) between some outcome aggregated for each location.
Arguments
outcome
: Metric outcome with dimensions (:timesteps, :locations, :scenarios).scens
: Scenarios DataFrame.agg_metric
: Metric used to aggregate scenarios when comparing between counterfactual and
target. If it is an AbstractFloat
between 0 and 1, it uses the bs_metric
-th quantile. Defaults to median
.
diff_target
: Target group of scenarios to compare with. Valid options are:guided
and
:unguided
. Defaults to :guided
conf
: Percentile used for the confidence interval. Defaults to 0.95.rng
: Pseudorandom number generator.
Example
# Load domain
+ADRIA.metrics.scenario_relative_juveniles(X, _coral_spec, _k_area)
ADRIA.metrics._scenario_rfi
— Methodscenariorfi(rfi::YAXArray; kwargs...) scenariorfi(rs::ResultSet; kwargs...)
Calculate the mean Reef Fish Index (RFI) for each scenario for the entire domain.
ADRIA.metrics._scenario_rsv
— Methodscenario_rsv(sv::YAXArray; kwargs...)::AbstractArray{<:Real}
+scenario_rsv(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean relative shelter volumes for each scenario for the entire domain.
ADRIA.metrics._scenario_rti
— Methodscenario_rti(rti::YAXArray; kwargs...)
+scenario_rti(rs::ResultSet; kwargs...)
Calculate the mean Reef Tourism Index (RTI) for each scenario for the entire domain.
ADRIA.metrics._scenario_total_cover
— Methodscenario_total_cover(rs::ResultSet; kwargs...)::AbstractArray{<:Real}
Calculate the mean absolute coral for each scenario for the entire domain.
Arguments
tac
: Total absolute coverrs
: ResultSet
ADRIA.metrics._shelter_species_loop!
— Methodshelterspeciesloop!(X::YAXArray, ASV::YAXArray, nspecies::Int64, colonyvolm3perm2::V, karea::V) where {V<:AbstractVector{<:Float64}}
Helper method to calculate absolute shelter volume metric across each species/size class for a given scenario.
Arguments
X
: raw results (proportional coral cover relative to full site area)ASV
: matrix to hold shelter volume resultsnspecies
: number of species (taxa and size classes) consideredscen
: scenario number to calculate metric forcolony_vol_m3_per_m2
: estimated cubic volume per m² of coverage for each species/size classk_area
: habitable area of site in m²
ADRIA.metrics._shelter_species_loop
— Method_shelter_species_loop(X::AbstractArray{T1,3}, n_species::Int64, colony_vol_m3_per_m2::Array{F}, max_colony_vol_m3_per_m2::Array{F}, k_area::Array{F})::YAXArray where {T1<:Real,F<:Float64}
Helper method to calculate relative shelter volume metric across each species/size class for a given scenario.
Note: Species dimension is an amalgamation of taxa and size class. e.g., X[species=1:6] is Taxa 1, size classes 1-6; X[species=7:12] is Taxa 2, size class 1-6, etc.
Arguments
X
: raw results (proportional coral cover relative to full site area)n_group_and_size
: number of species (taxa and size classes) consideredcolony_vol_m3_per_m2
: estimated cubic volume per m² of coverage for each species/size classmax_colony_vol_m3_per_m2
: theoretical maximum volume per m² of coverage for each taxak_area
: habitable area of site in m² (i.e.,k
area)
ADRIA.metrics._total_absolute_cover
— Methodtotal_absolute_cover(X::AbstractArray{<:Real}, k_area::Vector{<:Real})::AbstractArray{<:Real}
+total_absolute_cover(rs::ResultSet)::AbstractArray{<:Real}
The Total Absolute Coral Cover. Sum of proportional area taken up by all corals, multiplied by total site area.
Arguments
relative_cover
: Array with relative_coverk_area
: Site areas, with sites following the same order as given indicated in X.
Returns
Absolute coral cover for a given location in m².
ADRIA.metrics.axes_units
— Methodaxes_units(axes_names::Union{Vector{Symbol},Tuple})::Tuple
Get units for each metric axis.
ADRIA.metrics.call_metric
— Methodcall_metric(metric::Union{Function,Metric}, data::YAXArray, args...; kwargs...)
Convenience method that slices the data in the specified manner.
Arguments
metric
: Function, the metric function to apply to "raw" data.data
: YAXArray, data to pass intometric
args
: Additional positional arguments to pass intometric
kwargs
: Additional keyword arguments to pass intoslice_results
dims
: dummy keyword argument, not used but defined to allow use with other methods
ADRIA.metrics.dims
— Methoddims(m::Metric)::Tuple
Get dimension names for a given outcome/metric.
ADRIA.metrics.dominates
— Methoddominates(x::Vector{<:Real}, y::Vector{<:Real})::Vector
Adapted from: https://discourse.julialang.org/t/fast-optimized-non-dominated-sorting-algorithms/86793/7
Original function name is dominates2()
ADRIA.metrics.ensemble_loc_difference
— Methodensemble_loc_difference(outcome::YAXArray{T,3}, scens::DataFrame; agg_metric::Union{Function,AbstractFloat}=median, diff_target=:guided, conf::Float64=0.95, rng::AbstractRNG=Random.GLOBAL_RNG)::YAXArray where {T}
Mean bootstrapped difference (counterfactual - target) between some outcome aggregated for each location.
Arguments
outcome
: Metric outcome with dimensions (:timesteps, :locations, :scenarios).scens
: Scenarios DataFrame.agg_metric
: Metric used to aggregate scenarios when comparing between counterfactual and
target. If it is an AbstractFloat
between 0 and 1, it uses the bs_metric
-th quantile. Defaults to median
.
diff_target
: Target group of scenarios to compare with. Valid options are:guided
and
:unguided
. Defaults to :guided
conf
: Percentile used for the confidence interval. Defaults to 0.95.rng
: Pseudorandom number generator.
Example
# Load domain
dom = ADRIA.load_domain(path_to_domain)
# Create scenarios
@@ -59,8 +59,8 @@
# Plot maps of difference to the counterfactual
ADRIA.viz.map(rs, gd_res[summary=At(:agg_value)]; diverging=true)
-ADRIA.viz.map(rs, ug_res[summary=At(:agg_value)]; diverging=true)
Returns
Vector with bootstrapped difference (counterfactual - guided) for each location.
ADRIA.metrics.fill_axes_metadata!
— Methodfill_axes_metadata!(outcomes::YAXArray)::Nothing
Fill outcomes axes metadata.
ADRIA.metrics.fill_metadata!
— Methodfill_metadata!(outcomes::YAXArray{T,N,A}, metric::Metric)::YAXArray{T,N,A} where {T,N,A}
-fill_metadata!(outcomes::YAXArray{T,N,A}, metadata::Dict{Symbol,Any})::YAXArray{T,N,A} where {T,N,A}
Fill outcomes YAXArray metadata (properties
attribute).
Arguments
outcomes
: YAXArray datacube of metric outcomes.metric
: ADRIA.metrics.Metric object.metadata
: Dict to be used to fill outcomes metrics metadata.
ADRIA.metrics.fog_ranks
— Methodfog_ranks(rs::ResultSet; kwargs...)
Arguments
- rs : ResultSet
- kwargs : named dimensions to slice across
Returns
YAXArray[timesteps, sites, scenarios]
Example
ADRIA.metrics.fog_ranks(rs; timesteps=1:10, scenarios=3:5)
ADRIA.metrics.loc_trajectory
— Methodloc_trajectory(metric, data::YAXArray{D,T,N,A})::YAXArray where {D,T,N,A}
Alias for summarize(data, [:scenarios], metric). Collate trajectory for each location.
Examples
using Statistics
+ADRIA.viz.map(rs, ug_res[summary=At(:agg_value)]; diverging=true)
Returns
Vector with bootstrapped difference (counterfactual - guided) for each location.
ADRIA.metrics.fill_axes_metadata!
— Methodfill_axes_metadata!(outcomes::YAXArray)::Nothing
Fill outcomes axes metadata.
ADRIA.metrics.fill_metadata!
— Methodfill_metadata!(outcomes::YAXArray{T,N,A}, metric::Metric)::YAXArray{T,N,A} where {T,N,A}
+fill_metadata!(outcomes::YAXArray{T,N,A}, metadata::Dict{Symbol,Any})::YAXArray{T,N,A} where {T,N,A}
Fill outcomes YAXArray metadata (properties
attribute).
Arguments
outcomes
: YAXArray datacube of metric outcomes.metric
: ADRIA.metrics.Metric object.metadata
: Dict to be used to fill outcomes metrics metadata.
ADRIA.metrics.fog_ranks
— Methodfog_ranks(rs::ResultSet; kwargs...)
Arguments
- rs : ResultSet
- kwargs : named dimensions to slice across
Returns
YAXArray[timesteps, sites, scenarios]
Example
ADRIA.metrics.fog_ranks(rs; timesteps=1:10, scenarios=3:5)
ADRIA.metrics.loc_trajectory
— Methodloc_trajectory(metric, data::YAXArray{D,T,N,A})::YAXArray where {D,T,N,A}
Alias for summarize(data, [:scenarios], metric). Collate trajectory for each location.
Examples
using Statistics
rs = ADRIA.load_results("some results")
tac = ADRIA.metrics.total_absolute_cover(rs)
@@ -77,27 +77,27 @@
#75×216 YAXArray{Float64,2} with dimensions:
# Dim{:timesteps} Categorical{Any} Any[1, 2, …, 74, 75] Unordered,
# Dim{:locations} Categorical{Any} Any[1, 2, …, 215, 216] Unordered
-#Total size: 126.56 KB
Arguments
- metric : Any function (nominally from the Statistics package) to be applied to
data
- data : Data set to apply metric to
Returns
2D array of $T ⋅ S$, where $T$ is total number of time steps and $S$ is number of locations
ADRIA.metrics.metadata
— Methodmetadata(outcomes::YAXArray)::Dict{Symbol,Any}
Helper function to extract metadata from YAXArrays.
ADRIA.metrics.metric_label
— Methodmetric_label(m::Metric)::String
+#Total size: 126.56 KB
Arguments
- metric : Any function (nominally from the Statistics package) to be applied to
data
- data : Data set to apply metric to
Returns
2D array of $T ⋅ S$, where $T$ is total number of time steps and $S$ is number of locations
ADRIA.metrics.metadata
— Methodmetadata(outcomes::YAXArray)::Dict{Symbol,Any}
Helper function to extract metadata from YAXArrays.
ADRIA.metrics.metric_label
— Methodmetric_label(m::Metric)::String
metric_label(f::Function, unit::String)
Return name of metric in the format: "Title Case [Unit]", suitable for use as a label.
Example
m_label = metric_label(scenario_total_cover)
-# "Scenario Total Cover [m²]"
ADRIA.metrics.n_fog_locations
— Methodn_fog_locations(rs::ResultSet; kwargs...)::Matrix{Int64}
Determine the number of locations fogged at each time step, for each scenario.
Returns
YAXArray[timesteps ⋅ scenarios] indicating the number of locations fogged at each time step.
ADRIA.metrics.n_seed_locations
— Methodn_seed_locations(rs::ResultSet; kwargs...)::Matrix{Int64}
Determine the number of locations seeded at each time step, for each scenario.
Returns
YAXArray[timesteps ⋅ scenarios] indicating the number of locations seeded at each time step.
ADRIA.metrics.nds
— Functionnds(X::AbstractArray{<:Real}, dist::Int64=0)::Vector{Vector{<:Int}}
Naive n-dimensional non-dominated sorting.
Adapted from: https://discourse.julialang.org/t/fast-optimized-non-dominated-sorting-algorithms/86793/7
Original function name is nds4()
Arguments
X : outcomes, where rows are scenarios and columns are metric results. dist : distance from front, where 0 is on the frontier.
Returns
Vector of Vectors with row indices for each dist
from frontier, where 0 is on the frontier.
ADRIA.metrics.per_loc
— Methodper_loc(metric, data::YAXArray{D,T,N,A})::YAXArray where {D,T,N,A}
Alias for summarize(data, [:scenarios, :timesteps], metric). Get metric results applied to the location-level at indicated time (or across timesteps).
Arguments
- metric : Any function (nominally from the Statistics package) to be applied to
data
- data : Data set to apply metric to
- timesteps : timesteps to apply
metric
across
Returns
Named Vector of $N$ elements, where $N$ is the number of locations.
ADRIA.metrics.scenario_outcomes
— Methodscenario_outcomes(rs::ResultSet, metrics::Vector{Metric})::YAXArray
Get outcomes for a given list of metrics and a result set.
Arguments
rs
: ResultSetmetrics
: Vector of scenario Metrics (the ones that start withscenario_
)
Returns
YAXArray with (:timesteps, :scenarios, :outcomes)
Examples
metrics::Vector{ADRIA.metrics.Metric} = [
+# "Scenario Total Cover [m²]"
ADRIA.metrics.n_fog_locations
— Methodn_fog_locations(rs::ResultSet; kwargs...)::Matrix{Int64}
Determine the number of locations fogged at each time step, for each scenario.
Returns
YAXArray[timesteps ⋅ scenarios] indicating the number of locations fogged at each time step.
ADRIA.metrics.n_seed_locations
— Methodn_seed_locations(rs::ResultSet; kwargs...)::Matrix{Int64}
Determine the number of locations seeded at each time step, for each scenario.
Returns
YAXArray[timesteps ⋅ scenarios] indicating the number of locations seeded at each time step.
ADRIA.metrics.nds
— Functionnds(X::AbstractArray{<:Real}, dist::Int64=0)::Vector{Vector{<:Int}}
Naive n-dimensional non-dominated sorting.
Adapted from: https://discourse.julialang.org/t/fast-optimized-non-dominated-sorting-algorithms/86793/7
Original function name is nds4()
Arguments
X : outcomes, where rows are scenarios and columns are metric results. dist : distance from front, where 0 is on the frontier.
Returns
Vector of Vectors with row indices for each dist
from frontier, where 0 is on the frontier.
ADRIA.metrics.per_loc
— Methodper_loc(metric, data::YAXArray{D,T,N,A})::YAXArray where {D,T,N,A}
Alias for summarize(data, [:scenarios, :timesteps], metric). Get metric results applied to the location-level at indicated time (or across timesteps).
Arguments
- metric : Any function (nominally from the Statistics package) to be applied to
data
- data : Data set to apply metric to
- timesteps : timesteps to apply
metric
across
Returns
Named Vector of $N$ elements, where $N$ is the number of locations.
ADRIA.metrics.scenario_outcomes
— Methodscenario_outcomes(rs::ResultSet, metrics::Vector{Metric})::YAXArray
Get outcomes for a given list of metrics and a result set.
Arguments
rs
: ResultSetmetrics
: Vector of scenario Metrics (the ones that start withscenario_
)
Returns
YAXArray with (:timesteps, :scenarios, :outcomes)
Examples
metrics::Vector{ADRIA.metrics.Metric} = [
ADRIA.metrics.scenario_total_cover,
ADRIA.metrics.scenario_asv,
ADRIA.metrics.scenario_absolute_juveniles,
]
# 3-dimensional Array of outcomes
-outcomes = ADRIA.metrics.scenario_outcomes(rs, metrics)
ADRIA.metrics.scenario_trajectory
— Methodscenario_trajectory(data::AbstractArray; metric=mean)::YAXArray{<:Real}
Produce scenario trajectories using the provided metric/aggregation function.
Arguments
data
: Results to aggregatemetric
: Function or Callable used to summarize data
Returns
Matrix[timesteps ⋅ scenarios]
ADRIA.metrics.seed_ranks
— Methodseed_ranks(rs::ResultSet; kwargs...)
Arguments
- rs : ResultSet
- kwargs : named dimensions to slice across
Returns
YAXArray[timesteps, sites, scenarios]
Example
ADRIA.metrics.seed_ranks(rs; timesteps=1:10, scenarios=3:5)
ADRIA.metrics.slice_results
— Methodslice_results(data::YAXArray; timesteps=(:), species=(:), locations=(:), scenarios=(:))
Slice data as indicated. Dimensions not found in target data are ignored.
ADRIA.metrics.summarize
— Methodsummarize(data::YAXArray{<:Real}, alongs_axis::Vector{Symbol}, metric::Function)::YAXArray{<:Real}
-summarize(data::YAXArray{<:Real}, alongs_axis::Vector{Symbol}, metric::Function, timesteps::Union{UnitRange,Vector{Int64},BitVector})::YAXArray{<:Real}
Apply summary metric along some axis of a data set across some or all timesteps.
Arguments
data
: Data set to apply metric to.alongs_axis
: which axis will be replaced with (:) when slicing.metric
: Any function (nominally from the Statistics package) to be applied todata
.timesteps
: timesteps to applymetric
across.
Returns
YAXArray with summary metric for the remaining axis.
ADRIA.metrics.summarize_absolute_shelter_volume
— Methodsummarize_absolute_shelter_volume(sv::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
-summarize_absolute_shelter_volume(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized coral evenness.
ADRIA.metrics.summarize_coral_evenness
— Methodsummarize_coral_evenness(raw::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
-summarize_coral_evenness(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized coral evenness.
ADRIA.metrics.summarize_raw
— Methodsummarize_raw(data::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Summarize raw data, aggregating the specified dimensions (e.g., timesteps
, scenarios
, etc.) and collapsing given dims
.
ADRIA.metrics.summarize_relative_cover
— Methodsummarize_relative_cover(rc::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
-summarize_relative_cover(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized relative cover.
ADRIA.metrics.summarize_relative_shelter_volume
— Methodsummarize_relative_shelter_volume(sv::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
-summarize_relative_shelter_volume(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized coral evenness.
ADRIA.metrics.summarize_total_cover
— Methodsummarize_total_cover(raw::YAXArray, areas::AbstractArray{<:Real}; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
-summarize_total_cover(rs::ResultSet; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized total absolute cover.
ADRIA.metrics.to_string
— Methodto_string(m::Metric)::String
Get name of metric as a string.
ADRIA.metrics.to_symbol
— Methodto_symbol(m::Metric)::String
Get name of metric as a symbol.
ADRIA.metrics.top_N_sites
— Methodtop_N_sites(rs::ResultSet; N::Int64; metric::relative_cover)
+outcomes = ADRIA.metrics.scenario_outcomes(rs, metrics)
ADRIA.metrics.scenario_trajectory
— Methodscenario_trajectory(data::AbstractArray; metric=mean)::YAXArray{<:Real}
Produce scenario trajectories using the provided metric/aggregation function.
Arguments
data
: Results to aggregatemetric
: Function or Callable used to summarize data
Returns
Matrix[timesteps ⋅ scenarios]
ADRIA.metrics.seed_ranks
— Methodseed_ranks(rs::ResultSet; kwargs...)
Arguments
- rs : ResultSet
- kwargs : named dimensions to slice across
Returns
YAXArray[timesteps, sites, scenarios]
Example
ADRIA.metrics.seed_ranks(rs; timesteps=1:10, scenarios=3:5)
ADRIA.metrics.slice_results
— Methodslice_results(data::YAXArray; timesteps=(:), species=(:), locations=(:), scenarios=(:))
Slice data as indicated. Dimensions not found in target data are ignored.
ADRIA.metrics.summarize
— Methodsummarize(data::YAXArray{<:Real}, alongs_axis::Vector{Symbol}, metric::Function)::YAXArray{<:Real}
+summarize(data::YAXArray{<:Real}, alongs_axis::Vector{Symbol}, metric::Function, timesteps::Union{UnitRange,Vector{Int64},BitVector})::YAXArray{<:Real}
Apply summary metric along some axis of a data set across some or all timesteps.
Arguments
data
: Data set to apply metric to.alongs_axis
: which axis will be replaced with (:) when slicing.metric
: Any function (nominally from the Statistics package) to be applied todata
.timesteps
: timesteps to applymetric
across.
Returns
YAXArray with summary metric for the remaining axis.
ADRIA.metrics.summarize_absolute_shelter_volume
— Methodsummarize_absolute_shelter_volume(sv::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
+summarize_absolute_shelter_volume(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized coral evenness.
ADRIA.metrics.summarize_coral_evenness
— Methodsummarize_coral_evenness(raw::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
+summarize_coral_evenness(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized coral evenness.
ADRIA.metrics.summarize_raw
— Methodsummarize_raw(data::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Summarize raw data, aggregating the specified dimensions (e.g., timesteps
, scenarios
, etc.) and collapsing given dims
.
ADRIA.metrics.summarize_relative_cover
— Methodsummarize_relative_cover(rc::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
+summarize_relative_cover(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized relative cover.
ADRIA.metrics.summarize_relative_shelter_volume
— Methodsummarize_relative_shelter_volume(sv::YAXArray; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
+summarize_relative_shelter_volume(rs::ResultSet, kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized coral evenness.
ADRIA.metrics.summarize_total_cover
— Methodsummarize_total_cover(raw::YAXArray, areas::AbstractArray{<:Real}; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
+summarize_total_cover(rs::ResultSet; kwargs...)::Dict{Symbol,AbstractArray{<:Real}}
Calculate summarized total absolute cover.
ADRIA.metrics.to_string
— Methodto_string(m::Metric)::String
Get name of metric as a string.
ADRIA.metrics.to_symbol
— Methodto_symbol(m::Metric)::String
Get name of metric as a symbol.
ADRIA.metrics.top_N_sites
— Methodtop_N_sites(rs::ResultSet; N::Int64; metric::relative_cover)
top_N_sites(data::AbstractArray{Real}, N::Int64; stat=mean)
Return the top N
sites according to the provided metric (defaulting to mean
of relative_cover
).
Arguments
- rs : ResultSet
- N : Number of best performing sites to be selected
- metric : Metric to use to order sites from best to worst, must take ResultSet as input
- stat : Summary statistic to use for comparison (default: mean)
Returns
YAXArray[:scenarios, :locations], where locations
indicates order of location ranking.
Example
ADRIA.metrics.top_N_sites(rs, 5)
ADRIA.metrics.top_N_sites(rs, 5; metric=ADRIA.metric.relative_cover)
-ADRIA.metrics.top_N_sites(rs, 5; metric=ADRIA.metric.relative_cover, stat=median)
ADRIA.metrics.top_n_seeded_sites
— Methodtop_n_seeded_sites(rs::ResultSet, n::Int64; kwargs...)
Get the top n seeded sites over time by their unique location id. Lower rank values are better (e.g., 1 = first choice)
Arguments
- rs : ResultSet
- n :
n
locations to retrieve - kwargs : dimensions to slice across
Returns
YAXArray[locations, [locid, locname, rank], scenarios]
ADRIA.metrics.trajectory_heatmap
— Methodtrajectory_heatmap(data::YAXArray)::HeatMap
Estimate heatmap of trajectories from a 2D dataset.
Arguments
- data : An N*D matrix where N is time steps and D is the scenario outcome for the given timestep in N
Returns
OnlineStats.HeatMap
ADRIA.metrics.trajectory_heatmap_data
— Methodtrajectory_heatmap_data(data::YAXArray)::Tuple{Vector{Float64},Vector{Float64},Matrix{Int64}}
Estimate heatmap of trajectories from a 2D dataset.
Arguments
- data : An N*D matrix where N is time steps and D is the scenario outcome for the given timestep in N
Returns
Tuple of xedges, yedges, and bi-dimensional histogram matrix
Base.ndims
— Methodndims(m::Metric)::Int64
Infer the number of dimensions for a given outcome/metric.
ADRIA.metrics.Metric
— Method(f::Metric)(raw, args...; kwargs...)
-(f::Metric)(rs::ResultSet, args...; kwargs...)
Makes Metric types callable with arbitary arguments that are passed to associated function.
Performance indicators
ADRIA.performance.RMSE
— MethodRoot Mean Square Error
ADRIA.performance.environmental_diversity
— Methodenvironmental_diversity(ms, inputs_i)
Obtain an indication of environmental factor diversity for a scenario set. Higher values indicate a greater of mix of environmental conditions were experienced between scenarios.
This is referred to as $E$.
Arguments
- ms : model spec
- inputs_i : inputs used for scenarios of interest
ADRIA.performance.gmd
— Methodgmd(vals::AbstractVector{<:Real})::Float64
-gmd(vals::AbstractMatrix{<:Real})
Gini's Mean Difference.
The absolute mean of all pairwise distances between elements in a given set.
References
La Haye, R., & Zizler, P. (2019). The Gini mean difference and variance. METRON, 77(1), 43-52. https://doi.org/10.1007/s40300-019-00149-2
Yitzhaki, S. (2003). Gini's Mean difference: A superior measure of variability for non-normal distributions. Metron - International Journal of Statistics, LXI(2), 285-316. https://ideas.repec.org/a/mtn/ancoec/030208.html
Kashif, M., Aslam, M., Al-Marshadi, A. H., & Jun, C.-H. (2016). Capability Indices for Non-Normal Distribution Using Gini's Mean Difference as Measure of Variability. IEEE Access, 4, 7322-7330. https://doi.org/10.1109/ACCESS.2016.2620241
ADRIA.performance.intervention_diversity
— Methodintervention_diversity(ms, inputs_i)
Obtain an indication of intervention diversity for a scenario. Higher values indicate a greater of mix of interventions options were applied.
This is referred to as $D$.
Arguments
- ms : model spec
- inputs_i : inputs used for scenarios of interest
ADRIA.performance.intervention_effort
— Methodintervention_effort(ms, inputs_i)
Obtain an indication of intervention effort for each scenario and intervention type. This is referred to as $F$.
Arguments
- ms : model spec
- inputs_i : inputs used for scenarios of interest
Returns
Matrix of s * 8
, where s
is the number of scenarios and columns are: N_seed_TA
, N_seed_CA
, N_seed_SM
, fogging
, SRM
, seed_years
, shade_years
, fog_years
ADRIA.performance.normalize
— Methodnormalize(vals::AbstractArray{<:Real})
Normalize values using feature scaling such that values are bound between 0 and 1, where 1 is equivalent to the maximum value found.
ADRIA.performance.probability
— Methodprobability(vals::AbstractArray{<:Real})
Calculate probability of individual trajectories, given a scenario ensemble $S$.
ADRIA.performance.temporal_variability
— Methodtemporal_variability(x::AbstractVector{<:Real})
+ADRIA.metrics.top_N_sites(rs, 5; metric=ADRIA.metric.relative_cover, stat=median)
ADRIA.metrics.top_n_seeded_sites
— Methodtop_n_seeded_sites(rs::ResultSet, n::Int64; kwargs...)
Get the top n seeded sites over time by their unique location id. Lower rank values are better (e.g., 1 = first choice)
Arguments
- rs : ResultSet
- n :
n
locations to retrieve - kwargs : dimensions to slice across
Returns
YAXArray[locations, [locid, locname, rank], scenarios]
ADRIA.metrics.trajectory_heatmap
— Methodtrajectory_heatmap(data::YAXArray)::HeatMap
Estimate heatmap of trajectories from a 2D dataset.
Arguments
- data : An N*D matrix where N is time steps and D is the scenario outcome for the given timestep in N
Returns
OnlineStats.HeatMap
ADRIA.metrics.trajectory_heatmap_data
— Methodtrajectory_heatmap_data(data::YAXArray)::Tuple{Vector{Float64},Vector{Float64},Matrix{Int64}}
Estimate heatmap of trajectories from a 2D dataset.
Arguments
- data : An N*D matrix where N is time steps and D is the scenario outcome for the given timestep in N
Returns
Tuple of xedges, yedges, and bi-dimensional histogram matrix
Base.ndims
— Methodndims(m::Metric)::Int64
Infer the number of dimensions for a given outcome/metric.
ADRIA.metrics.Metric
— Method(f::Metric)(raw, args...; kwargs...)
+(f::Metric)(rs::ResultSet, args...; kwargs...)
Makes Metric types callable with arbitary arguments that are passed to associated function.
Performance indicators
ADRIA.performance.RMSE
— MethodRoot Mean Square Error
ADRIA.performance.environmental_diversity
— Methodenvironmental_diversity(ms, inputs_i)
Obtain an indication of environmental factor diversity for a scenario set. Higher values indicate a greater of mix of environmental conditions were experienced between scenarios.
This is referred to as $E$.
Arguments
- ms : model spec
- inputs_i : inputs used for scenarios of interest
ADRIA.performance.gmd
— Methodgmd(vals::AbstractVector{<:Real})::Float64
+gmd(vals::AbstractMatrix{<:Real})
Gini's Mean Difference.
The absolute mean of all pairwise distances between elements in a given set.
References
La Haye, R., & Zizler, P. (2019). The Gini mean difference and variance. METRON, 77(1), 43-52. https://doi.org/10.1007/s40300-019-00149-2
Yitzhaki, S. (2003). Gini's Mean difference: A superior measure of variability for non-normal distributions. Metron - International Journal of Statistics, LXI(2), 285-316. https://ideas.repec.org/a/mtn/ancoec/030208.html
Kashif, M., Aslam, M., Al-Marshadi, A. H., & Jun, C.-H. (2016). Capability Indices for Non-Normal Distribution Using Gini's Mean Difference as Measure of Variability. IEEE Access, 4, 7322-7330. https://doi.org/10.1109/ACCESS.2016.2620241
ADRIA.performance.intervention_diversity
— Methodintervention_diversity(ms, inputs_i)
Obtain an indication of intervention diversity for a scenario. Higher values indicate a greater of mix of interventions options were applied.
This is referred to as $D$.
Arguments
- ms : model spec
- inputs_i : inputs used for scenarios of interest
ADRIA.performance.intervention_effort
— Methodintervention_effort(ms, inputs_i)
Obtain an indication of intervention effort for each scenario and intervention type. This is referred to as $F$.
Arguments
- ms : model spec
- inputs_i : inputs used for scenarios of interest
Returns
Matrix of s * 8
, where s
is the number of scenarios and columns are: N_seed_TA
, N_seed_CA
, N_seed_SM
, fogging
, SRM
, seed_years
, shade_years
, fog_years
ADRIA.performance.normalize
— Methodnormalize(vals::AbstractArray{<:Real})
Normalize values using feature scaling such that values are bound between 0 and 1, where 1 is equivalent to the maximum value found.
ADRIA.performance.probability
— Methodprobability(vals::AbstractArray{<:Real})
Calculate probability of individual trajectories, given a scenario ensemble $S$.
ADRIA.performance.temporal_variability
— Methodtemporal_variability(x::AbstractVector{<:Real})
temporal_variability(x::AbstractArray{<:Real, 2})
temporal_variability(x::AbstractArray{<:Real}, func_or_data...)
The V meta-metric.
As a meta-metric, it can be applied to any combination of metrics (including itself), assuming $x$ is bound between 0 and 1. If this is not the case, consider normalizing values first.
Examples
# Apply V to a time series
julia> temporal_variability(rand(50))
@@ -110,14 +110,14 @@
# Where the argument is an array and not a function, the data is used directly
# and so it is assumed all matrices are of the same size and shape.
julia> temporal_variability(x, temporal_variabilty, temporal_variability(P(x)))
-julia> temporal_variability(x, temporal_variabilty, P(x), D(x), E(x))
Sensitivity
ADRIA.sensitivity._category_bins
— Method_category_bins(foi_spec::DataFrame)::Int64
Get number of bins for categorical variables.
Arguments
foi_spec
: Model specification for factors of interest
Returns
Number of bins relevant to the factor of interest
ADRIA.sensitivity._create_seq_store
— Method_create_seq_store(model_spec::DataFrame, unordered_cat::Vector{Symbol}, S::Int64)::Dict{Symbol,Vector{Float64}}
Get stored bin sequences for each factor type.
Arguments
model_spec
: Model specification, as extracted byADRIA.model_spec(domain)
or from aResultSet
unordered_cat
: Factors considered for sensitivity analysis of unordered categorical type.S
: Number of bins.
Returns
A dictionary containing bin sequences for each factor
ADRIA.sensitivity._foi_data_stores
— Method_foi_data_stores(
+julia> temporal_variability(x, temporal_variabilty, P(x), D(x), E(x))
Sensitivity
ADRIA.sensitivity._category_bins
— Method_category_bins(foi_spec::DataFrame)::Int64
Get number of bins for categorical variables.
Arguments
foi_spec
: Model specification for factors of interest
Returns
Number of bins relevant to the factor of interest
ADRIA.sensitivity._create_seq_store
— Method_create_seq_store(model_spec::DataFrame, unordered_cat::Vector{Symbol}, S::Int64)::Dict{Symbol,Vector{Float64}}
Get stored bin sequences for each factor type.
Arguments
model_spec
: Model specification, as extracted byADRIA.model_spec(domain)
or from aResultSet
unordered_cat
: Factors considered for sensitivity analysis of unordered categorical type.S
: Number of bins.
Returns
A dictionary containing bin sequences for each factor
ADRIA.sensitivity._foi_data_stores
— Method_foi_data_stores(
seq_store::Dict{Symbol,Vector{Float64}},
m_spec::DataFrame,
unordered_cat::Vector{Symbol};
second_dim::NamedTuple
-)::Dataset
Generate data stores of correct size for each factor of interest.
Arguments
seq_store
: Dictionary for storing bin sequences (created by_create_seq_store
)m_spec
: Model specificationunordered_cat
: List of unordered categorical variables.second_dim
: second storage dimension (e.g. (CI=["mean","lower","upper"], ))
Returns
Dataset containing storage for sensitivity ranges for each factor.
ADRIA.sensitivity._get_cat_quantile
— Method_get_cat_quantile(foi_spec::DataFrame, factor_name::Symbol, steps::Vector{Float64})::Vector{Float64}
Get quantiles for a given categorical variable.
Arguments
foi_spec
: Model specification for factors of interestfactor_name
: Contains true where the factor is categorical and false otherwisesteps
: Number of steps for defining bins
Returns
Quantile for a categorical factor.
ADRIA.sensitivity._get_factor_quantile
— Method_get_factor_quantile(seq_store::Dict{Symbol,Vector{Float64}}, foi_spec::DataFrame, fact_t::Symbol)
Checks the type of the factor to calculate its quantile.
Arguments
seq_store
: storage containing bin sequences for factors consideredfoi_spec
: Model specification for factors of interestX_f
: Scenario dataframe for factor of interestfactor_name
: Contains true where the factor is categorical and false otherwise
Returns
Quantile for factor fact_t
, given bin sequences in seq_store
ADRIA.sensitivity._get_factor_spec
— Method_get_factor_spec(model_spec::DataFrame, factors::Vector{Symbol})::DataFrame
Get model spec for specified factors.
Arguments
model_spec
: Model specification, as extracted byADRIA.model_spec(domain)
or from aResultSet
factors
: Factors considered for sensitivity analysis
ADRIA.sensitivity._map_outcomes
— Method_map_outcomes(y::AbstractVecOrMat{<:Real}, rule::Union{BitVector,Vector{Int64}})::Union{BitVector,Vector{Int64}}
-_map_outcomes(y::AbstractVecOrMat{<:Real}, rule::Function)::Vector{Int64}
Apply rule to create mapping between $X$ (model inputs/parameters/factors) and $y$ (model outcomes).
Note
Where the rule is a vector indicating true/false, the y
argument is ignored. The function accepts the y
argument simply to maintain compatibility so the same method name can be applied.
Arguments
y
: Model outputs/outcomesrule
: BitVector, or Function that returns a BitVector, indicating outcomes that meet some desired threshold/behavior.
ADRIA.sensitivity.convergence
— Methodconvergence(X::DataFrame, y::YAXArray, target_factors::Vector{Symbol}; n_steps::Int64=10)::YAXArray
-convergence(rs::ResultSet, X::DataFrame, y::YAXArray, components::Vector{String}; n_steps::Int64=10)::YAXArray
Calculates the PAWN sensitivity index for an increasing number of scenarios where the maximum is the total number of scenarios in scens. Number of scenario subsets determined by N_steps. Can be calculated for individual factors or aggregated over factors for specified model components.
Arguments
rs
: Result set (only needed if aggregating over model components).X
: Model inputsy
: Model outputstarget_factors
: Names of target factors represented by columns inX
.components
: Names of model components to aggregate over (e.g. [:Intervention, :Criteria]).n_steps
: Number of steps to cut the total number of scenarios into.
Returns
YAXArray, of min, lower bound, mean, median, upper bound, max, std, and cv summary statistics for an increasing number of scenarios.
ADRIA.sensitivity.ks_statistic
— Methodks_statistic(ks)
Calculate the Kolmogorov-Smirnov test statistic.
ADRIA.sensitivity.outcome_map
— Methodoutcome_map(p::YAXArray, X_q::AbstractArray, X_f::AbstractArray, y::AbstractVecOrMat{<:Real}, behave::BitVector; n_boot::Int64=100, conf::Float64=0.95)::YAXArray
+)::Dataset
Generate data stores of correct size for each factor of interest.
Arguments
seq_store
: Dictionary for storing bin sequences (created by_create_seq_store
)m_spec
: Model specificationunordered_cat
: List of unordered categorical variables.second_dim
: second storage dimension (e.g. (CI=["mean","lower","upper"], ))
Returns
Dataset containing storage for sensitivity ranges for each factor.
ADRIA.sensitivity._get_cat_quantile
— Method_get_cat_quantile(foi_spec::DataFrame, factor_name::Symbol, steps::Vector{Float64})::Vector{Float64}
Get quantiles for a given categorical variable.
Arguments
foi_spec
: Model specification for factors of interestfactor_name
: Contains true where the factor is categorical and false otherwisesteps
: Number of steps for defining bins
Returns
Quantile for a categorical factor.
ADRIA.sensitivity._get_factor_quantile
— Method_get_factor_quantile(seq_store::Dict{Symbol,Vector{Float64}}, foi_spec::DataFrame, fact_t::Symbol)
Checks the type of the factor to calculate its quantile.
Arguments
seq_store
: storage containing bin sequences for factors consideredfoi_spec
: Model specification for factors of interestX_f
: Scenario dataframe for factor of interestfactor_name
: Contains true where the factor is categorical and false otherwise
Returns
Quantile for factor fact_t
, given bin sequences in seq_store
ADRIA.sensitivity._get_factor_spec
— Method_get_factor_spec(model_spec::DataFrame, factors::Vector{Symbol})::DataFrame
Get model spec for specified factors.
Arguments
model_spec
: Model specification, as extracted byADRIA.model_spec(domain)
or from aResultSet
factors
: Factors considered for sensitivity analysis
ADRIA.sensitivity._map_outcomes
— Method_map_outcomes(y::AbstractVecOrMat{<:Real}, rule::Union{BitVector,Vector{Int64}})::Union{BitVector,Vector{Int64}}
+_map_outcomes(y::AbstractVecOrMat{<:Real}, rule::Function)::Vector{Int64}
Apply rule to create mapping between $X$ (model inputs/parameters/factors) and $y$ (model outcomes).
Note
Where the rule is a vector indicating true/false, the y
argument is ignored. The function accepts the y
argument simply to maintain compatibility so the same method name can be applied.
Arguments
y
: Model outputs/outcomesrule
: BitVector, or Function that returns a BitVector, indicating outcomes that meet some desired threshold/behavior.
ADRIA.sensitivity.convergence
— Methodconvergence(X::DataFrame, y::YAXArray, target_factors::Vector{Symbol}; n_steps::Int64=10)::YAXArray
+convergence(rs::ResultSet, X::DataFrame, y::YAXArray, components::Vector{String}; n_steps::Int64=10)::YAXArray
Calculates the PAWN sensitivity index for an increasing number of scenarios where the maximum is the total number of scenarios in scens. Number of scenario subsets determined by N_steps. Can be calculated for individual factors or aggregated over factors for specified model components.
Arguments
rs
: Result set (only needed if aggregating over model components).X
: Model inputsy
: Model outputstarget_factors
: Names of target factors represented by columns inX
.components
: Names of model components to aggregate over (e.g. [:Intervention, :Criteria]).n_steps
: Number of steps to cut the total number of scenarios into.
Returns
YAXArray, of min, lower bound, mean, median, upper bound, max, std, and cv summary statistics for an increasing number of scenarios.
ADRIA.sensitivity.ks_statistic
— Methodks_statistic(ks)
Calculate the Kolmogorov-Smirnov test statistic.
ADRIA.sensitivity.outcome_map
— Methodoutcome_map(p::YAXArray, X_q::AbstractArray, X_f::AbstractArray, y::AbstractVecOrMat{<:Real}, behave::BitVector; n_boot::Int64=100, conf::Float64=0.95)::YAXArray
outcome_map(X::DataFrame, y::AbstractVecOrMat{<:Real}, rule::Union{Function,BitVector,Vector{Int64}}, target_factors::Vector{Symbol}, model_spec::DataFrame; S::Int64=10, n_boot::Int64=100, conf::Float64=0.95)::Dataset
outcome_map(X::DataFrame, y::AbstractVecOrMat{<:Real}, rule::Union{Function,BitVector,Vector{Int64}}, target_factor::Symbol, model_spec::DataFrame; S::Int64=20, n_boot::Int64=100, conf::Float64=0.95)::YAXArray
outcome_map(X::DataFrame, y::AbstractVector{T}, rule::Union{Function,BitVector,Vector{Int64}}; S::Int64=20, n_boot::Int64=100, conf::Float64=0.95)::Dataset where {T<:Real}
@@ -133,7 +133,7 @@
rule = y -> all(y .> 0.5)
# Map input values where to their outcomes
-ADRIA.sensitivity.outcome_map(X, y, rule, foi; S=20, n_boot=100, conf=0.95)
ADRIA.sensitivity.pawn
— Methodpawn(rs::ResultSet, y::Union{NamedDimsArray,AbstractVector{<:Real}}; S::Int64=10)::NamedDimsArray
+ADRIA.sensitivity.outcome_map(X, y, rule, foi; S=20, n_boot=100, conf=0.95)
ADRIA.sensitivity.pawn
— Methodpawn(rs::ResultSet, y::Union{NamedDimsArray,AbstractVector{<:Real}}; S::Int64=10)::NamedDimsArray
pawn(X::AbstractMatrix{<:Real}, y::AbstractVector{<:Real}, factor_names::Vector{String}; S::Int64=10)::NamedDimsArray
pawn(X::DataFrame, y::AbstractVector{<:Real}; S::Int64=10)::NamedDimsArray
pawn(X::NamedDimsArray, y::Union{NamedDimsArray,AbstractVector{<:Real}}; S::Int64=10)::NamedDimsArray
@@ -144,29 +144,29 @@
# Get mean coral cover over time and locations
μ_tac = mean(ADRIA.metrics.scenario_total_cover(rs), dims=:timesteps)
-ADRIA.sensitivity.pawn(rs, μ_tac)
References
Pianosi, F., Wagener, T., 2018. Distribution-based sensitivity analysis from a generic input-output sample. Environmental Modelling & Software 108, 197-207. https://doi.org/10.1016/j.envsoft.2018.07.019
Baroni, G., Francke, T., 2020. GSA-cvd Combining variance- and distribution-based global sensitivity analysis https://github.com/baronig/GSA-cvd
Puy, A., Lo Piano, S., & Saltelli, A. 2020. A sensitivity analysis of the PAWN sensitivity index. Environmental Modelling & Software, 127, 104679. https://doi.org/10.1016/j.envsoft.2020.104679
https://github.com/SAFEtoolbox/Miscellaneous/blob/main/ReviewofPuy_2020.pdf
Extended help
Pianosi and Wagener have made public their review responding to a critique of their method by Puy et al., (2020). A key criticism by Puy et al. was that the PAWN method is sensitive to its tuning parameters and thus may produce biased results. The tuning parameters referred to are the number of samples ($N$) and the number of conditioning points - $n$ in Puy et al., but denoted as $S$ here.
Puy et al., found that the ratio of $N$ (number of samples) to $S$ has to be sufficiently high ($N/S > 80$) to avoid biased results. Pianosi and Wagener point out this requirement is not particularly difficult to meet. Using the recommended value ($S := 10$), a sample of 1024 runs (small for purposes of Global Sensitivity Analysis) meets this requirement ($1024/10 = 102.4$). Additionally, lower values of $N/S$ is more an indication of faulty experimental design moreso than any deficiency of the PAWN method.
ADRIA.sensitivity.rsa
— Methodrsa(X::DataFrame, y::AbstractVector{<:Real}, model_spec::DataFrame; S::Int64=10)::Dataset
+ADRIA.sensitivity.pawn(rs, μ_tac)
References
Pianosi, F., Wagener, T., 2018. Distribution-based sensitivity analysis from a generic input-output sample. Environmental Modelling & Software 108, 197-207. https://doi.org/10.1016/j.envsoft.2018.07.019
Baroni, G., Francke, T., 2020. GSA-cvd Combining variance- and distribution-based global sensitivity analysis https://github.com/baronig/GSA-cvd
Puy, A., Lo Piano, S., & Saltelli, A. 2020. A sensitivity analysis of the PAWN sensitivity index. Environmental Modelling & Software, 127, 104679. https://doi.org/10.1016/j.envsoft.2020.104679
https://github.com/SAFEtoolbox/Miscellaneous/blob/main/ReviewofPuy_2020.pdf
Extended help
Pianosi and Wagener have made public their review responding to a critique of their method by Puy et al., (2020). A key criticism by Puy et al. was that the PAWN method is sensitive to its tuning parameters and thus may produce biased results. The tuning parameters referred to are the number of samples ($N$) and the number of conditioning points - $n$ in Puy et al., but denoted as $S$ here.
Puy et al., found that the ratio of $N$ (number of samples) to $S$ has to be sufficiently high ($N/S > 80$) to avoid biased results. Pianosi and Wagener point out this requirement is not particularly difficult to meet. Using the recommended value ($S := 10$), a sample of 1024 runs (small for purposes of Global Sensitivity Analysis) meets this requirement ($1024/10 = 102.4$). Additionally, lower values of $N/S$ is more an indication of faulty experimental design moreso than any deficiency of the PAWN method.
ADRIA.sensitivity.rsa
— Methodrsa(X::DataFrame, y::AbstractVector{<:Real}, model_spec::DataFrame; S::Int64=10)::Dataset
rsa(r_s::YAXArray, X_q::AbstractArray, X_i::AbstractArray, y::AbstractVecOrMat{<:Real}, sel::BitVector)::YAXArray
rsa(X::Vector{Float64}, y::AbstractVector{<:Real}, foi_spec::DataFrame; S::Int64=10)::YAXArray
rsa(rs::ResultSet, y::AbstractVector{T}; S::Int64=10)::Dataset where {T<:Real}
rsa(rs::ResultSet, y::AbstractVector{T}, factors::Vector{Symbol}; S::Int64=10)::Dataset where {T<:Real}
-rsa(rs::ResultSet, y::AbstractVector{T}, factor::Symbol; S::Int64=10)::YAXArray where {T<:Real}
Perform Regional Sensitivity Analysis.
Regional Sensitivity Analysis is a Monte Carlo Filtering approach which aims to identify which (group of) factors drive model outputs within or outside of a specified bound. Outputs which fall inside the bounds are regarded as "behavioral", whereas those outside are "non-behavioral". The distribution of behavioral/non-behavioral subsets are compared for each factor. If the subsets are not similar, then the factor is influential. The sensitivity index is simply the maximum distance between the two distributions, with larger values indicating greater sensitivity.
The implemented approach slices factor space into $S$ bins and iteratively assesses behavioral (samples within the bin) and non-behavioral (out of bin samples) subsets with the non-parametric $k$-sample Anderson-Darling test. Larger values indicate greater dissimilarity (thus, sensitivity). The Anderson-Darling test places more weight on the tails compared to the Kolmogorov-Smirnov test.
RSA can indicate where in factor space model sensitivities may be, and contributes to a Value-of-Information (VoI) analysis.
Increasing the value of $S$ increases the granularity of the analysis, but necessitates larger sample sizes.
Note: Values of type missing
indicate a lack of samples in the region.
Arguments
rs
: ResultSetX
: scenario specificationy
: scenario outcomesmodel_spec
: Model specification, as extracted byADRIA.model_spec(domain)
or from aResultSet
factors
: Specific model factors to examineS
: number of bins to slice factor space into (default: 10)
Returns
Dataset
Examples
ADRIA.sensitivity.rsa(X, y; S=10)
References
Pianosi, F., K. Beven, J. Freer, J. W. Hall, J. Rougier, D. B. Stephenson, and T. Wagener. 2016. Sensitivity analysis of environmental models: A systematic review with practical workflow. Environmental Modelling & Software 79:214-232. https://dx.doi.org/10.1016/j.envsoft.2016.02.008
Saltelli, A., M. Ratto, T. Andres, F. Campolongo, J. Cariboni, D. Gatelli, M. Saisana, and S. Tarantola. 2008. Global Sensitivity Analysis: The Primer. Wiley, West Sussex, U.K. https://dx.doi.org/10.1002/9780470725184 Accessible at: http://www.andreasaltelli.eu/file/repository/PrimerCorrected2022.pdf
ADRIA.sensitivity.tsa
— Methodtsa(X::DataFrame, y::AbstractMatrix)::YAXArray
Perform Temporal (or time-varying) Sensitivity Analysis using the PAWN sensitivity index.
The sensitivity index value for time $t$ is inclusive of all time steps prior to $t$. Alternate approaches use a moving window, or only data for time $t$.
Examples
rs = ADRIA.load_results("a ResultSet of interest")
+rsa(rs::ResultSet, y::AbstractVector{T}, factor::Symbol; S::Int64=10)::YAXArray where {T<:Real}
Perform Regional Sensitivity Analysis.
Regional Sensitivity Analysis is a Monte Carlo Filtering approach which aims to identify which (group of) factors drive model outputs within or outside of a specified bound. Outputs which fall inside the bounds are regarded as "behavioral", whereas those outside are "non-behavioral". The distribution of behavioral/non-behavioral subsets are compared for each factor. If the subsets are not similar, then the factor is influential. The sensitivity index is simply the maximum distance between the two distributions, with larger values indicating greater sensitivity.
The implemented approach slices factor space into $S$ bins and iteratively assesses behavioral (samples within the bin) and non-behavioral (out of bin samples) subsets with the non-parametric $k$-sample Anderson-Darling test. Larger values indicate greater dissimilarity (thus, sensitivity). The Anderson-Darling test places more weight on the tails compared to the Kolmogorov-Smirnov test.
RSA can indicate where in factor space model sensitivities may be, and contributes to a Value-of-Information (VoI) analysis.
Increasing the value of $S$ increases the granularity of the analysis, but necessitates larger sample sizes.
Note: Values of type missing
indicate a lack of samples in the region.
Arguments
rs
: ResultSetX
: scenario specificationy
: scenario outcomesmodel_spec
: Model specification, as extracted byADRIA.model_spec(domain)
or from aResultSet
factors
: Specific model factors to examineS
: number of bins to slice factor space into (default: 10)
Returns
Dataset
Examples
ADRIA.sensitivity.rsa(X, y; S=10)
References
Pianosi, F., K. Beven, J. Freer, J. W. Hall, J. Rougier, D. B. Stephenson, and T. Wagener. 2016. Sensitivity analysis of environmental models: A systematic review with practical workflow. Environmental Modelling & Software 79:214-232. https://dx.doi.org/10.1016/j.envsoft.2016.02.008
Saltelli, A., M. Ratto, T. Andres, F. Campolongo, J. Cariboni, D. Gatelli, M. Saisana, and S. Tarantola. 2008. Global Sensitivity Analysis: The Primer. Wiley, West Sussex, U.K. https://dx.doi.org/10.1002/9780470725184 Accessible at: http://www.andreasaltelli.eu/file/repository/PrimerCorrected2022.pdf
ADRIA.sensitivity.tsa
— Methodtsa(X::DataFrame, y::AbstractMatrix)::YAXArray
Perform Temporal (or time-varying) Sensitivity Analysis using the PAWN sensitivity index.
The sensitivity index value for time $t$ is inclusive of all time steps prior to $t$. Alternate approaches use a moving window, or only data for time $t$.
Examples
rs = ADRIA.load_results("a ResultSet of interest")
# Get scenario outcomes over time (shape: `time ⋅ scenarios`)
y_tac = ADRIA.metrics.scenario_total_cover(rs)
# Calculate sensitivity of outcome to factors for each time step
-ADRIA.sensitivity.tsa(rs.inputs, y_tac)
Arguments
X
: Scenario specificationy
: scenario outcomes over time
Returns
YAXArray, of shape $D$ ⋅ 6 ⋅ $T$, where
\[D\]
is the number of dimensions/factors- 6 corresponds to the min, mean, median, max, std, and cv of the PAWN indices
\[T\]
is the number of time steps
General API
ADRIA.coral_spec
— Methodcoral_spec()
Template for coral parameter values for ADRIA. Includes "vital" bio/ecological parameters, to be filled with sampled or user-specified values.
Any parameter added to the params
DataFrame defined here will automatically be made available to the ADRIA model.
Notes: Values for the historical, temporal patterns of degree heating weeks between bleaching years come from [1].
Returns
params
: NamedTuple[taxanames, paramnames, params], taxa names, parameter names, and parameter values for each coral taxa, group and size class
References
Lough, J. M., Anderson, K. D., & Hughes, T. P. (2018). Increasing thermal stress for tropical coral reefs: 1871-2017. Scientific Reports, 8(1), 6079. https://doi.org/10.1038/s41598-018-24530-9
Hall, V.R. & Hughes, T.P. 1996. Reproductive strategies of modular organisms: comparative studies of reef-building corals. Ecology, 77: 950 - 963. https://dx.doi.org/10.2307/2265514
Bozec, Y.-M., Rowell, D., Harrison, L., Gaskell, J., Hock, K., Callaghan, D., Gorton, R., Kovacs, E. M., Lyons, M., Mumby, P., & Roelfsema, C. (2021). Baseline mapping to support reef restoration and resilience-based management in the Whitsundays. https://doi.org/10.13140/RG.2.2.26976.20482
Bozec, Y.-M., Hock, K., Mason, R. A. B., Baird, M. E., Castro-Sanguino, C., Condie, S. A., Puotinen, M., Thompson, A., & Mumby, P. J. (2022). Cumulative impacts across Australia's Great Barrier Reef: A mechanistic evaluation. Ecological Monographs, 92(1), e01494. https://doi.org/10.1002/ecm.1494
Bairos-Novak, K.R., Hoogenboom, M.O., van Oppen, M.J.H., Connolly, S.R., 2021. Coral adaptation to climate change: Meta-analysis reveals high heritability across multiple traits. Global Change Biology 27, 5694-5710. https://doi.org/10.1111/gcb.15829
ADRIA.create_coral_struct
— Functioncreate_coral_struct(bounds=(0.9, 1.1))
Generates Coral struct using the default parameter spec.
Example
# Define coral struct with auto-generated parameter ranges
+ADRIA.sensitivity.tsa(rs.inputs, y_tac)
Arguments
X
: Scenario specificationy
: scenario outcomes over time
Returns
YAXArray, of shape $D$ ⋅ 6 ⋅ $T$, where
\[D\]
is the number of dimensions/factors- 6 corresponds to the min, mean, median, max, std, and cv of the PAWN indices
\[T\]
is the number of time steps
General API
ADRIA.coral_spec
— Methodcoral_spec()
Template for coral parameter values for ADRIA. Includes "vital" bio/ecological parameters, to be filled with sampled or user-specified values.
Any parameter added to the params
DataFrame defined here will automatically be made available to the ADRIA model.
Notes: Values for the historical, temporal patterns of degree heating weeks between bleaching years come from [1].
Returns
params
: NamedTuple[taxanames, paramnames, params], taxa names, parameter names, and parameter values for each coral taxa, group and size class
References
Lough, J. M., Anderson, K. D., & Hughes, T. P. (2018). Increasing thermal stress for tropical coral reefs: 1871-2017. Scientific Reports, 8(1), 6079. https://doi.org/10.1038/s41598-018-24530-9
Hall, V.R. & Hughes, T.P. 1996. Reproductive strategies of modular organisms: comparative studies of reef-building corals. Ecology, 77: 950 - 963. https://dx.doi.org/10.2307/2265514
Bozec, Y.-M., Rowell, D., Harrison, L., Gaskell, J., Hock, K., Callaghan, D., Gorton, R., Kovacs, E. M., Lyons, M., Mumby, P., & Roelfsema, C. (2021). Baseline mapping to support reef restoration and resilience-based management in the Whitsundays. https://doi.org/10.13140/RG.2.2.26976.20482
Bozec, Y.-M., Hock, K., Mason, R. A. B., Baird, M. E., Castro-Sanguino, C., Condie, S. A., Puotinen, M., Thompson, A., & Mumby, P. J. (2022). Cumulative impacts across Australia's Great Barrier Reef: A mechanistic evaluation. Ecological Monographs, 92(1), e01494. https://doi.org/10.1002/ecm.1494
Bairos-Novak, K.R., Hoogenboom, M.O., van Oppen, M.J.H., Connolly, S.R., 2021. Coral adaptation to climate change: Meta-analysis reveals high heritability across multiple traits. Global Change Biology 27, 5694-5710. https://doi.org/10.1111/gcb.15829
ADRIA.create_coral_struct
— Functioncreate_coral_struct(bounds=(0.9, 1.1))
Generates Coral struct using the default parameter spec.
Example
# Define coral struct with auto-generated parameter ranges
# (default in ADRIA is ± 10%, triangular distribution with peak at 0.5)
create_coral_struct()
coral = Coral()
# Recreate coral spec ± 50% from nominal values
create_coral_struct((0.5, 1.5))
-coral = Coral()
ADRIA.env_stats
— Methodenv_stats(rs::ResultSet, s_name::String, rcp::String)
+coral = Coral()
ADRIA.env_stats
— Methodenv_stats(rs::ResultSet, s_name::String, rcp::String)
env_stats(rs::ResultSet, s_name::String, rcp::String, scenario::Int)
-env_stats(rs::ResultSet, s_name::String, stat::String, rcp::String, scenario::Int)
Extract statistics for a given environmental layer ("DHW" or "wave")
ADRIA.growthODE
— MethodgrowthODE(du, X, p, _)
Base coral growth function.
Proportion of corals within a size class are modeled to transition to the next size class up. Assumes colony sizes are evenly distributed within each size bin. Transitions are a ratio of the change in colony size to the width of the bin. See coral_spec()
for further detail.
Note that recruitment pertains to coral groups ($n = 6$) and represents the contribution to the cover of the smallest size class within each group. While growth and mortality metrics pertain to groups (6) as well as size classes (6) across all sites (total of 36 by $n_locs$), recruitment is a 6 by $n_locs$ array.
ADRIA.loc_area
— Methodloc_area(rs::ResultSet)::Vector{Float64}
Extract vector of a location's total area in its areal unit (m², km², etc).
ADRIA.loc_area
— Methodloc_area(domain::Domain)::Vector{Float64}
Get site area for the given domain.
ADRIA.run_scenario
— Methodrun_scenario(domain::Domain, idx::Int64, scenario::Union{AbstractVector,DataFrameRow}, functional_groups::Vector{Vector{FunctionalGroup}}, data_store::NamedTuple)::Nothing
+env_stats(rs::ResultSet, s_name::String, stat::String, rcp::String, scenario::Int)
Extract statistics for a given environmental layer ("DHW" or "wave")
ADRIA.growthODE
— MethodgrowthODE(du, X, p, _)
Base coral growth function.
Proportion of corals within a size class are modeled to transition to the next size class up. Assumes colony sizes are evenly distributed within each size bin. Transitions are a ratio of the change in colony size to the width of the bin. See coral_spec()
for further detail.
Note that recruitment pertains to coral groups ($n = 6$) and represents the contribution to the cover of the smallest size class within each group. While growth and mortality metrics pertain to groups (6) as well as size classes (6) across all sites (total of 36 by $n_locs$), recruitment is a 6 by $n_locs$ array.
ADRIA.loc_area
— Methodloc_area(rs::ResultSet)::Vector{Float64}
Extract vector of a location's total area in its areal unit (m², km², etc).
ADRIA.loc_area
— Methodloc_area(domain::Domain)::Vector{Float64}
Get site area for the given domain.
ADRIA.run_scenario
— Methodrun_scenario(domain::Domain, idx::Int64, scenario::Union{AbstractVector,DataFrameRow}, functional_groups::Vector{Vector{FunctionalGroup}}, data_store::NamedTuple)::Nothing
run_scenario(domain::Domain, scenario::Union{AbstractVector,DataFrameRow})::NamedTuple
-run_scenario(domain::Domain, scenario::Union{AbstractVector,DataFrameRow}, RCP::String)::NamedTuple
Run individual scenarios for a given domain, saving results to a Zarr data store. Results are stored in Zarr format at a pre-configured location. Sets up a new cache
if not provided.
Arguments
domain
: Domainidx
: Scenario index
Returns
Nothing
ADRIA.select
— Methodselect(r::ResultSet, op::String)
Hacky scenario filtering - to be replaced with more robust approach.
Only supports filtering by single attribute. Should be expanded to support filtering metric results too.
Examples
select(result, "guided .> 0.0")
+run_scenario(domain::Domain, scenario::Union{AbstractVector,DataFrameRow}, RCP::String)::NamedTuple
Run individual scenarios for a given domain, saving results to a Zarr data store. Results are stored in Zarr format at a pre-configured location. Sets up a new cache
if not provided.
Arguments
domain
: Domainidx
: Scenario index
Returns
Nothing
ADRIA.select
— Methodselect(r::ResultSet, op::String)
Hacky scenario filtering - to be replaced with more robust approach.
Only supports filtering by single attribute. Should be expanded to support filtering metric results too.
Examples
select(result, "guided .> 0.0")
# Above expands to:
-# result.inputs.guided .> 0.0
ADRIA.site_k_area
— Methodsite_k_area(rs::ResultSet)::Vector{Float64}
Extract vector of a location's coral carrying capacity in terms of absolute area.
ADRIA.site_k_area
— Methodsite_k_area(domain::Domain)::Vector{Float64}
Get maximum coral cover area for the given domain in absolute area.
ADRIA.timesteps
— Methodtimesteps(rs::ResultSet)
Retrieve the time steps represented in the result set.
Arguments
rs
: ResultSet
ADRIA.timesteps
— MethodExtract the time steps represented in the data package.
ADRIA.ADRIADomain
— TypeADRIADomain{Σ,M,I,D,X,Y,Z}
Core ADRIA domain. Represents study area.
ADRIA.Domain
— MethodDomain(name::String, rcp::String, timeframe::Vector, location_data_fn::String, location_id_col::String, cluster_id_col::String, init_coral_fn::String, conn_path::String, dhw_fn::String, wave_fn::String, cyclone_mortality_fn::String)::Domain
Convenience constructor for Domain.
Arguments
name
: Name of domaindpkg_path
: location of data packagercp
: RCP scenario representedtimeframe
: Time steps representedlocation_data_fn
: File name of spatial data usedlocation_id_col
: Column holding name of reef the location is associated with (non-unique)cluster_id_col
: Column holding unique cluster names/idsinit_coral_fn
: Name of file holding initial coral cover valuesconn_path
: Path to directory holding connectivity datadhw_fn
: Filename of DHW data cube in usewave_fn
: Filename of wave data cubecyclone_mortality_fn
: Filename of cyclone mortality data cube
ADRIA.Domain
— MethodBarrier function to create Domain struct without specifying Intervention/Criteria/Coral/SimConstant parameters.
ADRIA.SimConstants
— TypeSimConstants
Struct of simulation constants for ADRIA
References
Lough, J. M., Anderson, K. D., & Hughes, T. P. (2018). Increasing thermal stress for tropical coral reefs: 1871-2017. Scientific Reports, 8(1), 6079. https://doi.org/10.1038/s41598-018-24530-9
Hughes, T. P., Kerry, J. T., Baird, A. H., Connolly, S. R., Dietzel, A., Eakin, C. M., Heron, S. F., Hoey, A. S., Hoogenboom, M. O., Liu, G., McWilliam, M. J., Pears, R. J., Pratchett, M. S., Skirving, W. J., Stella, J. S., & Torda, G. (2018). Global warming transforms coral reef assemblages. Nature, 556(7702), 492-496. https://doi.org/10.1038/s41586-018-0041-2
Bozec, Y.-M., Rowell, D., Harrison, L., Gaskell, J., Hock, K., Callaghan, D., Gorton, R., Kovacs, E. M., Lyons, M., Mumby, P., & Roelfsema, C. (2021). Baseline mapping to support reef restoration and resilience-based management in the Whitsundays. https://doi.org/10.13140/RG.2.2.26976.20482
Bozec, Y.-M., Hock, K., Mason, R. A. B., Baird, M. E., Castro-Sanguino, C., Condie, S. A., Puotinen, M., Thompson, A., & Mumby, P. J. (2022). Cumulative impacts across Australia's Great Barrier Reef: A mechanistic evaluation. Ecological Monographs, 92(1), e01494. https://doi.org/10.1002/ecm.1494