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

rename cubes for ADRIA compatability #20

Merged
merged 2 commits into from
Apr 26, 2024
Merged
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
36 changes: 18 additions & 18 deletions src/ResultStore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function create_dataset(start_year::Int, end_year::Int, n_reefs::Int, reps::Int)

arr_size = (year_range, n_reefs, 2 * reps)

# Coral cover [% of total reef area]
cover = DataCube(
# Total Coral cover [% of total reef area]
total_cover = DataCube(
zeros(arr_size...);
timesteps=start_year:end_year,
locations=1:n_reefs,
Expand Down Expand Up @@ -107,10 +107,10 @@ function create_dataset(start_year::Int, end_year::Int, n_reefs::Int, reps::Int)
locations=1:n_reefs,
scenarios=1:(2 * reps)
)
# Species cover [% of total reef area]
# Total Species cover [% of total reef area]
n_species = 6
arr_size = (year_range, n_reefs, n_species, 2 * reps)
species = DataCube(
total_taxa_cover = DataCube(
zeros(arr_size...);
timesteps=start_year:end_year,
locations=1:n_reefs,
Expand All @@ -119,14 +119,14 @@ function create_dataset(start_year::Int, end_year::Int, n_reefs::Int, reps::Int)
)

return Dataset(
cover=cover,
total_cover=total_cover,
dhw=dhw,
dhw_mortality=dhw_mortality,
cyc_mortality=cyc_mortality,
cyc_cat=cyc_cat,
cots=cots,
cots_mortality=cots_mortality,
species=species
total_taxa_cover=total_taxa_cover
)
end

Expand All @@ -146,19 +146,19 @@ function Base.show(io::IO, mime::MIME"text/plain", rs::ResultStore)::Nothing

Each store holds data for `:ref` and `:iv`.

Reefs: $(length(rs.results.cover.locations))
Reefs: $(length(rs.results.total_cover.locations))
Range: $(rs.start_year) to $(rs.end_year) ($(rs.year_range) years)
Repeats: $(rs.reps)
Total repeats with ref and iv: $(2 * rs.reps)

cover : $(size(rs.results.cover))
total_cover : $(size(rs.results.total_cover))
dhw : $(size(rs.results.dhw))
dhw_mortality : $(size(rs.results.dhw_mortality))
cyc_mortality : $(size(rs.results.cyc_mortality))
cyc_cat : $(size(rs.results.cyc_cat))
cots : $(size(rs.results.cots))
cots_mortality : $(size(rs.results.cots_mortality))
species : $(size(rs.results.species))
total_taxa_cover : $(size(rs.results.total_taxa_cover))
""")
end

Expand Down Expand Up @@ -189,9 +189,9 @@ function preallocate_concat!(rs, start_year, end_year, reps::Int64)::Nothing
Dim{:scenarios}(prev_reps+1:new_n_reps)
)

# Concatenate species cube separately.
# Concatenate total_taxa_cover cube separately.
cubes = [
:cover,
:total_cover,
:dhw,
:dhw_mortality,
:cyc_mortality,
Expand All @@ -214,8 +214,8 @@ function preallocate_concat!(rs, start_year, end_year, reps::Int64)::Nothing
Dim{:taxa}(1:n_species),
Dim{:scenarios}(prev_reps+1:new_n_reps)
)
rs.results.cubes[:species] = cat(
rs.results.cubes[:species],
rs.results.cubes[:total_taxa_cover] = cat(
rs.results.cubes[:total_taxa_cover],
YAXArray(axlist, zeros(rs.year_range, n_reefs, n_species, 2 * reps));
dims=Dim{:scenarios}(1:new_n_reps)
)
Expand Down Expand Up @@ -333,7 +333,7 @@ function concat_results!(

# Temporary data store for results
n_reefs = 3806
n_species = length(rs.results.species.taxa)
n_species = length(rs.results.total_taxa_cover.taxa)
tmp = zeros(n_reefs)

for r in 1:reps
Expand All @@ -349,7 +349,7 @@ function concat_results!(
tmp::Ref{Cdouble},
n_reefs::Cint
)::Cint
rs.results.cover[timesteps=At(yr), scenarios=rep_offset + r] = tmp
rs.results.total_cover[timesteps=At(yr), scenarios=rep_offset + r] = tmp

@RME runGetData(
"coral_pct"::Cstring,
Expand All @@ -360,7 +360,7 @@ function concat_results!(
tmp::Ref{Cdouble},
n_reefs::Cint
)::Cint
rs.results.cover[timesteps=At(yr), scenarios=rep_offset + reps + r] = tmp
rs.results.total_cover[timesteps=At(yr), scenarios=rep_offset + reps + r] = tmp

@RME runGetData(
"max_dhw"::Cstring,
Expand Down Expand Up @@ -507,7 +507,7 @@ function concat_results!(
tmp::Ref{Cdouble},
n_reefs::Cint
)::Cint
rs.results.species[
rs.results.total_taxa_cover[
timesteps=At(yr), taxa=At(sp), scenarios=rep_offset + r
] = tmp

Expand All @@ -520,7 +520,7 @@ function concat_results!(
tmp::Ref{Cdouble},
n_reefs::Cint
)::Cint
rs.results.species[
rs.results.total_taxa_cover[
timesteps=At(yr), taxa=At(sp), scenarios=rep_offset + reps + r
] = tmp
end
Expand Down
Loading