From 222723c133d731b48f6096b8c0527d7f1bfb24f1 Mon Sep 17 00:00:00 2001 From: Romain Forestier Date: Wed, 31 Aug 2022 10:14:22 +1000 Subject: [PATCH 1/5] file path can lead to confusion as it is not the same as in the associated worksheet --- use/further-scenarios.qmd | 2 +- use/{toothfish => }/longline.rds | Bin 2 files changed, 1 insertion(+), 1 deletion(-) rename use/{toothfish => }/longline.rds (100%) diff --git a/use/further-scenarios.qmd b/use/further-scenarios.qmd index bca5e17..9dc381a 100644 --- a/use/further-scenarios.qmd +++ b/use/further-scenarios.qmd @@ -109,7 +109,7 @@ The abundance of some (but not all) of the smaller to medium sizes of prey are a Mizer can also be used to carry out projections with changes in fishing effort. We will start by reading in a time series of catch and effort. We will read in the effort data for this fishery. Note: these are not the correct effort values, they are only for illustration in this example. Then we plot effort and catch through time. ```{r, code_folding=TRUE} -dat <- readRDS("toothfish/longline.rds") +dat <- readRDS("longline.rds") plot_dat <- melt(dat, "Year") ggplot(plot_dat, aes(x = Year, y = value)) + diff --git a/use/toothfish/longline.rds b/use/longline.rds similarity index 100% rename from use/toothfish/longline.rds rename to use/longline.rds From d80d2b2800f358324c08a1fa7fe8decc9b6d1d59 Mon Sep 17 00:00:00 2001 From: Romain Forestier Date: Wed, 31 Aug 2022 10:19:12 +1000 Subject: [PATCH 2/5] sim0 is never saved in this version of the course so it cannot be loaded just by copying the code there --- use/further-scenarios.qmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/use/further-scenarios.qmd b/use/further-scenarios.qmd index 9dc381a..20ee817 100644 --- a/use/further-scenarios.qmd +++ b/use/further-scenarios.qmd @@ -281,8 +281,7 @@ Let's take a look at the relative exploitation status of the stocks using the pr ```{r} # plot change in biomass under each scenario relative to unfished values -# get saved values from steady state without fishing that we generated earlier -sim0<-readRDS("sim0.rds") +# using the sim0 values from steady state without fishing that we generated earlier # get the unfished biomasses B_unfished <- getBiomass(sim0)[1, ] #scen 1 From 1b6631be53af03e3d4b23d06de39d482ca956ce0 Mon Sep 17 00:00:00 2001 From: Romain Forestier Date: Wed, 31 Aug 2022 14:55:24 +1000 Subject: [PATCH 3/5] editing legend so it fits caption --- use/change-resources.qmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/use/change-resources.qmd b/use/change-resources.qmd index 2b62d6d..a4d91cd 100644 --- a/use/change-resources.qmd +++ b/use/change-resources.qmd @@ -76,14 +76,14 @@ c_R <- (mu_bar + r_R) / r_R * N_bar mu_R <- seq(0, 2, by = 0.05) N_R <- c_R * r_R / (mu_R + r_R) df <- melt(data.frame(N_R, mu_R, c_R), id.vars = "mu_R") -df$dd <- "Low" +df$dd <- "High" r_R <- 2 c_R <- (mu_bar + r_R) / r_R * N_bar mu_R <- seq(0, 2, by = 0.05) N_R <- c_R * r_R / (mu_R + r_R) df2 <- melt(data.frame(N_R, mu_R, c_R), id.vars = "mu_R") -df2$dd <- "High" +df2$dd <- "Low" df <- rbind(df, df2) df <- df[df$value < 2.1, ] @@ -97,7 +97,7 @@ ggplot(rbind(df, df2)) + breaks = N_bar, labels = c("N_R")) + scale_x_continuous(name = "Resource mortality rate [1/year]", breaks = mu_bar, labels = c("mu_R")) + - scale_colour_manual(values = c("black", "blue")) + + scale_colour_manual(values = c("blue","black")) + scale_linetype_manual(values = c("solid", "dotted")) ``` From 242f3d531dd5d62a0b361f2c4f1a231787495fda Mon Sep 17 00:00:00 2001 From: Gustav Delius Date: Mon, 27 Nov 2023 19:55:44 +0000 Subject: [PATCH 4/5] Minor corrections and changes. --- build/create-first-model.qmd | 4 ++-- build/set-multiple-resources.qmd | 2 +- understand/predation-growth-and-mortality.qmd | 3 ++- understand/single-species-spectra.qmd | 4 ++-- understand/species-interactions.qmd | 8 +++++--- use/change-resources.qmd | 5 +++-- use/fishing-scenarios.qmd | 2 +- use/tune-resilience.qmd | 2 +- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/build/create-first-model.qmd b/build/create-first-model.qmd index ad95c23..80cc0e2 100644 --- a/build/create-first-model.qmd +++ b/build/create-first-model.qmd @@ -38,7 +38,7 @@ curonian_interaction <- read.csv("curonian_interaction.csv", row.names = 1) We use `rownames = 1` to let `read.csv` know that the first column in the spreadsheet, which contains the predator names, should be used as the names of the rows of the interaction matrix. -When you repeat this work in your worksheet, you can check that the data was read in correctly by clicking on `curonian_species_params`, `curonian_species_params` and `curonian_interaction` in the "Environment" tab. That will open the data frames in your editor window for you to inspect. +When you repeat this work in your worksheet, you can check that the data was read in correctly by clicking on `curonian_species_params`, `curonian_gear_params` and `curonian_interaction` in the "Environment" tab. That will open the data frames in your editor window for you to inspect. We will now set up a multi-species mizer model using the function `newMultispeciesParams()`. Besides the species parameters, the gear parameters and the interaction matrix, the other information that flows into a multi-species model are the resource parameters, the allometric exponents `n` and `p` and the fishing effort. @@ -84,7 +84,7 @@ We will now project to the steady state, which will finally give us realistic sp cur_model <- steady(cur_model) ``` -We can ignore the warning from the `setBevertonHolt()` function about unrealistic reproductive efficiencies. Those warnings are an artefact of how the reproduction level is set by default by the `matchBiomasses()` function. We could fix those defaults, but we are not yet concerned with the reproduction dynamics so we don't have to do that and just ignore the warnings. +We can ignore the warning from the `setBevertonHolt()` function about unrealistic reproductive efficiencies. Those warnings are an artefact of how the reproduction level is set by default. We could fix those defaults, but we are not yet concerned with the reproduction dynamics so we don't have to do that and just ignore the warnings. ::: {.callout-important collapse="false"} Remember, the steady() function does not yet calibrate your model to any observed biomasses or catches. It simply runs the model to find a state where species spectra stop changing. If you start a simulation from initial biomasses that the set of current species and resource parameters cannot support, species biomasses will change drastically at the start. Perhaps there are too many predators at the start, or too many fish for the resource to support it. After a while these fluctuations will settle down (hopefully) and species biomasses will be stable for a given set of parameters. Of course, since we are keeping reproduction and resource levels constant, this is not yet a final model. diff --git a/build/set-multiple-resources.qmd b/build/set-multiple-resources.qmd index 4d8142a..34e466e 100644 --- a/build/set-multiple-resources.qmd +++ b/build/set-multiple-resources.qmd @@ -6,7 +6,7 @@ title: "Setting up multiple resources" Most mizer models simulate multiple size structured species and one background resource. But what if you want to account for different types of 'resources' with different dynamics? The most obvious case is the separation of pelagic and benthic resource. Benthic resource may not be important for offshore or pelagic ecosystems, but if you want to model coastal or freshwater ecosystems this may become essential. -Adding benthic resource into multi-species and size based models is not new. Some researchers incorporate benthic food sources by explicitly modelling key benthic species as size-structured groups. This is fine if you have data on their biomases for calibration and if you are interested in their dynamics, but modelling many benthic species separately might be overwhelming. Instead, just like with plankton species, we might want to model all benthic organisms as a separate resource spectrum. That is what the mizerMR extension does. +Adding benthic resource into multi-species and size based models is not new. Some researchers incorporate benthic food sources by explicitly modelling key benthic species as size-structured groups. This is fine if you have data on their biomasses for calibration and if you are interested in their dynamics, but modelling many benthic species separately might be overwhelming. Instead, just like with plankton species, we might want to model all benthic organisms as a separate resource spectrum. That is what the mizerMR extension does. The origin of mizerMR is a [model for Tasmanian coastal rocky reef ecosystem](https://doi.org/10.1101/2022.06.20.496925), where most large fish are not predators (like in a classical size based marine ecosystem), but feed on benthic invertebrates. In such reefs, benthic production pathway is likely to be a major source of energy. The mizerMR framework has also been used in a [Baltic Sea mizer model](https://onlinelibrary.wiley.com/doi/full/10.1111/gcb.16341) and a [south-east Australian mizer model](https://besjournals.onlinelibrary.wiley.com/doi/abs/10.1111/1365-2664.14086). There are other ways to incorporate benthic resources, and you can find some examples [here](https://onlinelibrary.wiley.com/doi/epdf/10.1111/geb.13348), [here](https://link.springer.com/article/10.1007/s12080-010-0078-9) and [here](https://onlinelibrary.wiley.com/doi/abs/10.1111/oik.05630), but none of these approaches are currently implemented in the main mizer code. diff --git a/understand/predation-growth-and-mortality.qmd b/understand/predation-growth-and-mortality.qmd index 03a27a1..1e326c0 100644 --- a/understand/predation-growth-and-mortality.qmd +++ b/understand/predation-growth-and-mortality.qmd @@ -344,7 +344,8 @@ We can now see how fishing affects the adult size spectrum. # We find the new steady state with fishing mortality imposed params_fishing <- singleSpeciesSteady(params_fishing) -plotSpectra2(params, "No Fishing", params_fishing, "Knife-edge", +plotSpectra2(params, name1 = "No Fishing", + params_fishing, name2 = "Knife-edge", power = 2, wlim = c(10, NA)) ``` diff --git a/understand/single-species-spectra.qmd b/understand/single-species-spectra.qmd index 730a3b1..8c71c72 100644 --- a/understand/single-species-spectra.qmd +++ b/understand/single-species-spectra.qmd @@ -447,8 +447,8 @@ params_changed_maturity <- singleSpeciesSteady(params_changed_maturity) Then we can use the function `plotSpectra2()` to plot the old size spectrum and the new size spectrum on the same graph. ```{r} -plotSpectra2(params, "Early maturity", - params_changed_maturity, "Late maturity", +plotSpectra2(params, name1 = "Early maturity", + params_changed_maturity, name2 = "Late maturity", power = 2, resource = FALSE, wlim = c(10, NA)) ``` diff --git a/understand/species-interactions.qmd b/understand/species-interactions.qmd index f335e7b..f174dde 100644 --- a/understand/species-interactions.qmd +++ b/understand/species-interactions.qmd @@ -21,7 +21,7 @@ In this first week we aim for understanding, not realism. So in this tutorial we We use the `newTraitParams()` function to create our idealised trait-based multi-species model. The function has many parameters, but we will just keep the defaults. Unlike the `newSingleSpeciesParams()` function, the `newTraitParams()` function does not set the initial spectra to their steady state values. We thus need to run the result through the `steady()` function (we'll discuss that function more next week). We assign the resulting MizerParams object to the variable `mp`. -```{r} +```{r message=FALSE} mp <- newTraitParams() |> steady() ``` @@ -231,7 +231,8 @@ mp_lessRes_steady <- projectToSteady(mp_lessRes) ``` ```{r} -plotSpectra2(mp_lessRes_steady, "less resource", mp, "original", +plotSpectra2(mp_lessRes_steady, name1 = "less resource", + mp, name2 = "original", total = TRUE, power = 2, ylim = c(1e-8, NA), wlim = c(1e-3, NA)) ``` @@ -240,7 +241,8 @@ There is much to see in this graph. We can see how the reduction in the abundanc Perhaps you would prefer to plot the above graph with `power = 1`, which will show the biomass density in weight instead of the Sheldon spectrum. Different people find different options more intuitive. ```{r} -plotSpectra2(mp_lessRes_steady, "less resource", mp, "original", +plotSpectra2(mp_lessRes_steady, name1 = "less resource", + mp, name2 = "original", total = TRUE, power = 1, ylim = c(1e-8, NA), wlim = c(1e-3, NA)) ``` diff --git a/use/change-resources.qmd b/use/change-resources.qmd index a4d91cd..897234c 100644 --- a/use/change-resources.qmd +++ b/use/change-resources.qmd @@ -210,7 +210,8 @@ cm_less_be <- setResourceSemichemostat(cm, rp_less_be) Let's check that resource abundances really changed by plotting the spectra ```{r} -plotSpectra2(cm_more_be, "More", cm_less_be, "Less", power = 2) +plotSpectra2(cm_more_be, name1 = "More", + cm_less_be, name2 = "Less", power = 2) ``` As we discussed before, while the `setResourceSemichemostat()` has set the resource carrying capacity so that initially the new resource abundance is steady, the fish abundances will change over time in response to the changed resource abundance and as a result also the resource abundance will start to change. Let us investigate that by projecting for 50 years with the new level and compare to the unchanged conditions. @@ -264,7 +265,7 @@ cm_more_be <- setResourceSemichemostat(cm, rp_more_be) cm_less_be <- setResourceSemichemostat(cm, rp_less_be) # Check on the spectra plot that the changes have taken place -plotSpectra2(cm_more_be, "More", cm_less_be, "Less", power = 2) +plotSpectra2(cm_more_be, name1 = "More", cm_less_be, name2 = "Less", power = 2) ``` Now we will project for 50 years with the new level and see how the biomasses are changed diff --git a/use/fishing-scenarios.qmd b/use/fishing-scenarios.qmd index cc12576..66b3a05 100644 --- a/use/fishing-scenarios.qmd +++ b/use/fishing-scenarios.qmd @@ -70,7 +70,7 @@ We can see that, surprisingly, after doubling fishing effort on all species, the To understand how that is possible, we have to look at how the spectra have changed. After all mizer is all about changes at size. Looking at overall biomasses does not tell use about size dynamics. We can compare the spectra using the `plotSpectra2()` function: ```{r} -plotSpectra2(sim_double_effort, 'double', cm, 'same', power = 2) +plotSpectra2(sim_double_effort, name1 = 'double', cm, name2 = 'same', power = 2) ``` Again, the changes are more visible if we plot relative change with respect to the initial spectra: diff --git a/use/tune-resilience.qmd b/use/tune-resilience.qmd index e570655..b807de1 100644 --- a/use/tune-resilience.qmd +++ b/use/tune-resilience.qmd @@ -245,7 +245,7 @@ To measure the resilience of our species to fishing, we will change the fishing plotYieldCurve(cm_generic_gear, species = "smallfish", F_max = 2) ``` -We refer to the yield achieved in the steady state as the *sustainable yield* (SY) because because it can be sustained indefinitely. The sustainable yield for this species has a maximum (MSY) at a fishing mortality of about 0.8. We refer to this value as $F_{MSY}$. The small fish have a high resilience to fishing. This is close enough to expectations, so we judge that it is not necessar to make changes to the resource level of "smallfish". +We refer to the yield achieved in the steady state as the *sustainable yield* (SY) because because it can be sustained indefinitely. The sustainable yield for this species has a maximum (MSY) at a fishing mortality of about 0.8. We refer to this value as $F_{MSY}$. The small fish have a high resilience to fishing. This is close enough to expectations, so we judge that it is not necessary to make changes to the resource level of "smallfish". Next we look at ruffe. This is classified as a medium resilience species, so we would like the $F_{MSY}$ to be between 0.1 and 0.5. From 3c53bea5d9a3a0bae064676ecea41b91c475e378 Mon Sep 17 00:00:00 2001 From: Gustav Delius Date: Mon, 27 Nov 2023 19:59:50 +0000 Subject: [PATCH 5/5] Missed in previous commit --- understand/dynamics-of-spectra.qmd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/understand/dynamics-of-spectra.qmd b/understand/dynamics-of-spectra.qmd index 0357731..1aca9b6 100644 --- a/understand/dynamics-of-spectra.qmd +++ b/understand/dynamics-of-spectra.qmd @@ -42,7 +42,7 @@ library(tidyverse) In the previous tutorial, in the section on [trophic cascades](species-interactions.qmd#trophic-cascades), we already simulated the size-spectrum dynamics to find the new steady state. But we only looked at the final outcome once the dynamics had settled down to the new steady state. We reproduce the code here: -```{r} +```{r message=FALSE} # Create trait-based model mp <- newTraitParams() |> # run to steady state with constant reproduction rate @@ -60,7 +60,8 @@ species_params(mp_lessRes)$interaction_resource[8:11] <- 0.8 mp_lessRes_steady <- projectToSteady(mp_lessRes) # We compare the steady states -plotSpectra2(mp_lessRes_steady, "less resource", mp, "original", +plotSpectra2(mp_lessRes_steady, name1 = "less resource", + mp, name2 = "original", total = TRUE, power = 2, ylim = c(1e-8, NA), wlim = c(1e-3, NA)) ``` @@ -114,7 +115,7 @@ The above simulation was run with constant abundance in the smallest size class To see the effect we run the same code as above after deleting the two lines that turned off the reproduction dynamics. We also specify with `t_save = 2` that we want to save the spectrum only every second year, which speeds up the display of the animation. -```{r} +```{r message=FALSE} # Create trait-based model mp <- newTraitParams() |> # run to steady state with constant reproduction rate @@ -241,7 +242,8 @@ Changing the reproduction level has no effect on the steady state, because that ```{r} mp9 <- projectToSteady(mp9) -plotSpectra2(mp, "reproduction_level = 0.25", mp9, "reproduction_level = 0.9", +plotSpectra2(mp, name1 = "reproduction_level = 0.25", + mp9, name2 = "reproduction_level = 0.9", total = TRUE, power = 2, ylim = c(1e-8, NA), wlim = c(1e-3, NA)) ```