Commit 275586a3 authored by LDalby's avatar LDalby
Browse files

Standarization now works

parent 13a94f3f
......@@ -43,49 +43,42 @@ path(current, jobs, grain_dist_file) %>%
goose_numbers_file <- glue("{jobs}_scenario-goose-numbers_{date_stamp}.fst")
path(current, jobs, goose_numbers_file) %>%
fst::read_fst() %>%
as_tibble() -> goose_numbers
left_join(goose_numbers, grain_dists, by = c("season", "param", "value")) -> goose_numbers
# Default numbers
goose_numbers %>%
as_tibble() %>%
left_join(grain_dists, by = c("season", "param", "value")) %>%
mutate(pinkfoot = pf_families + pf_non_breeders,
greylag = gl_families + gl_non_breeders,
barnacle = bn_families + bn_non_breeders,
day = day - 365L) %>%
day = day - 365L*season) %>%
select(-ends_with("families"), -ends_with("non_breeders")) -> goose_numbers
# Default numbers
goose_numbers %>%
filter(value == 1) %>%
select(param, season, day, pinkfoot, greylag, barnacle, grain_dist) %>%
gather(key = species, value = numbers, -param, -season, -day, -grain_dist) %>%
select(param, day, pinkfoot, greylag, barnacle, grain_dist) %>%
gather(key = species, value = numbers, -param, -day, -grain_dist) %>%
filter(numbers > 0) %>%
group_by(season, day, species, grain_dist) %>%
group_by(day, species, grain_dist) %>%
summarise(numbers = mean(numbers)) -> default_numbers
# Summarize field forage data ----
# Mean numbers per day
goose_numbers %>%
mutate(day = day - 365*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)) %>%
summarise_at(.vars = vars(pinkfoot, barnacle, greylag),
.funs = funs(mean)) %>%
ungroup() %>%
gather(key = species, value = numbers, -grain_dist, -param, -value, -day) %>%
filter(numbers > 0) -> numbers_per_day
# Read the default numbers and standardize
default_numbers %>%
mutate(species = case_when(species == "pinkfoot" ~ "pinkfoot_daily_avg",
species == "greylag" ~ "greylag_daily_avg",
species == "barnacle" ~ "barnacle_daily_avg",
TRUE ~ species)) %>%
left_join(numbers_per_day, .,
by = c("day", "species"),
by = c("grain_dist", "day", "species"),
suffix = c("", "_default")) %>%
mutate(standarized = numbers/numbers_default) -> numbers_per_day
goose_sp <- "pinkfoot_daily_avg"
goose_sp <- "pinkfoot"
goose_sp <- "greylag_daily_avg"
numbers_per_day %>%
filter(param == "GOOSE_BN_STARTNO_SCALER",
......@@ -99,7 +92,8 @@ numbers_per_day %>%
caption = "Numbers are average of 3 consecutive seasons",
y = "proportion of default numbers") +
facet_grid(~grain_dist)
# Works to down to here
goose_numbers %>%
select(replicate, grain_dist, param, value, season, pinkfoot, barnacle, greylag) %>%
......
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