API
ReefModEngine.DataCube Method
DataCube(data::AbstractArray; kwargs...)::YAXArrayConstructor for YAXArray. When used with axes_names, the axes labels will be UnitRanges from 1 up to that axis length.
Arguments
data: Array of data to be used when building the YAXArrayaxes_names:
ReefModEngine._check_deprecated_options Method
_check_deprecated_options(opt::String)::StringChecks option string and updates to latest (renamed) equivalent.
sourceReefModEngine._run_batch Method
run_batch(batch_idx::Int64, batch_start::Int64, batch_size::Int64, reps::Int64, rme_results_dir::String, start_year::Int64, end_year::Int64, RCP_scen::String, gcm::String, result_store)::NothingRun one batch of repetitions using RME.
sourceReefModEngine.append_scenarios! Method
append_scenarios!(rs::ResultStore, reps::Int)::NothingAdd rows to scenario dataframe in result store.
sourceReefModEngine.area_needed Method
area_needed(n_corals::Int64, density::Union{Float64,Vector{Float64}})::Union{Vector{Float64},Float64}Determine area (in km²) needed to deploy the given the number of corals at the specified density.
sourceReefModEngine.concat_RME_datasets Method
concat_RME_datasets(datasets::Vector{Dataset})Combine RME result datasets along the scenarios dimension to combine scenarios that have been run separately into a single dataset.
Example
results_dataset_300scens = concat_RME_netcdfs( results_dataset_200scens, results_dataset_50scens, results_dataset_50scens )
sourceReefModEngine.concat_results! Method
concat_results!(rs::ResultStore, start_year::Int64, end_year::Int64, reps::Int64)::NothingAppend results for all runs/replicates.
Arguments
rs: Result store to save data tostart_year: Collect data from this yearend_year: Collect data to this yearreps: Total number of expected replicates
ReefModEngine.concat_separate_reps Method
concat_separate_reps(results_store_1::ResultStore, result_store_s::ResultStore...)Concatenate ResultStores that have been saved separately along the scenarios axis. Intended use: When additional scenarios have been run after saving an initial scenario set. All variables and factors such as start_year, end_year, n_reefs must be identical across ResultStores.
ReefModEngine.create_dataset Method
create_dataset(start_year::Int, end_year::Int, n_reefs::Int, reps::Int)::DatasetPreallocate and create dataset for result variables. Only constructed when the first results are collected.
sourceReefModEngine.deployment_area Method
deployment_area(n_corals::Int64, max_n_corals::Int64, density::Union{Float64, Vector{Float64}}, target_areas::Vector{Float64})::Union{Tuple{Float64,Float64},Tuple{Float64,Vector{Float64}}}Determine deployment area for the expected number of corals to be deployed.
Arguments
n_corals: Number of corals,max_n_corals: Expected maximum deployment effort (total number of corals in intervention set)density: Stocking density per m². In RME versions higher than v1.0.28 density needs to be a vector with each element representing the density per functional grouptarget_areas: Available area at target location(s)
Returns
Tuple
Percent area of deployment
modified stocking density [currently no modifications are made]
ReefModEngine.deployment_area Method
deployment_area(max_n_corals::Int64, target_areas::Vector{Float64})::Union{Tuple{Float64,Float64}, Tuple{Float64,Vector{Float64}}}Determine deployment area for given number of corals and target area, calculating the appropriate deployment density, limiting deployment density to be <40m2 for each coral species.
sourceReefModEngine.get_iv_param Method
get_iv_param(iv_name::String, param_name::String)Return the current value of a parameter of an intervention.
Returns parameter param_name of intervention iv_name. The returned value can either be a number or text depending on the type of parameter. If the intervention does not exist, parameter is not recognized, or value is of the wrong type, an error will be thrown.
Currently supported values for param_name are:
"second_rs": Secondary reef set name or empty string"hours": Number of hours effort"rank_data_code1": Data code to rank by or "none""rank_data_code2": Data code to rank by or "none""rank_weight1": Weight for first rank data (0-1)"rank_weight2": Weight for second rank data (0-1)
Examples
<Badge type="info" class="source-link" text="source"><a href="https://github.com/open-AIMS/ReefModEngine.jl/blob/2ee6362ac32b7d4779cf94a959b33454646384cc/src/interface.jl#L137-L159" target="_blank" rel="noreferrer">source</a></Badge>
</details>
<details class='jldocstring custom-block' open>
<summary><a id='ReefModEngine.get_param-Tuple{String}' href='#ReefModEngine.get_param-Tuple{String}'><span class="jlbinding">ReefModEngine.get_param</span></a> <Badge type="info" class="jlObjectType jlMethod" text="Method" /></summary>
```julia
get_param(name::String)::Union{Float64,Vector{Float64}}Return the current value(s) of an RME parameter.
The returned value will be a vector of length 1 or greater.
sourceReefModEngine.init_rme Method
init_rme(rme_path::String)::NothingInitialize ReefMod Engine for use.
sourceReefModEngine.iv_add Method
iv_add(name::String, type::String, reef_set::String, first_year::Int, last_year::Int, year_step::Int, area_pct::Float64, count_per_m2::Union{Float64, Vector{Float64}})Add an outplant or enrich intervention with deployment parameters.
Additional Arguments for "outplant" and "enrich" types
area_pct: Percentage of reef area where restoration will occurcount_per_m2: Corals to add per m² (scalar or 6-element vector for each species)
ReefModEngine.iv_add Method
iv_add(name::String, type::String, reef_set::String, first_year::Int, last_year::Int, year_step::Int)Add an intervention to the current run.
Arguments
name: Name of the intervention (must be unique)type: Type of intervention (see types below)reef_set: Name of reef set to apply intervention tofirst_year: First year intervention will be appliedlast_year: Last year intervention will be appliedyear_step: Frequency (1=every year, 2=every other year, etc.)
Intervention Types
cots_control: CSIRO method CoTS control algorithmcots_control_basic: Original CoTS control methodprevent_anchoring: Not implemented (no effect)prevent_herbivore_exploitation: Prevent herbivore exploitationstabilise: Rubble stabilizationoutplant: Coral outplanting (requires additional parameters)enrich: Larval enrichment (requires additional parameters)
ReefModEngine.load_result_store Method
load_result_store(dir_name::String, n_reps::Int64)::ResultStoreSave ResultStore from saved results.nc and scenarios.csv files to allow modification.
Arguments
dir_name: Directory where result store files are held.n_reps: The number of reps held in resultstore (should not include duplicate reps for counterfactual-only runs).
ReefModEngine.log_get_reef_data_int Method
log_get_reef_data_int(name::String, reef_index::Int, repeat::Int, iter::Int)Get reef-level log data from intervention run.
sourceReefModEngine.log_get_reef_data_ref Method
log_get_reef_data_ref(name::String, reef_index::Int, repeat::Int, iter::Int)Get reef-level log data from reference run.
sourceReefModEngine.log_get_run_data_int Method
log_get_run_data_int(name::String, repeat::Int, iter::Int)Get run-level log data from intervention run.
sourceReefModEngine.log_get_run_data_ref Method
log_get_run_data_ref(name::String, repeat::Int, iter::Int)Get run-level log data from reference run.
sourceReefModEngine.log_set_all_items_enabled Method
log_set_all_items_enabled(enabled::Bool)Enable or disable logging of all data items.
sourceReefModEngine.log_set_all_reefs_enabled Method
log_set_all_reefs_enabled(enabled::Bool)Enable or disable logging for all reefs.
sourceReefModEngine.log_set_item_enabled Method
log_set_item_enabled(name::String, enabled::Bool)Enable or disable logging of specific data item.
sourceReefModEngine.log_set_reef_enabled Method
log_set_reef_enabled(reef_index::Int, enabled::Bool)Enable or disable logging for specific reef.
sourceReefModEngine.match_id Method
match_id(id::String)::Int64
match_ids(ids::Vector{String})::Vector{Int64}Find matching index position for the given ID(s) according to ReefMod Engine's reef list.
Note
ReefMod Engine's reef list is in all upper case. The provided IDs are converted to upper case to ensure a match.
Examples
julia> reef_ids()
# 3806-element Vector{String}:
# "10-330"
# "10-331"
# ⋮
# "23-048"
# "23-049"
julia> match_id("10-330")
# 1
julia> match_id("23-049")
# 3806
julia> match_ids(["23-048", "10-331"])
# 3805
# 2ReefModEngine.n_corals_calculation Method
n_corals_calculation(count_per_year::Float64, target_reef_area_km²::Vector{Float64})::Int64Calculate total number of corals deployed in an intervention.
sourceReefModEngine.preallocate_concat! Method
preallocate_concat(rs, start_year, end_year, reps::Int64)::NothingAllocate additional memory before adding an additional result set. Result sets must have the same time frame.
sourceReefModEngine.rebuild_RME_dataset Method
rebuild_RME_dataset(
rs_dataset::Dataset,
start_year::Int64,
end_year::Int64,
n_reefs::Int64,
n_reps::Int64,
unique_indices::Vector{Int64}
)Rebuild a RME dataset that has duplicated scenarios. For example, when RME outputs counterfactual runs with duplicate scenario data.
Arguments
rs_dataset: The RME dataset with duplicated scenarios.start_year: Start year of timesteps dimension.end_year: End year of timesteps dimension.location_ids: Location IDs to be held in sites dimension.n_reps: The intended number of scenarios that should be in the returned dataset (after removing duplicate scenarios).unique_indices: The first index of each unique scenario to keep (excludes indices of duplicate scenarios).
ReefModEngine.reef_areas Method
reef_areas(id_list)Retrieve reef areas in km² for specified locations.
sourceReefModEngine.reef_ids Method
reef_ids()::Vector{String}Get list of reef ids in the order expected by ReefMod Engine.
sourceReefModEngine.remove_duplicate_reps Method
remove_duplicate_reps(result_store::ResultStore, n_reps::Int64)Find the indices of unique scenarios when there are duplicated scenarios and rebuild the scenarios axis in rebuild_RME_dataset() to contain only a single copy of unique scenarios.
ReefModEngine.reset_rme Method
reset_rme()Reset ReefModEngine, clearing any and all interventions and reef sets.
sourceReefModEngine.run_init Method
run_init()::NothingConvenience function to initialize RME runs.
sourceReefModEngine.run_rme Method
run_rme(rme_path::String, n_threads::Int64, reps::Int64, result_path::String; start_year::Int64=2022, end_year::Int64=2099, batch_size::Int64=10, start_batch::Int64=1, RCP_scen::String="SSP 2.45", gcm::String="CNRM_ESM2_1", rnd_seed::Int64=1234)::NothingRun counterfactual scenarios with ReefModEngine.jl and save result set to desired directory.
Arguments
rme_path: Path to REM folder.n_threads: Number of threads to be used with RME.reps: Total number of repetitions to be run.result_path: Path to folder where resultset should be placed.start_year: RME run start year.end_year: RME run end year.batch_size: Number of repetitions to be run in each batch.RCP_scen: RCP scenario to be used for RME runs.gcm: GCM to be used for RME runs.rnd_seed: Random seed.
ReefModEngine.save_result_store Method
save_result_store(dir_name::String, result_store::ResultStore)::NothingSave results to a netcdf file and a dataframe containing the scenario runs. Saved to the given directory. The directory is created if it does not exit.
sourceReefModEngine.set_enrichment_deployment! Method
set_enrichment_deployment!(name::String, reefset::String, n_larvae::Int64, max_effort::Int64, first_year::Int64, last_year::Int64, year_step::Int64, area_km2::Vector{Float64}, density::Float64)::NothingSet deployment for multiple years at a given frequency.
sourceReefModEngine.set_enrichment_deployment! Method
set_enrichment_deployment!(name::String, reefset::String, n_larvae::Int64, year::Int64, area_km2::Vector{Float64}, density::Float64)::NothingAs set_seeding_deployment() but for larvae enrichment (also known as assisted migration). Set deployment for a single target year.
ReefModEngine.set_iv_param Method
set_iv_param(name::String, value::Union{Float64, Int64})::Nothing
set_iv_param(name::String, value::Vector{Float64})::Nothing
set_iv_param(name::String, value::String)::Nothing
set_iv_param(iv_name::String, param_name::String, value::String)::Nothing
set_iv_param(iv_name::String, param_name::String, value::Union{Float64, Int64})::NothingSet RME intervention parameter by name.
sourceReefModEngine.set_option Method
set_option(opt::String, val::Float64)
set_option(opt::String, val::Int)
set_option(opt::String, val::String)Set RME option.
See RME documentation for full list of available options.
sourceReefModEngine.set_outplant_deployment! Method
set_outplant_deployment!(name::String, reefset::String, n_corals::Int64, max_effort::Int64, first_year::Int64, last_year::Int64, year_step::Int64, area_km2::Vector{Float64}, density::Union{Vector{Float64}, Float})::NothingSet outplanting deployments across a range of years.
Arguments
name: Name to assign intervention eventreefset: Name of pre-defined list of reefs to intervene onn_corals: Number of corals to outplant for a given yearmax_effort: Total number of corals to outplantfirst_year: First year to start interventionslast_year: Final year of interventionsyear_step: Frequency of intervention (1 = every year, 2 = every second year, etc)area_km2: Intervention area [km²]density: Stocking density of intervention [corals / m²]
ReefModEngine.set_outplant_deployment! Method
set_outplant_deployment!(name::String, reefset::String, max_effort::Int64, first_year::Int64, last_year::Int64, year_step::Int64, area_km2::Vector{Float64})::NothingSet outplanting deployments across a range of years, automatically determining the coral deployment density to maintain the set grid size.
sourceReefModEngine.set_outplant_deployment! Method
set_outplant_deployment!(name::String, reefset::String, n_corals::Int64, year::Int64, area_km2::Vector{Float64}, density::Union{Float64, Vector{Float64}})::NothingSet outplanting deployments for a single year.
Arguments
name: Name to assign intervention eventreefset: Name of pre-defined list of reefs to intervene onn_corals: Number of corals to outplantyear: Year to intervenearea_km2: Area to intervene [km²]density: Stocking density of intervention [corals / m²]
ReefModEngine.set_outplant_deployment! Method
set_outplant_deployment!(name::String, reefset::String, n_corals::Int64, year::Int64, area_km2::Vector{Float64})::NothingSet outplanting deployments for a single year, automatically determining the coral deployment density to maintain the set grid size.
Arguments
name: Name to assign intervention eventreefset: Name of pre-defined list of reefs to intervene onn_corals: Number of corals to outplantyear: Year to intervenearea_km2: Area to intervene [km²]
ReefModEngine.set_outplant_tolerance! Method
set_outplant_tolerance!(
iv_name::String,
dhw_mean::Float64,
dhw_std::Float64;
n_groups=6
)
set_outplant_tolerance!(
iv_name::String,
dhw_mean::Vector{Float64},
dhw_std::Vector{Float64};
n_groups=6
)Set heat tolerance of outplanting interventions.
Arguments
iv_name: Name of defined deployment as set byset_outplant_deployment!()dhw_mean: Mean of DHW tolerance (for each coral functional group)dhw_std: Standard deviation of DHW tolerance (for each coral functional group)n_groups: Number of coral groups (default: 6). This should not change unless RME adds more coral groups.
Returns
Nothing
sourceReefModEngine.@getRME Macro
Only for use when RME functions return numeric results that are not error codes.
Examples
count_per_m2::Float64 = @getRME ivOutplantCountPerM2("iv_name"::Cstring)::Cdouble