Jump to content
Ornithology Exchange
  • 0

automated editing and deletion of twiligths with TwGeos


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,

Share this post

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0



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.




Share this post

Link to post
Share on other sites
  • 0


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,


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now