Running through this to extract raw from move_list and saving raw output df so some of these can run on the mini without moving the entire RDS dir.
``` {r eval = FALSE} source(‘~/ebs/RCode/nip_drake/R/functions.R’) source(‘~/ebs/RCode/nip_drake/R/packages.R’)
first build_move for all indiv of interest
meta <- read.table(‘./RawData/all_tag_meta.csv’, sep=’,’, header=T, stringsAsFactors = F) meta <- meta[which(meta$etuff == 1 & meta$instrument_type == ‘satellite’ & meta$platform == ‘Prionace glauca’ & meta$person_owner != ‘TOPP’),]
rds_files <- list.files(‘~/ebs/RCode/nip_drake/move_res/’, full.names = TRUE) rds_ids <- rep(NA, length.out=length(rds_files)) for (i in 1:length(rds_ids)) rds_ids[i] <- substr(rds_files[i], stringr::str_locate(rds_files[i], ‘//’)[2] + 1, stringr::str_locate(rds_files[i], ‘_move’)[1] - 1)
idx <- which(rds_ids %in% meta$instrument_name)
make move_list from mako RDS files
move_list = make_move_list(rds_files[idx], meta_only = FALSE)
pred <- lapply(move_list$move_eddies, FUN=function(x) x$pred) %>% do.call(rbind, .) #combine to one major move_eddies, retaining IDs
raw <- lapply(move_list$move_eddies, FUN=function(x) x$raw) %>% do.call(rbind, .) #combine to one major move_eddies, retaining IDs
library(bsam) data(ellie) raw$lc <- ordered(as.factor(raw$lc), levels = levels(ellie$lc))
save(raw, file=’./RawData/prep_bsam_Gcuvier_20200310.rda’)
Resulting in 70 I. oxyrinchus, 75 R. typus, 71 C. carcharias, 75 P. glauca, 165 G. cuvier
The blue shark bsam that's already complete included the TOPP data so make sure to filter later to remove those.
``` {r eval = FALSE}
load('~/ebs/Results/eddies/run_bsam_all_blues_20200129.rda')
df <- bsam_blues_hdcrws$summary
df$lon2 <- ifelse(df$lon < 0, df$lon + 360, df$lon)
load('./RawData/prep_bsam_Pglauca_20200310.rda')
unique(raw$id)[which(!(unique(raw$id) %in% unique(df$id)))]
which(df$id %in% raw$id[1] & df$id == raw$date[1])
Ready to run bsam on remaining species. ``` {r eval = FALSE}
library(bsam) load(‘./RawData/prep_bsam_Gcuvier_20200310.rda’) bsam_gcuvier_hdcrws <- bsam::fit_ssm(raw, model = “hDCRWS”, tstep = 12 / 24, adapt = 60000, samples = 20000, thin = 20)
Elapsed time: 4070.5 min | ~68 hrs
save.image(‘~/ebs/Results/eddies/run_bsam_all_Gcuvier_20200310.rda’)
```