ctmm-initiative / ctmm

Continuous-Time Movement Modeling. Functions for identifying, fitting, and applying continuous-space, continuous-time stochastic movement models to animal tracking data.
http://biology.umd.edu/movement.html
47 stars 12 forks source link

as.telemetry import error on some data #22

Closed xhdong-umd closed 6 years ago

xhdong-umd commented 6 years ago

Today I found this error in importing telemetry data.

> library(ctmm)
> tele <- as.telemetry("/Users/xhdong/Projects/ctmm-Shiny/data/misc tele/Movebank 1764627 - Kruger African Buffalo  GPS tracking  South Africa.csv")
Error in `[.data.frame`(DATA, , COL) : undefined columns selected
In addition: Warning message:
In as.telemetry.data.frame(data, timeformat = timeformat, timezone = timezone,  :
  No MoveBank identification found. Assuming data corresponds to one indiviudal.

The data is downloaded from movebank. Here is a copy. I think there is animal id column in the data but not recognized.

In previous version of ctmm the same data can be imported properly.

timestamp,location_lat,location_long,individual_id,tag_id
2005-02-17 05:05:00.000,-24.53730062,31.76642049,1764819,197990562
2005-02-17 06:08:00.000,-24.53931071,31.76442057,1764819,197990562
2005-02-17 07:05:00.000,-24.54798991,31.76114095,1764819,197990562
2005-02-17 08:05:00.000,-24.54702962,31.76079915,1764819,197990562
chfleming commented 6 years ago

I'm not getting this behavior with the master branch of ctmm on that data.

xhdong-umd commented 6 years ago

Sorry my bad. The google drive file is an old link I uploaded long time ago. It's actually different from what I tested. I just uploaded the right file here.

It's downloaded from movebank through movebank API so maybe the format is not too good.

chfleming commented 6 years ago

The file you linked has a different name and more columns, including the animal's names.

chfleming commented 6 years ago

Can you link to the other data? tag_id should have worked in the master branch.

xhdong-umd commented 6 years ago

I linked the same file I used in a comment above.

https://drive.google.com/file/d/1df0cmsDoDjzsWyzmCoEvmEkMbYQRW4MD/view?usp=sharing

chfleming commented 6 years ago

Looks like I made some embarrassing updates to pull.column... to the point where I'm not sure how anything was working.

I made a fix and am running check now. Will be up in a few hours, after I get back from dinner.

xhdong-umd commented 6 years ago

Please take your time. It's not a pressing issue from my side.

chfleming commented 6 years ago

This and related bugs should be fixed now.

bjpadilla commented 3 years ago

This and related bugs should be fixed now.

Hello.

I see that the bug was reported as fixed in 2018. But, when re-analyzing some data with identical R script and data set I am again getting this same error.

`## Both 2018 AND 2019  ####
> trk <- make_track(etib,Longitude..deg.,Latitude..deg.,  # All years (2018 and 2019)
+                   date_time, id = Collar.ID,year = year, month = month,sex=sex,season = seas, crs = crs(sgl), sex = sex) %>%  
+   transform_coords(crs(trug))
.t found, creating `track_xyt`.
> elks <- trk %>% nest(data = -c(id, year,season)) %>% 
+   mutate(n = map_int(data, nrow)) %>% 
+   filter(n > 20)
> elks1 <- elks %>%
+   mutate(
+     "hr_od_ou" = map(data, ~ hr_od(., model = fit_ctmm(., "ou"))),
+     "hr_od_50" = map(data, ~ hr_od(., model = fit_ctmm(., "ou"), levels = c(0.5)))
+   )
Minimum sampling interval of 4.46 hours in unknown
Error: Problem with `mutate()` input `hr_od_ou`.
x NA
ℹ Input `hr_od_ou` is `map(data, ~hr_od(., model = fit_ctmm(., "ou")))`.
Run `rlang::last_error()` to see where the error occurred.
In addition: Warning messages:
1: Problem with `mutate()` input `hr_od_ou`.
ℹ No MoveBank identification found. Assuming data corresponds to one indiviudal.
ℹ Input `hr_od_ou` is `map(data, ~hr_od(., model = fit_ctmm(., "ou")))`. 
2: In as.telemetry.data.frame(data.frame(lon = x$x_, lat = x$y_, timestamp = x$t_)) :
  No MoveBank identification found. Assuming data corresponds to one indiviudal.`