Commit 13a94f3f authored by LDalby's avatar LDalby
Browse files

WIP: Default numbers object ready.

parent 9cef99e0
......@@ -33,32 +33,31 @@ dir_ls(current, glob = "*.out") %>%
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
# Grain distributions
grain_dist_file <- glue("{jobs}_scenario-grain-distributions_{date_stamp}.fst")
path_desktop("goose", date_stamp, jobs, grain_dist_file) %>%
path(current, jobs, grain_dist_file) %>%
fst::read_fst() %>%
as_tibble() -> grain_dists
left_join(goose_numbers, grain_dists, by = c("param", "value", "season")) -> goose_numbers
default_numbers_file <- glue("{jobs}_scenario-goose-numbers_{date_stamp}.fst")
path_desktop("goose", date_stamp, jobs, default_numbers_file) %>%
goose_numbers_file <- glue("{jobs}_scenario-goose-numbers_{date_stamp}.fst")
path(current, jobs, goose_numbers_file) %>%
fst::read_fst() %>%
as_tibble() %>%
as_tibble() -> goose_numbers
left_join(goose_numbers, grain_dists, by = c("season", "param", "value")) -> goose_numbers
# Default numbers
goose_numbers %>%
mutate(pinkfoot = pf_families + pf_non_breeders,
greylag = gl_families + gl_non_breeders,
barnacle = bn_families + bn_non_breeders,
day = day - 365L) %>%
filter(value == 1) %>%
select(day, pinkfoot, greylag, barnacle) %>%
gather(key = species, value = numbers, -day) %>%
select(param, season, day, pinkfoot, greylag, barnacle, grain_dist) %>%
gather(key = species, value = numbers, -param, -season, -day, -grain_dist) %>%
filter(numbers > 0) %>%
group_by(day, species) %>%
summarise(numbers = median(numbers)) -> default_numbers
group_by(season, day, species, grain_dist) %>%
summarise(numbers = mean(numbers)) -> default_numbers
# Summarize field forage data ----
# Mean numbers per day
......@@ -126,5 +125,74 @@ numbers_per_season %>%
y = expression("Goose days" %*% 1e-6),
x = "Baseline input number scaler") +
scale_x_continuous(breaks = c(2,4,6,8,10))
```
```{r}
default_numbers_file <- glue("{jobs}_scenario-goose-numbers_{date_stamp}.fst")
path_desktop("goose", date_stamp, jobs, default_numbers_file) %>%
fst::read_fst() %>%
as_tibble() %>%
mutate(pinkfoot = pf_families + pf_non_breeders,
greylag = gl_families + gl_non_breeders,
barnacle = bn_families + bn_non_breeders,
day = day - 365L*season) -> goose_numbers
left_join(goose_numbers, grain_dists, by = c("param", "value", "season")) -> goose_numbers
goose_numbers %>%
mutate(day = day - 365L*season) %>%
select(grain_dist, param, value, season, day, pinkfoot, barnacle, greylag) %>%
group_by(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
goose_numbers %>%
filter(value == 1) %>%
select(grain_dist, day, pinkfoot, greylag, barnacle) %>%
gather(key = species, value = numbers, -day, -grain_dist) %>%
filter(numbers > 0) %>%
group_by(day, species, grain_dist) %>%
summarise(default_numbers = round(mean(numbers))) -> default_numbers
goose_numbers %>%
select(season, param, value, grain_dist, day, pinkfoot, greylag, barnacle) %>%
gather(key = species, value = numbers, -day, -season, -param, -value, -grain_dist) %>%
filter(numbers > 0) %>%
left_join(default_numbers, by = c("day", "species", "grain_dist")) %>%
mutate(standarized = numbers/default_numbers) -> foo
goose_sp <- "pinkfoot"
goose_sp <- "greylag_daily_avg"
foo %>%
filter(param == "GOOSE_BN_STARTNO_SCALER",
species == goose_sp) %>%
ggplot(aes(day, standarized)) +
geom_line(aes(color = factor(value))) +
scale_color_brewer(palette = "Set3", 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 3 consecutive seasons",
y = "proportion of default numbers") +
facet_grid(~grain_dist)
```
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