Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Longitudes unwrap when individuals cross the date line #2

Closed
ryanreisinger opened this issue Feb 4, 2019 · 2 comments
Closed

Longitudes unwrap when individuals cross the date line #2

ryanreisinger opened this issue Feb 4, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ryanreisinger
Copy link

When an individual's track crosses the date line (-180/+180), the fitted output is 'unwrapped' (i.e., has longitudes greater than 180 degrees). Should the interanl function wrap_lon be called in fit_ssm?

library(lubridate)
library(foieGras)
track <- data.frame(id = "bird",
                    date = seq(ymd_hms("2012-01-01 12:00:00"), ymd_hms("2012-01-03 12:00:00"), length.out = 40),
                    lc = "3",
                    lon = c(seq(150, 179, length.out = 20), seq(-179, -150, length.out = 20)),
                    lat = seq(-30, - 60, length.out = 40)
                    )

plot(track$lon, track$lat)

fit.track <- fit_ssm(track, time.step = 3, vmax = 1000)

plot(fit.track$ssm[[1]]$predicted$lon, fit.track$ssm[[1]]$predicted$lat)
@ryanreisinger
Copy link
Author

Seems so:

library(lubridate)
library(foieGras)
track <- data.frame(id = "bird",
                    date = seq(ymd_hms("2012-01-01 12:00:00"), ymd_hms("2012-01-03 12:00:00"), length.out = 40),
                    lc = "3",
                    lon = c(seq(150, 179, length.out = 20), seq(-179, -150, length.out = 20)),
                    lat = seq(-30, - 60, length.out = 40)
                    )

plot(track$lon, track$lat)

fit.track <- fit_ssm(track, time.step = 3, vmax = 1000)

plot(fit.track$ssm[[1]]$predicted$lon, fit.track$ssm[[1]]$predicted$lat)

# Wrap longitude back
fit.track$ssm[[1]]$predicted$lon <- wrap_lon(fit.track$ssm[[1]]$predicted$lon)
plot(fit.track$ssm[[1]]$predicted$lon, fit.track$ssm[[1]]$predicted$lat

@ianjonsen ianjonsen added the bug Something isn't working label Feb 4, 2019
@ianjonsen ianjonsen self-assigned this Feb 4, 2019
@ianjonsen
Copy link
Owner

issue fixed. fit_ssm/prefilter/sfilter now return longitude on original data interval [-180,180] or [0,360] but wraps appropriately for projection to mercator, prior to fitting SSM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants