---
title: "View Simulation Results"
---
```{r, include = FALSE, cache = FALSE}
library(tidyverse)
library(lubridate)
library(ggpubr)
library(egg)
library(RColorBrewer)
library(ggridges)
library(patchwork)
library(scales)
source("Functions.R")
source("PlotResults.R")
```
**Purpose:** View raw simulation results of fixed habitat/equilibrium simulation runs.
## Setup
Load each result .rds object and bind directly into a list. Using a helper function ensures each `res` object is freed from memory as soon as `ibm_long` is extracted, avoiding duplicate references that would force R to copy the data frames.
```{r}
#| cache: false
# Extract params from one file (small object)
res <- readRDS("results/TempOffset_ColdWarm_05percold_highPwarm.rds")
sim_params <- res$params
habitat_df <- res$habitat_df
exp_start_date <- sim_params$mindate + years(sim_params$nyears_burnin)
rm(res)
# Helper: read one scenario, extract ibm_long, and free res before returning
load_scen <- function(path, pc, ht, pcmax_cold, pcmax_warm) {
res <- readRDS(path)
list(df = res$ibm_long, pc = pc, ht = ht, pcmax_cold = pcmax_cold, pcmax_warm = pcmax_warm)
}
ibm_list_mech <- list(
load_scen("results/TempOffset_ColdOnly_95percold.rds", 0.95, "Cold only", 0.5, NA_real_),
load_scen("results/TempOffset_ColdOnly_75percold.rds", 0.75, "Cold only", 0.5, NA_real_),
load_scen("results/TempOffset_ColdOnly_50percold.rds", 0.50, "Cold only", 0.5, NA_real_),
load_scen("results/TempOffset_ColdOnly_25percold.rds", 0.25, "Cold only", 0.5, NA_real_),
load_scen("results/TempOffset_ColdOnly_05percold.rds", 0.05, "Cold only", 0.5, NA_real_),
load_scen("results/TempOffset_ColdWarm_95percold.rds", 0.95, "Cold + Warm", 0.5, 0.5),
load_scen("results/TempOffset_ColdWarm_75percold.rds", 0.75, "Cold + Warm", 0.5, 0.5),
load_scen("results/TempOffset_ColdWarm_50percold.rds", 0.50, "Cold + Warm", 0.5, 0.5),
load_scen("results/TempOffset_ColdWarm_25percold.rds", 0.25, "Cold + Warm", 0.5, 0.5),
load_scen("results/TempOffset_ColdWarm_05percold.rds", 0.05, "Cold + Warm", 0.5, 0.5),
load_scen("results/TempOffset_ColdWarm_95percold_highPwarm.rds", 0.95, "Cold + Warm (high P)", 0.5, 0.6),
load_scen("results/TempOffset_ColdWarm_75percold_highPwarm.rds", 0.75, "Cold + Warm (high P)", 0.5, 0.6),
load_scen("results/TempOffset_ColdWarm_50percold_highPwarm.rds", 0.50, "Cold + Warm (high P)", 0.5, 0.6),
load_scen("results/TempOffset_ColdWarm_25percold_highPwarm.rds", 0.25, "Cold + Warm (high P)", 0.5, 0.6),
load_scen("results/TempOffset_ColdWarm_05percold_highPwarm.rds", 0.05, "Cold + Warm (high P)", 0.5, 0.6)
)
```
## Null: cold only
### 95% cold
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[1]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 75% cold
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[2]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 50% cold
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[3]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 25% cold
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[4]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 5% cold
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[5]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
---
## Cold + Warm, same Pcmax
### 95% cold / 5% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[6]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 75% cold / 25% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[7]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 50% cold / 50% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[8]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 25% cold / 75% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[9]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 5% cold / 95% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[10]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
---
## Cold + Warm, high Pcmax in warm (0.6)
### 95% cold / 5% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[11]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 75% cold / 25% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[12]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 50% cold / 50% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[13]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 25% cold / 75% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[14]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
### 5% cold / 95% warm
Daily and annual abundance/biomass, age structure, weight-at-age, body-size distributions, survival, lambda, and cohort survivorship.
```{r}
#| fig-width: 10
#| fig-height: 6
plot_population(
ibm_long = ibm_list_mech[[15]][[1]],
habitat_df = habitat_df,
exp_start_date = exp_start_date
)
```
---