eldarrak / FLightR

R package to position animals with solar geolocation archival tags
Other
21 stars 10 forks source link

run.particle.filter(check.outliers = T) failing after spatial architecture transition #32

Closed henrycstevens closed 4 months ago

henrycstevens commented 4 months ago

Hi Eldar, thanks for making those fixes to FLightR following the changes to R's spatial architecture!

I recently updated to R 4.4.0 and tried running my geolocator light data analysis script (which is essentially the same as the Lisovski et al. 2019 manual using FLightR). Everything seems to work well except for run.particle.filter(). If I set check.outliers = F, it works as normal. However, if I set check.outliers = T, the code consistently breaks after the third time period (i.e., time period 3 of x) yielding the following error:

"Error in weighted.mean.default(sf::st_distance(sf::st_as_sf(as.data.frame(in.Data$Spatial$Grid[Results.stack[, : 'x' and 'w' must have the same length"

I checked with my colleague that also uses FLightR and they confirmed the same issue occurs for their own analyses (they use R 4.3.2).

I assumed this issue was related to transitioning from sp to sf in the run.particle.filter() function, so I checked out the section of code where you switch from using sp to sf, but everything looks fine to me. I also noticed that in your "test" folder, there is a test for run.particle.filter() using check.outliers = F, but not for check.outliers = T, so I'm assuming this bug may have slipped under the radar.

Any ideas what might be happening here?

Thanks,

Henry

eldarrak commented 4 months ago

solved it, thanks for catching! the new github version should run smootly with check.outliers too