Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
baf00f9
add result interface
DanTanAtAims Aug 2, 2024
bcb4d57
update viz scenario input type
DanTanAtAims Aug 2, 2024
b6b8814
add generic variable loading to cscape interface to allow for more fl…
DanTanAtAims Aug 5, 2024
baddf76
restore CScape interface documentation
DanTanAtAims Aug 14, 2024
ee5fa62
add documentation for load_variable!
DanTanAtAims Aug 14, 2024
b9c275f
fix documentation error for CScape interface
DanTanAtAims Aug 15, 2024
9c9393f
Small adjustment to string creation
ConnectedSystems Aug 27, 2024
8aa35c1
Minor adjustment to docstrings for clarity
ConnectedSystems Aug 27, 2024
42962ad
Micro-performance change: maintain same types for stability
ConnectedSystems Aug 27, 2024
b465cd4
Modified loading strategy
ConnectedSystems Aug 27, 2024
40e1163
Use of specific datatypes
ConnectedSystems Aug 27, 2024
b907430
Clarify comments
ConnectedSystems Aug 27, 2024
042f750
Set up use of a dummy selector
ConnectedSystems Aug 27, 2024
eb1840e
Use dummy selector to read data in as needed
ConnectedSystems Aug 27, 2024
0311ff6
Avoid additional calculations if there is no data (all zeros)
ConnectedSystems Aug 27, 2024
e6fe195
Provide type info
ConnectedSystems Aug 27, 2024
6147e60
Format file
ConnectedSystems Aug 27, 2024
1a031bc
Standardize/format docs
ConnectedSystems Aug 28, 2024
e4d2196
Indicate data loading progress
ConnectedSystems Aug 28, 2024
a23edea
correct calculation of available coral cover
DanTanAtAims Sep 16, 2024
66d468a
update cscape interface to use loc instead of site
DanTanAtAims Sep 16, 2024
7cde0c4
remove manual id correction with update datapackage
DanTanAtAims Sep 16, 2024
9b84914
run julia formatter
DanTanAtAims Sep 16, 2024
81e6242
correct calculation of relative cover
DanTanAtAims Sep 17, 2024
2f3bf6e
format file
DanTanAtAims Sep 17, 2024
245438e
resolve misplaced habitable area
DanTanAtAims Sep 17, 2024
9612824
use NetCDF.jl for raw set
DanTanAtAims Sep 17, 2024
0068b49
migrate coral size diameter extraction to use NetCDF interface
DanTanAtAims Sep 18, 2024
e4ee825
migrate relative cover loading to use netcdf api
DanTanAtAims Sep 18, 2024
a5a950e
migrate load variable to use NetCDF.jl api
DanTanAtAims Sep 18, 2024
6affa64
format interface
DanTanAtAims Sep 18, 2024
c741119
rename dimension from sites to locations
DanTanAtAims Sep 23, 2024
221ca19
format interface
DanTanAtAims Sep 23, 2024
5880ad4
throw more informative error message
DanTanAtAims Sep 23, 2024
8394d26
add scenario id to scenario dataframe
DanTanAtAims Sep 23, 2024
19ec163
use fill not repeat
DanTanAtAims Sep 24, 2024
a3c1a67
remove unused tuple in fill call
DanTanAtAims Sep 25, 2024
6801bee
add option to remove cscape result interface loading progress bar
DanTanAtAims Jan 17, 2025
ef4d84f
add constant to model spec
DanTanAtAims Feb 3, 2025
e208c2c
add metrics to cscape interface
DanTanAtAims Feb 5, 2025
955979d
integrate cscape interface with existing metric code
DanTanAtAims Feb 10, 2025
8182963
use NetCDF library to read variable
DanTanAtAims Feb 10, 2025
fb8dc34
remove manual scenario type calculation for cscape and use ADRIA
DanTanAtAims Feb 10, 2025
6e98504
remove manual plotting dispatch
DanTanAtAims Feb 10, 2025
343a5d6
format files
DanTanAtAims Feb 10, 2025
858b5ab
add coral evenness metric
DanTanAtAims Feb 12, 2025
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
60 changes: 58 additions & 2 deletions docs/src/usage/loading_results.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,66 @@ data_dir
results.nc
scenarios.csv
```
In order to reduce the duplication of geospatial and conectivity data, the data directory
and results directory can be supplied seperately to avoid having copies for each resuilt set

In order to reduce the duplication of geospatial and connectivity data, the data directory
and results directory can be supplied separately to avoid having copies for each result set
analysed.

```julia
rs = ADRIA.load_domain(RMEResultSet, "<path to data dir>", "<path to results dir>")
```

## Loading C~scape Results

Results from C~scape can be loaded with the `load_results` function.

```julia
# Assumes NetCDFs are contained in result subdirectory (see example directory tree below)
rs = ADRIA.load_results(CScapeResultSet, "<path to data dir>")

# Retrieves NetCDFs from separate directory
rs = ADRIA.load_results(CScapeResultSet, "<path to data dir>", "<path to result directory>")

# Manually pass in a list of files to load as results
rs = ADRIA.load_results(CScapeResultSet, "<path to data dir>", ["netcdf_fn1", "netcdf_fn2", ...])
```

The expected directory structure is:

```bash
data_dir
│ ScenarioID.csv
├───connectivity
│ connectivity.csv
├───site_data
│ geospatial_data.gpkg
├───initial_cover
│ initial_cover.csv
└───results (optional)
NetCDF_Scn_140001.nc
NetCDF_Scn_140002.nc
NetCDF_Scn_140003.nc
...
```

### Loading Variables using the interface

All variables except from relative cover are not loaded automatically. The outcomes
dictionary contained in the result structure is where all outputs are stored.

```julia
julia> rs.outcomes[:relative_cover]
```

To analyse a variable contained in the NetCDFs, use the function

```julia
julia> var = ADRIA.load_variable!(rs, :var_name)

# The variable will also be stored in the outcomes dictionary.
julia> rs.outcomes[:var_name]
```
2 changes: 2 additions & 0 deletions src/ADRIA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ include("io/ResultSet.jl")
include("spatial/spatial.jl")
include("io/result_io.jl")
include("io/rme_result_io.jl")
include("io/cscape_result_io.jl")
include("io/result_post_processing.jl")
include("io/sampling.jl")
include("metrics/metrics.jl")
Expand Down Expand Up @@ -102,6 +103,7 @@ export RMEDomain
export ReefModDomain

export RMEResultSet
export CScapeResultSet
# metric helper methods
# export dims, ndims

Expand Down
32 changes: 25 additions & 7 deletions src/analysis/scenario.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,41 @@ end

function counterfactual(scenarios::DataFrame)::BitVector
no_seed = _no_seed(scenarios)
no_fog = scenarios.fogging .== 0
no_SRM = scenarios.SRM .== 0
has_fog_col = "fogging" in names(scenarios)
no_fog = has_fog_col ? scenarios.fogging .== 0 : fill(true, size(scenarios, 1))
has_SRM_col = "SRM" in names(scenarios)
no_SRM = has_SRM_col ? scenarios.SRM .== 0 : fill(true, size(scenarios, 1))

return no_seed .& no_fog .& no_SRM
end

function unguided(scenarios::DataFrame)::BitVector
has_guided_col = "guided" in names(scenarios)
# If the results set does not have a guided type column default to unguided
is_unguided = has_guided_col ? scenarios.guided .== 0 : fill(true, size(scenarios, 1))

has_fog_col = "fogging" in names(scenarios)
has_fog = has_fog_col ? scenarios.fogging .> 0 : fill(true, size(scenarios, 1))

has_SRM_col = "SRM" in names(scenarios)
has_SRM = has_SRM_col ? scenarios.SRM .> 0 : fill(true, size(scenarios, 1))

has_seed = .!_no_seed(scenarios)
has_shade = (scenarios.fogging .> 0) .| (scenarios.SRM .> 0)
return (scenarios.guided .== 0) .& (has_seed .| has_shade)
has_shade = (has_fog) .| (has_SRM)

return is_unguided .& (has_seed .| has_shade)
end

function guided(scenarios::DataFrame)::BitVector
return .!(counterfactual(scenarios) .| unguided(scenarios))
end

function _no_seed(scenarios::DataFrame)::BitVector
return (scenarios.N_seed_TA .== 0) .&
(scenarios.N_seed_CA .== 0) .&
(scenarios.N_seed_SM .== 0)
seed_cols::Vector{String} = filter(
x -> contains(x, "N_seed_"), names(scenarios)
)

return BitVector(
all(collect(scen_row) .== 0) for scen_row in eachrow(scenarios[:, seed_cols])
)
end
2 changes: 1 addition & 1 deletion src/ecosystem/corals/Corals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function coral_spec()::NamedTuple
params.coral_id = String[join(x, "_") for x in zip(tn, params.taxa_id, params.class_id)]

# Ecological parameters
# To be more consistent with parameters in ReefMod, C~Scape and RRAP
# To be more consistent with parameters in ReefMod, C~scape and RRAP
# interventions, we express coral abundance as colony numbers in different
# size classes and growth rates as linear extension (in cm per year).
colony_area_mean_cm², mean_colony_diameter_m = colony_areas()
Expand Down
Loading