Commit 5ef4e74e authored by LDalby's avatar LDalby
Browse files

WIP: redo the default numbers calculation based on the new file dumped from grendel

parent b3b3bce2
...@@ -45,33 +45,41 @@ path_desktop("goose", date_stamp, jobs, grain_dist_file) %>% ...@@ -45,33 +45,41 @@ path_desktop("goose", date_stamp, jobs, grain_dist_file) %>%
fst::read_fst() %>% fst::read_fst() %>%
as_tibble() -> grain_dists 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 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) 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) %>%
filter(param == "GOOSE_STARTNO_SCALER",
value == 1,
season == 1) %>%
select(day, pinkfoot, greylag, barnacle) %>%
gather(key = species, value = numbers, -day) %>%
filter(numbers > 0) -> default_numbers
# Summarize field forage data ---- # Summarize field forage data ----
# Mean numbers per day # Mean numbers per day
goose_numbers %>% goose_numbers %>%
mutate(day = day - 365*season) %>% mutate(day = day - 365*season) %>%
select(replicate, grain_dist, param, value, season, day, pinkfoot, barnacle, greylag) %>% select(grain_dist, param, value, season, day, pinkfoot, barnacle, greylag) %>%
group_by(replicate, grain_dist, param, value, season, day) %>% group_by(grain_dist, param, value, season, day) %>%
summarise_at(.vars = vars(pinkfoot, barnacle, greylag), summarise_at(.vars = vars(pinkfoot, barnacle, greylag),
.funs = funs(daily = sum)) %>% .funs = funs(daily = sum)) %>%
group_by(grain_dist, param, value, day) %>% group_by(grain_dist, param, value, day) %>%
summarise_at(.vars = vars(ends_with("daily")), summarise_at(.vars = vars(ends_with("daily")),
.funs = funs(avg = mean, .funs = funs(avg = mean, min, max)) %>%
min, max)) %>%
ungroup() %>% ungroup() %>%
gather(key = species, value = numbers, -grain_dist, -param, -value, -day) %>% gather(key = species, value = numbers, -grain_dist, -param, -value, -day) %>%
filter(numbers > 0) -> numbers_per_day filter(numbers > 0) -> numbers_per_day
numbers_per_day %>% # Read the default numbers and standardize
filter(value == 1) -> default left_join(numbers_per_day, default_numbers,
left_join(numbers_per_day, default, by = c("day", "species"),
by = c("grain_dist", "param", "day", "species"),
suffix = c("", "_default")) %>% suffix = c("", "_default")) %>%
mutate(standarized = numbers/numbers_default) -> numbers_per_day mutate(standarized = numbers/numbers_default) -> numbers_per_day
......
Supports Markdown
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