Jump to content


automated editing and deletion of twiligths with TwGeos

  • Please log in to reply
2 replies to this topic

#1 Cosme

  • General Members
  • 10 posts
  • University of Seville,
  • Spain

Posted 03 August 2017 - 11:48 AM

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,

#2 Simeon

  • General Members
  • 5 posts
  • Sempach, Switzerland,
  • Switzerland

Posted 19 September 2017 - 12:34 AM



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.




#3 Cosme

  • General Members
  • 10 posts
  • University of Seville,
  • Spain

Posted 22 September 2017 - 03:17 AM


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,


0 user(s) are reading this topic

0 members(s), 0 guests(s) and 0 anonymous member(s)