-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
153 lines (153 loc) · 4.93 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
setwd("C:/Users/Francisco/Documents")
install.packages("pacman")
library(pacman)
packages <- readLines(file_path)
file_path <- "r_packages.txt"
packages <- readLines(file_path)
# Remove any empty lines
packages <- packages[packages != ""]
# Use p_load to install and load packages
p_load(packages, character.only = TRUE)
install.packages("rafalib")
install.packages("ggExtra")
install.packages("factoextra")
library(tidyverse)
library(sp)
# library(rgdal)
# library(rgeos)
library(ctmm)
# library(tlocoh)
library(lubridate)
library(beepr)
library(plotly)
library(parallel)
library(doParallel)
library(cli)
setwd("C:/Users/xacfr/OneDrive/Bears")
load("C:/Users/Francisco/OneDrive/Bears/ctmm_2024.RData")
# set parallelization method
cl <- makeCluster(detectCores() - 2, type= "PSOCK", outfile = '')
doParallel::registerDoParallel(cl)
#Explicitly output how many cores I am using
a <- system("wmic path Win32_PerfFormattedData_PerfProc_Process get Name,PercentProcessorTime",
intern = TRUE)
df <- do.call(rbind, lapply(strsplit(a, " "),
function(x) {x <- x[x != ""];data.frame(process = x[1],
cpu = x[2])}))
df[grepl("Rgui|rstudio", df$process),]
#Function to be ran
fit_function <- function(i){
GUESS <- ctmm.guess(bears_fproj[[i]], variogram = VARIOGRAMS[[i]],
ctmm(error = TRUE, isotropic= TRUE), interactive = FALSE)
ctmm.select(bears_fproj[[i]], GUESS, trace = 2)
}
#Estimate fits
start_time <- Sys.time()
FITS <- foreach::foreach(i = 1:length(bears_fproj), .packages = "ctmm") %dopar%
{fit_function(i)}
install.packages("httpgd")
install.packages("languageserver")
library(languageserver)
remotes::install_github("nx10/httpgd")
setwd("C:/Users/Francisco/Documents/GitHub/intro_telemetry_r")
library(moveVis)
library(move)
library(tidyverse)
jaguars <- read_csv("docs/datos/Jaguars.csv")
# Selecciona a Courisco
courisco <- jaguars %>%
filter(`individual-local-identifier` == "Courisco")
# Transformar en objeto move
courisco_move <- df2move(courisco[1:4500,],
proj = "+proj=longlat +south +zone=23 +ellps=WGS84",
x = "location-long", y = "location-lat", time = "study-local-timestamp",
track_id = "individual-local-identifier")
courisco_move <- align_move(courisco_move, res = 60, unit = "mins")
use_multicore(n_cores = 22)
# Crear el objeto que alamcene los frames de la animacion
frames <- frames_spatial(courisco_move,
map_service = "osm",
map_type = "topographic",
path_legend = F,
path_colours = "black",
path_alpha = 0.8,
tail_size = 2,
tail_length = 5)
frames_edit <- add_labels(frames, x = "Longitud" , y = "Latitud", verbose = TRUE) %>%
add_scalebar(height = 0.015) %>%
add_northarrow() %>%
add_timestamps(courisco_move, type = "label") %>%
add_gg(frames, gg = expr(labs(title = "Movimientos del jaguar Courisco en Brasil")))
animate_frames(frames_edit[1:1500], out_file = "courisco.gif",
height = 500, width = 500, res = 82, overwrite = TRUE)
library(moveVis)
library(move)
library(tidyverse)
jaguars <- read_csv("docs/datos/Jaguars.csv")
str(read_csv)
str(jaguars)
# Selecciona a Courisco
courisco <- jaguars %>%
filter(`individual-local-identifier` == "Courisco")
summary(courisco)
View(courisco)
# Visualizar frecuencia de muestreo
lagging <- timeLag(courisco_move,
unit="mins")
# Transformar en objeto move
courisco_move <- df2move(courisco[1:500,],
proj = "+proj=longlat +south +zone=23 +ellps=WGS84",
x = "location-long", y = "location-lat",
time = "study-local-timestamp",
track_id = "individual-local-identifier")
View(courisco_move)
# Visualizar frecuencia de muestreo
lagging <- timeLag(courisco_move,
unit="mins")
summary(lagging)
# Histograma de frecuencias de muestreo
hist(lagging, xlab= "mins", xlim= c(0, 400), breaks= 40)
# Histograma de frecuencias de muestreo
hist(lagging, xlab= "mins", xlim= c(0, 100), breaks= 40)
# Histograma de frecuencias de muestreo
hist(lagging, xlab= "mins", xlim= c(0, 100), breaks= 10)
# Histograma de frecuencias de muestreo
hist(lagging, xlab= "mins", xlim= c(0, 100), breaks= 80)
use_multicore()
use_multicore(n_cores = 10)
get_maptypes()
# Crear el objeto que alamcene los frames de la animacion
frames <- frames_spatial(courisco_move,
map_service = "osm",
map_type = "topographic",
path_legend = F,
path_colours = "black",
path_alpha = 0.8,
tail_size = 2,
tail_length = 5)
courisco_move <- align_move(courisco_move, res = 60, unit = "mins")
# Crear el objeto que alamcene los frames de la animacion
frames <- frames_spatial(courisco_move,
map_service = "osm",
map_type = "topographic",
path_legend = F,
path_colours = "black",
path_alpha = 0.8,
tail_size = 2,
tail_length = 5)
sessionInfo()
?timeLag
frames[[456]]
?frames_spatial
frames[[1]]
frames[[100]]
# editar
frames_edit <- add_labels(frames, x = "Longitud" , y = "Latitud", verbose = TRUE) %>%
add_scalebar(height = 0.015) %>%
add_northarrow() %>%
add_timestamps(courisco_move, type = "label") %>%
add_gg(frames, gg = expr(labs(title = "Movimientos del jaguar Courisco en Brasil")))
frames_edit[[100]]
suggest_formats()
animate_frames(frames_edit, out_file = "courisco.gif",
height = 500, width = 500, res = 82, overwrite = TRUE)