Skip to main content

interactive acceleration data viewer (or general time series plotter)

Hello everyone,

 

I normally used the movebank acceleration viewer to look at my acceleration data (e-obs tags). First it worked perfectly, then it only allowed to display data after up- and downloading it to/from movebank.org, now it doesn´t work at all on my XP Computer.... Today I sacrificed a sunny day to implement the interactive plotting function in R. With some little twists I´m sure it can be used by some people for plotting any time series data as well. Probably this exists in a better form somewhere else, but I didn´t find it. So here you go. Comments and suggestions are welcome, since I´m a lousy coder.

Greetings

Philipp

#RCode:

# for e-obs data use decoder option 6b. Otherwise adjust Function according to your data-table layout

ACCviewer<-function(path, samplerate=10, burstlength=4){ #burstlength is the duration of a continuous measurement in seconds, the
library(rpanel)
 if (interactive()) {
  tag2543Test<-read.table(path, sep=",")
  gpstime<- paste( tag2543Test[,2], tag2543Test[,4], sep=" ") # valid for decoder option 6b ...adjust if your data-table are structured any other way
  gpstime<-strptime(gpstime, format="%d.%m.%Y %H:%M:%S")
  countupseconds<- rep(c(0:(burstlength-1)), each=samplerate )
  gpstime<-gpstime+countupseconds
  gpstime2<-as.character(gpstime)
  tag2543Test<-cbind(tag2543Test, gpstime2)

 # to avoid scrolling over into negative index-areas...
  NAs<-rep(NA,  length(tag2543Test[,4]) )
  NAs2<-rep("NA",  length(tag2543Test[,4]) )
  NAs<-data.frame(NAs,NAs2, NAs2, NAs2,NAs,NAs,NAs,NAs)
  names(NAs)<- names( tag2543Test)
  tag2543<-rbind(  NAs, tag2543Test, NAs )
   n<- nrow(tag2543)
       
   ACC.draw <- function(panel) {

      extent<- c( (panel$middlepoint - panel$zoom) : (panel$middlepoint + panel$zoom) )
      ylimits<-   c(min(na.omit(tag2543[extent,5:7])),max(na.omit(tag2543[extent,5:7])))
      par(mai=c(2, 1, 1, 1))
      #if(is.na(ylimits[1]) | is.na(ylimits[2] )){ylimits<-c(min(tag2543[,5:7]),max(tag2543Test[-NA,5:7]))}
      plot( tag2543[extent,5], type="l", col="red", axes=F,  xlab=NA, ylim=ylimits)      #
      lines(     tag2543[extent,6]   , col="green")
      lines(    tag2543[extent,7]   , col="blue")

    if(length(extent)<=60){
    att<-seq(1,length(extent),10)
     labelss<- tag2543[extent[seq(1,length(extent),10)],"gpstime2"]
    }
    if(length(extent)>60 ){
    att<-seq(1,length(extent),length.out=6)
    labelss<- tag2543[extent[seq(1,length(extent),length.out=6)],"gpstime2"]
    }
    
    axis(side=1,
    at=att,
    labels= labelss ,
    las=2,
 
    )
    axis(side=2)
     panel
     }

   panel <- rp.control(middlepoint=n/2, zoom = 3)
   rp.slider(panel, middlepoint,from=n/3,to=2*n/3, resolution = 1,  action = ACC.draw  , showvalue =T)
   rp.slider(panel, zoom ,from=n/2,to= 1,resolution = 1, log=F, action = ACC.draw, showvalue =T)
      rp.doublebutton(panel, middlepoint ,step= 1,  action = ACC.draw)
    rp.doublebutton(panel, zoom ,step= 1,  action = ACC.draw, showvalue =T)

     }
}# end function
 

Document: 

Clarification about the Movebank Acceleration Viewer

 

A brief clarification about the Acceleration Viewer: This tool was designed to work with data that are in Movebank format, and is available for free to Movebank users. The program has always accessed data via Movebank, i.e. it has never worked for data not downloaded from the site. This supports the project's goals of promoting data archiving and enabling collaboration between researchers. Of course there are many other programs available to help with data analysis, and we encourage users to explore which tool(s) will work best for them.

If anyone has questions/comments about the program or needs help uploading and organizing data on the site, we're happy to help, free to contact us at support@movebank.org.

Cheers,

Sarah Davidson, Movebank Data Curator