Integration with Diversity.jl
EcoSISTEM is integrated with the Diversity package, so diversity measures can be calculated directly on an ecosystem - an Ecosystem is a Diversity metacommunity, with one subcommunity per grid cell.
See The basics of EcoSISTEM.jl for how to set one up; the example below builds a small one to measure.
Every grid cell is a subcommunity, including inactive ones - sea off a coastline, or a cell a Deactivate intervention has destroyed. That costs nothing for the metacommunity measures, which weight each subcommunity by its share of the total abundance and so give an empty cell zero weight; the partitioned results are identical whether or not the empty cells are there. But a subcommunity measure returns one row per cell, so on a small island in a large grid most of those rows describe empty sea, and an index of an empty community is not defined. Select the occupied cells before asking a per-cell question.
using Diversity
first(norm_sub_alpha(eco, 1.0), 5) # subcommunity measures - one row per grid cell, 25 here| Row | div_type | measure | q | type_level | type_name | partition_level | partition_name | diversity |
|---|---|---|---|---|---|---|---|---|
| String | String | Float64 | String | String | String | String | Float64 | |
| 1 | Unique | NormalisedAlpha | 1.0 | types | subcommunity | [0.0, 10.0) × [0.0, 10.0) km | 9.83906 | |
| 2 | Unique | NormalisedAlpha | 1.0 | types | subcommunity | [10.0, 20.0) × [0.0, 10.0) km | 9.96828 | |
| 3 | Unique | NormalisedAlpha | 1.0 | types | subcommunity | [20.0, 30.0) × [0.0, 10.0) km | 9.87023 | |
| 4 | Unique | NormalisedAlpha | 1.0 | types | subcommunity | [30.0, 40.0) × [0.0, 10.0) km | 9.93373 | |
| 5 | Unique | NormalisedAlpha | 1.0 | types | subcommunity | [40.0, 50.0) × [0.0, 10.0) km | 9.86444 |
norm_meta_alpha(eco, 1.0) # or metacommunity measures - one row for the landscape| Row | div_type | measure | q | type_level | type_name | partition_level | partition_name | diversity |
|---|---|---|---|---|---|---|---|---|
| String | String | Float64 | String | String | String | String | Float64 | |
| 1 | Unique | NormalisedAlpha | 1.0 | types | metacommunity | 9.91511 |
Any measure takes several values of the viewpoint parameter q at once - 0 counts rare and common species alike, and larger values weight towards the commonest:
beta = norm_sub_beta(eco, 0.0:3.0) # one row per cell per q - 100 of them here
beta[beta.partition_name .== first(beta.partition_name), :] # one cell, all four q| Row | div_type | measure | q | type_level | type_name | partition_level | partition_name | diversity |
|---|---|---|---|---|---|---|---|---|
| String | String | Float64 | String | String | String | String | Float64 | |
| 1 | Unique | NormalisedBeta | 0.0 | types | subcommunity | [0.0, 10.0) × [0.0, 10.0) km | 1.0 | |
| 2 | Unique | NormalisedBeta | 1.0 | types | subcommunity | [0.0, 10.0) × [0.0, 10.0) km | 1.01635 | |
| 3 | Unique | NormalisedBeta | 2.0 | types | subcommunity | [0.0, 10.0) × [0.0, 10.0) km | 1.03165 | |
| 4 | Unique | NormalisedBeta | 3.0 | types | subcommunity | [0.0, 10.0) × [0.0, 10.0) km | 1.0457 |