Commit 85979492 authored by LDalby's avatar LDalby
Browse files

WIP: cp-ing from draft scenario res compiler

parent 207e38b4
......@@ -14,16 +14,106 @@ knitr::opts_chunk$set(echo = FALSE,
```{r load, message=FALSE, include=FALSE}
library(ralmass)
library(pathfinder)
library(tidyverse)
library(viridis)
library(fs)
library(colorblindr)
library(here)
library(glue)
date_stamp <- "2019-01-04"
```
Document compiled: `r Sys.time()`
```{r read-results, echo=FALSE}
current <- path_desktop("goose", date_stamp)
dir_ls(current, glob = "*.out") %>%
path_file() %>%
path_ext_remove() %>%
as.character() %>%
str_extract("[[:digit:]]+") -> jobs
res_file <- glue("{jobs}_scenario-results_{date_stamp}.fst")
path_desktop("goose", date_stamp, jobs, res_file) %>%
fst::read_fst() %>%
as_tibble() -> goose_numbers
path_desktop("Goose", date_stamp, jobs, "scenario-grain-distributions.txt_1521869_2018-11-12.fst") %>%
# path_desktop("Goose", date_stamp, jobs, "scenario-grain-distributions.txt_2057427_2018-12-29.fst") %>%
fst::read_fst() %>%
as_tibble() -> grain_dists
grain_dists %>% group_by(param, value) %>% count(grain_dist)
left_join(goose_numbers, grain_dists, by = c("param", "value", "season")) -> goose_numbers
goose_numbers %>%
mutate(replicate = 1L) -> goose_numbers
goose_numbers <- bind_rows(goose_numbers, goose_numbers_2)
# Summarize field forage data ----
# Mean numbers per day
goose_numbers %>%
mutate(day = day - 365*season) %>%
select(replicate, grain_dist, param, value, season, day, pinkfoot, barnacle, greylag) %>%
group_by(replicate, grain_dist, param, value, season, day) %>%
summarise_at(.vars = vars(pinkfoot, barnacle, greylag),
.funs = funs(daily = sum)) %>%
group_by(grain_dist, param, value, day) %>%
summarise_at(.vars = vars(ends_with("daily")),
.funs = funs(avg = mean,
min, max)) %>%
ungroup() %>%
gather(key = species, value = numbers, -grain_dist, -param, -value, -day) %>%
filter(numbers > 0) -> numbers_per_day
numbers_per_day %>%
filter(value == 1) -> default
left_join(numbers_per_day, default,
by = c("grain_dist", "param", "day", "species"),
suffix = c("", "_default")) %>%
mutate(standarized = numbers/numbers_default) -> numbers_per_day
goose_sp <- "pinkfoot_daily_avg"
goose_sp <- "greylag_daily_avg"
numbers_per_day %>%
filter(param == "GOOSE_BN_STARTNO_SCALER",
species == goose_sp) %>%
ggplot(aes(day, standarized)) +
geom_line(aes(color = factor(value))) +
scale_color_viridis_d(name = "Barnacle scaler") +
hrbrthemes::theme_ipsum_rc(axis_title_size = 12) +
labs(title = "Daily average numbers",
subtitle = "Pinkfeet numbers as a function of barnacle numbers",
caption = "Numbers are average of 10 consecutive seasons",
y = "proportion of default numbers") +
facet_grid(~grain_dist)
goose_numbers %>%
select(replicate, grain_dist, param, value, season, pinkfoot, barnacle, greylag) %>%
group_by(replicate, grain_dist, param, value, season) %>%
summarise(pinkfoot = sum(pinkfoot, na.rm = TRUE),
barnacle = sum(barnacle, na.rm = TRUE),
greylag = sum(greylag, na.rm = TRUE)) %>%
group_by(grain_dist, param, value, season) %>%
summarise(pinkfoot = mean(pinkfoot, na.rm = TRUE),
barnacle = mean(barnacle, na.rm = TRUE),
greylag = mean(greylag, na.rm = TRUE)) %>%
gather(key = species, value = numbers, -grain_dist, -param, -value, -season) -> numbers_per_season
numbers_per_season %>%
filter(param == "GOOSE_BN_STARTNO_SCALER") %>%
ggplot(aes(value, numbers/1e6)) +
geom_point(alpha = 0.5) +
geom_smooth() +
facet_grid(species ~ grain_dist, scales = "free_y") +
hrbrthemes::theme_ipsum_rc(axis_title_size = 12) +
labs(title = "Goose days as a function of barnacle goose input numbers",
y = expression("Goose days" %*% 1e-6),
x = "Baseline input number scaler") +
scale_x_continuous(breaks = c(2,4,6,8,10))
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment