@@ -30,7 +30,9 @@ library(tictoc)
30
30
dv :: src()
31
31
32
32
# ### Load data
33
- # map <- terra::rast(here_input("map.tif"))
33
+ if (! os_linux()) {
34
+ map <- terra :: rast(here_input(" map.tif" ))
35
+ }
34
36
map_len <- qs :: qread(here_input(" map_len.qs" ))
35
37
timelines <- qs :: qread(here_input(" timelines.qs" ))
36
38
paths <- qs :: qread(here_input(" paths.qs" ))
@@ -70,7 +72,7 @@ asd <- parameters$model_move$angle$sd
70
72
state <- " StateXY"
71
73
model_move <- move_xy(mobility = mobility ,
72
74
dbn_length = glue(" truncated(Gamma({sshape}, {sscale}), lower = 0.0, upper = {mobility})" ),
73
- dbn_angle = glue(" Normal({amean}, {asd} )" ))
75
+ dbn_angle = glue(" Uniform(-pi, pi )" ))
74
76
75
77
# ### Define observation models
76
78
# Assemble acoustics (0, 1)
@@ -100,13 +102,11 @@ args <- list(.timeline = timeline,
100
102
.xinit = NULL ,
101
103
.yobs = yobs_fwd ,
102
104
.model_move = model_move ,
103
- .n_particle = 1e4L ,
105
+ .n_particle = 2e4L ,
104
106
.direction = " forward"
105
107
)
106
108
107
109
# ### Run forward filter
108
- # * NB: Setting observations is slow (1 min)
109
- # > Weights from filter (1 -> 208292) are zero at time 62367
110
110
fwd <- do.call(pf_filter , args , quote = TRUE )
111
111
112
112
# ### Run backward filter
@@ -115,51 +115,8 @@ args$.direction <- "backward"
115
115
do.call(pf_filter , args , quote = TRUE )
116
116
117
117
# ### Run smoother
118
- out_smo <- pf_smoother_two_filter()
119
-
120
-
121
- # ##########################
122
- # ##########################
123
- # ### Quick residency analysis
124
-
125
- # ### True residency in each region
126
- path_res <-
127
- path | >
128
- group_by(region ) | >
129
- summarise(n = n()) | >
130
- mutate(residency = (n / sum(n )) * 100 ,
131
- estimate = " path" ,
132
- sim_id = id ) | >
133
- as.data.table()
134
-
135
- # ### Particle residency estimates
136
- part_res <-
137
- out_smo | >
138
- mutate(region = terra :: extract(map , cbind(x , y ))) | >
139
- group_by(region ) | >
140
- mutate(residency = (n / sum(n )) * 100 ,
141
- estimate = " smoother" ,
142
- sim_id = id ) | >
143
- as.data.table()
144
-
145
- # ### Collect data
146
- res <- rbind(path_res , part_res )
147
- qs :: qsave(res , " data/patter/output/residency/qresidency/" , paste0(id , " .qs" ))
148
-
149
-
150
- # ##########################
151
- # ##########################
152
- # ### Synthesis
153
-
154
- # Read residency data for each individual
155
- residency <-
156
- lapply(unique(paths $ sim_id ), function (id ) {
157
- qs :: qread(" data/patter/qresidency.qs" )
158
- }) | > rbindlist()
159
-
160
- # Visualise residency ~ individual, coloured by truth/algorithm
161
- #
162
- # > TO DO
118
+ smo <- pf_smoother_two_filter()
119
+ qs :: qsave(smo , here_output(" particles" , paste0(id , " .qs" )))
163
120
164
121
165
122
# ### End of code.
0 commit comments