Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle cases where there are no intervention scenarios #22

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ reset_rme()

```julia
using ReefModEngine
using CSV, DataFrames, MAT
using CSV, DataFrames

# Initialize RME (may take a minute or two)
init_rme("path to RME directory")
Expand Down
23 changes: 17 additions & 6 deletions src/ResultStore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function append_scenarios!(rs::ResultStore, reps::Int)::Nothing
outplant_count += n_years * @getRME ivOutplantCountPerM2(name::Cstring)::Cdouble
outplant_area += n_years * @getRME ivOutplantAreaPct(name::Cstring)::Cdouble
outplant_locs += n_years * n_locs[1]
elseif type=="enrich"
elseif type == "enrich"
n_enrichment_iv += n_years
enrichment_count += n_years * @getRME ivEnrichCountPerM2(name::Cstring)::Cdouble
enrichment_area += n_years * @getRME ivEnrichAreaPct(name::Cstring)::Cdouble
Expand All @@ -276,12 +276,23 @@ function append_scenarios!(rs::ResultStore, reps::Int)::Nothing
n_outplant_iv = max(1, n_outplant_iv)
n_enrichment_iv = max(1, n_enrichment_iv)

# Create vector for compatibility with c++ pointers.
# Create vector for compatibility with C++ pointers.
dhw_tolerance_outplants::Vector{Float64} = [0.0]
@RME getOption(
"restoration_dhw_tolerance_outplants"::Cstring,
dhw_tolerance_outplants::Ptr{Cdouble}
)::Cint

has_outplants = try
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has_outplants is not used but leaving it as is as I think it may come in handy later...

@RME getOption(
"restoration_dhw_tolerance_outplants"::Cstring,
dhw_tolerance_outplants::Ptr{Cdouble}
)::Cint

true
catch err
if !(err isa ArgumentError)
rethrow(err)
end

false
end

df_cf::DataFrame = DataFrame(
counterfactual=repeat(1, reps),
Expand Down
12 changes: 11 additions & 1 deletion src/rme_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,17 @@ function init_rme(rme_path::String)::Nothing
data_fp = joinpath(rme_path, "data_files")

@RME setDataFilesPath(data_fp::Cstring)::Cint
@RME init(joinpath(rme_path, "data_files", "config", "config.xml")::Cstring)::Cint

try
@RME init(joinpath(rme_path, "data_files", "config", "config.xml")::Cstring)::Cint
catch err
msg = """
Error encountered initializing RME.
See documentation for ReefModEngine.jl and check RME config.xml file.
"""
@info msg
rethrow(err)
end

rme_vers = @RME version()::Cstring
@info "Loaded RME $rme_vers"
Expand Down