Jump to content
Ornithology Exchange (brought to you by the Ornithological Council)

automated editing and deletion of twiligths with TwGeos

Recommended Posts

Hello everyone!


I am trying to use the function twilightEdit from TwGeos, which is supposed to edit and delete twilight outliers automatically. I do not know why I get this error: "Error in x[(window/2) + 1, 2] : subindex out of limits"


My code is:


readLig <- function(file,skip=0) {
  ## Read csv file and add column names
  d <- read.csv(file,header=FALSE,skip=skip,
  ## Parse date
  d$Date <- as.POSIXct(strptime(d$Date,"%d/%m/%y %H:%M:%S",tz="GMT"))
lig.raw<-readLig("V4221 023_cal.lig")
head(lig.raw, n=10)
###Search for twilight times
twilights<-findTwilights(lig.raw, threshold=16, include = c(c("2016-06-21","2017-03-15"), c("2017-07-20", "2017-07-27")), 
exclude = NULL, extend = 0, dark.min = 300)
head(twilights, n=10)
###Automated (Objective) editing and deletion of twilight times (experimental)
twilightEdit(twilights, offset = 17, window = 4, outlier.mins = 45,
  stationary.mins = 15, zlim = c(0, 64), plot = T)
In addition, I do not know how to use the result object from twilightEdit and work with FlightR. Does anyone know something about it?
Thank you very much in advance,
Link to comment
Share on other sites

  • 1 month later...



I am not sure what may cause the error - could be that there are too large caps in the time series of sunrise/sunset times (larger than the window)?!


The output should be exactly the same as the output of e.g. preprocessLight but in case of deleted twilight times, the "Deleted" column is set to TRUE and in case of modified twilights, the "Twilight" column is the new data time and the "Twilight3" column the old datetime.




Link to comment
Share on other sites


thank you for your answer Simeon. You were right! if I use a bigger window, the error dissapear and the result is fine. However now I see that I do not understand what the parameter "windows" means ("the number of neighboring twilights"). Depending of this number the function deletes or not specific twilights.


Kind regards,


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...