lts issue

35 views
Skip to first unread message

Mario Rollo

unread,
Oct 11, 2023, 6:47:35 AM10/11/23
to seewave
Hello,

I get an error when using lts() with files recorded by AudioMoth.

This is the code:
lts(dir, wl = 1024, ovlp = 50, col = spectro.colors(30), fftw = FALSE, verbose = TRUE, ntann = NULL, tlab = "Time(min)", flab = "Frequency (kHz)", recorder = "audiomoth")

The error message:
Error in image.default(x = time, xaxt = "n", xlab = "", y = freq, ylab = flab) : 'x' and 'y' values must be finite and non-missing

My system: R 4.3.1, seewave 2.2.2, and macOS Ventura 13.5.2

Any help would be greatly appreciated. Thanks a lot.

Jérôme SUEUR

unread,
Oct 12, 2023, 3:36:13 AM10/12/23
to seewave GROUP
Hello Mario,
Which format of audiomoth file name do you use?
Can you send me 2-3 files so that I can check?
Thanks
Best
Jerome 


De: "Mario Rollo" <mario...@gmail.com>
À: "seewave GROUP" <see...@googlegroups.com>
Envoyé: Mercredi 11 Octobre 2023 12:47:35
Objet: [seewave] lts issue

--
You received this message because you are subscribed to the Google Groups "seewave" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seewave+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/seewave/c8a52234-8bf1-42ad-a85d-01737ef2561cn%40googlegroups.com.

Mario Rollo

unread,
Oct 12, 2023, 6:51:47 AM10/12/23
to seewave
Thanks a lot for your reply, Jérôme!

In the attached link you can find two files recorded with different AudioMoth units under different sites, settings and environmental conditions. 

Both are already in "yyyymmdd_hhmmss" format but the error message coming from the analysis of the respective sets is the same.


Best
Mario

Jérôme SUEUR

unread,
Oct 12, 2023, 11:05:23 AM10/12/23
to seewave GROUP
I think I found the bug that I will fix quickly (but not tomorrow) in a new release.
Meanwhile can you try with sourcing the following update of audiomoth() after having loaded seewave
HTH
Jerome

audiomoth <- function(x,                  # a character vector, not a Wave object
                      tz = ""             # a character vector defining a time zone specification, see as.POSIXct(), argument 'tz'
                      )
{
    if (!is.character(x)) stop("'x' should be of mode character.")
    options(stringsAsFactors = FALSE)
    res <- data.frame(year = numeric(0), month = numeric(0), day = numeric(0),
                      hour = numeric(0), min = numeric(0), sec = numeric(0),
                      time = numeric(0))
    N <- length(x)  ## number of file names    
    for (i in 1:N)
    {
        tmp <- x[i]
        n <- nchar(tmp)
        ## check if .WAV or .wav file
        extension <- substr(tmp, start = n-3, stop = n)
        if(extension != ".wav" & extension != ".WAV"){warning(paste("File '", tmp, "' is not a '.wav' file", sep=""))}
        else{
            if(nchar(tmp)==12)   ## hexadecimal format
            {
                hex <- unlist(strsplit(tmp, extension))
                num <- strtoi(hex, base = 16)
                time <- as.POSIXct(num, tz=tz, origin = "1970-01-01")  
                year <- as.numeric(format(time, "%Y"))
                month <- as.numeric(format(time, "%m"))
                day <- as.numeric(format(time, "%d"))
                hour <- as.numeric(format(time, "%H"))
                min <- as.numeric(format(time, "%M"))
                sec <- as.numeric(format(time, "%S"))
            }
            else if(nchar(tmp)==19)  
            {
                year <- substr(tmp, start = 1, stop = 4)
                month <- substr(tmp, start = 5, stop = 6)
                day <- substr(tmp, start = 7, stop = 8)
                hour <- substr(tmp, start = 10, stop = 11)
                min <- substr(tmp, start = 12, stop = 13)
                sec <- substr(tmp, start = 14, stop = 15)
                time <- strptime(paste(year,month,day,hour,min,sec), "%Y%m%d%H%M%S")
            }
            res <- rbind(res, data.frame(year, month, day, hour, min, sec, time))
        }
    }
    return(res)    
    options(stringsAsFactors = TRUE)
}



De: "Mario Rollo" <mario...@gmail.com>
À: "seewave GROUP" <see...@googlegroups.com>
Envoyé: Jeudi 12 Octobre 2023 12:51:47
Objet: Re: [seewave] lts issue

Mario Rollo

unread,
Feb 5, 2024, 6:58:22 AMFeb 5
to seewave
Hello Jérôme. Sorry for such a late response. I'm just writing to say that it worked perfectly. Thank you very much again for your availability. Best, Mario.
Reply all
Reply to author
Forward
0 new messages