Skip to content
Permalink
master
Go to file
 
 
Cannot retrieve contributors at this time
66 lines (56 sloc) 3.49 KB
<!--
%\VignetteEngine{knitr}
%\VignetteIndexEntry{Bar-Tailed Godwit GeoLight analysis}
%\VignetteDepends{BAStag}
-->
# Intigeo tag on a Bar tailed godwit analysis example
# BAStag twilights selection
Appendix A4 to
Rakhimberdiev, E., Senner, N. R., Verhoeven, M. A., Winkler, D. W., Bouten, W. and Piersma T. 2016 Comparing inferences of solar geolocation data against high-precision GPS data: annual movements of a double-tagged Black-Tailed Godwit. - Journal of Avian Biology 000: 000-000.
In order to run GeoLight ir FLightR over the light data we have to preselect twilights. *.lux in the directory is the original file you get from Migrate Technology Ltd. This file does not have defined twilights. There is plenty of ways to predefine twilights and here we will use [BAStag package](https://github.com/SWotherspoon/BAStag):
```{r, eval=F}
library(devtools)
install_github("SWotherspoon/SGAT")
install_github("SWotherspoon/BAStag")
install_github("eldarrak/FLightR@0.3.6") # install this version if you want completely the same results as in the paper
install_github("eldarrak/FLightR") # this will install latest version
library(BAStag)
```
##Download data from GitHub
Download [.lux](https://raw.githubusercontent.com/eldarrak/FLightR/master/examples/Black-Tailed_Godwit_JAB_example/A2_raw_data.lux) file into your working directory and name it 'A2_raw_data.lux'.
```{r, eval=FALSE}
download.file("https://raw.githubusercontent.com/eldarrak/FLightR/master/examples/Black-Tailed_Godwit_JAB_example/A2_raw_data.lux", "A2_raw_data.lux")
```
##Process .lux file in R
```{r, eval=F}
library(BAStag)
d.lux<-readMTlux("A2_raw_data.lux")
d.lux<- subset(d.lux,select=c("Date","Light"))
```
In the .lux files light values go very high, so we should log transform data before selecting twilights.
```{r, eval=F}
d.lux$Light<-log(d.lux$Light)
```
## Find proper offset and have a first look at the data
```{r, eval=F}
offset = 10
lightImage(d.lux, offset = offset, zlim = c(0, 12), dt = 300) # dt specifies the recording interval
start <- as.POSIXct("2013-06-16", tz = "GMT")
end <- as.POSIXct("2014-05-17", tz = "GMT")
abline(v = c(start, end), lty = c(1,2), col = "orange", lwd = 2)
d.lux <- subset(d.lux, Date>=start & Date<=end)
```
## Twilight detection - selection
```{r, eval=FALSE}
threshold=1.5 # better use 1.5 for Intigeo tags if no strong reason for other value
twl <- preprocessLight(d.lux, threshold, offset = offset,lmax=12) # only needs to be done once
```
The idea of ```preprocessLight()``` function is that you go through twilights one by one and delete ones that have obvious non random change in the shading in +/- 24 points around twilight (2 hours for 5 minute logging interval). For example twilight should be deleted if in the beginning birds was in hig vegetation and after it immediately flew to the open space. Or other way around - there is nice pattern of rising sun and in the middle bird goes to high vegetation and stays there...
##Transfer BAStag output to TAGS format...
```{r, eval=F}
library(FLightR)
TAGS.twilights.raw<-BAStag2TAGS(d.lux, twl, threshold=threshold)
TAGS.twilights.raw$datetime<-format(TAGS.twilights.raw$datetime, format="%Y-%m-%dT%T.000Z")
write.csv(TAGS.twilights.raw, file="tmp.csv", quote=FALSE, row.names=FALSE)
```
Now you can read these data by [GeoLight](https://github.com/eldarrak/FLightR/blob/master/examples/Black-Tailed_Godwit_JAB_example/A5_GeoLight_analysis.Rmd) or [FLightR](https://github.com/eldarrak/FLightR/blob/master/examples/Black-Tailed_Godwit_JAB_example/A6_FLightR_analysis.Rmd).
You can’t perform that action at this time.