library(MCE)                                               # Load the package
library(dplyr)                                             # Load some data manipulation tools

data.frame(Light = seq(0.001, 1, length = 500)) %>%        # Choose light levels
  mutate("Bright depths" = depth(Light),                   # Calculate depths
         "Shaded depths" = depth(Light, shade = 0.25),     # Calculate depths with shading
         "Shallow community" = shallow(Light),             # Shallow community at these light levels
         "Mesophotic community" = mesophotic(Light),       # Mesophotic community at these light levels
         "Whole reef" = reef(Light)) -> depth.distribution # Calculate reef-wide community values

As the default light levels are shared across all the functions, specifying a set of light levels isn’t really neccessary. You would get the same result not specifying Light anywhere in the above code. I think including it helps to show how things are working, and makes the code more readable.

The following table show’s the values we simulated.

Light Bright depths Shaded depths Shallow community Mesophotic community Whole reef
0.001000 138.15511 110.42922 0.0028897 0.0152591 0.0123694
0.003002 116.16950 88.44362 0.0085491 0.0275055 0.0189565
0.005004 105.95032 78.22443 0.0140466 0.0360121 0.0219655
0.007006 99.21973 71.49385 0.0193891 0.0428429 0.0234538
0.009008 94.19281 66.46692 0.0245830 0.0486119 0.0240289

We don’t actually need to go to the effort of simulating a reef to get the boundary depths between the shallow, upper mesophotic, and lower mesophotic zones. MCE comes with a built in reef_boundary function which returns the light level where a patch of reef would look just as much shallow as it does mesophotic.

If we pass this light level to the depth function, we can then get the shallowest and deepest depths where the two communities overlap. This is the same as identifying the upper and lower limits of the upper mesophotic zone.

boundaries <- data.frame(Boundary = c("lower", "upper"),
                         Depth = c(depth(reef_boundary()), depth(reef_boundary(), shade = 0.25)))
Boundary Depth
lower 66.53724
upper 38.81135