Re: [camtrapR] Errors in temporal thinning, Two problems occoured

54 views
Skip to first unread message

Patrick Lorch

unread,
Feb 4, 2021, 3:48:47 PM2/4/21
to Ilona Popp, camtrapR
I think in the past this kind of problem has turned out to be due to badly formed datetimes. 

Sent from my iPhone

On Feb 3, 2021, at 5:21 PM, Ilona Popp <ilona...@gmail.com> wrote:


Hello,

I ran the below to achieve temporal independence of 1 hour, across multiple species. Each species needs to be independent to it's self but not across species. I used the same script on 4 different data sets that where all formatted in the same way.

Two scripts came back weird. The first returned a strangely small amount of records and took much longer than the others. The other returned only one species (the set has around 13 species). 

This is the script for the one that took a really long time:

#Koombaloomba

###Read.csv
KOOM<-read.csv("/Users/ilonapapp/Documents/Tom Project/CamTrapR Temporal Independance for each site/Raw Site CSV files/Koombaloomba.csv",stringsAsFactors = FALSE)


###create DateTimeOrginal column in proper format
KOOM$DateTimeOriginalKOOM <- strptime(paste(KOOM$Date, KOOM$Time, sep = " "), format = "%d/%m/%Y %H:%M:%S", tz = "Australia/Queensland")

###find duplicate rows (add more items if needed, e.g. "Site.Name")

duplicate_rows_KOOM <- which(duplicated(KOOM[, c("Camera.Serial.Number", "Species", "DateTimeOriginalKOOM")]))

###remove duplicate rows
records_filter_KOOM <- KOOM[-duplicate_rows_KOOM,]

###assign a species


KOOM_Temporal_Independance <- camtrapR:::assessTemporalIndependence(intable = records_filter_KOOM,
                                                  deltaTimeComparedTo = "lastIndependentRecord",
                                                  columnOfInterest = "Species",
                                                    stationCol = "Camera.Trap.name",
                                                  cameraCol = "Camera.Serial.Number",
                                                  camerasIndependent = FALSE,
                                                  minDeltaTime = 60)


sum(KOOM_Temporal_Independance$Species == spec_test)

The problem I had was the file had around 120, 000 records and was thinned to around 5500. The other sets I had started at around 11, 000 and thinned to around 5, 000. It also took 10 hours to run.


*****

This is the script for the one that returned only one species:

#Tumoulin

###Read.csv
TUM<-read.csv("//Users/ilonapapp/Documents/Tom Project/CamTrapR Temporal Independance for each site/Raw Site CSV files/Tumoulin.csv",stringsAsFactors = FALSE)


###create DateTimeOrginal column in proper format
TUM$DateTimeOriginal <- strptime(paste(TUM$Date, TUM$Time, sep = " "), format = "%d/%m/%Y %H:%M:%S", tz = "Australia/Queensland")

###find duplicate rows (add more items if needed, e.g. "Site.Name")
duplicate_rows_TUM <- which(duplicated(TUM[, c("Camera.Serial.Number", "Species", "DateTimeOriginal")]))

###remove duplicate rows
records_filter_TUM <- TUM[-duplicate_rows_TUM,]

###assign a species


TUM_Temporal_Independance <- camtrapR:::assessTemporalIndependence(intable = records_filter_SOJO,
                                                  deltaTimeComparedTo = "lastIndependentRecord",
                                                  columnOfInterest = "Species",
                                                  stationCol = "Camera.Trap.name",
                                                  cameraCol = "Camera.Serial.Number",
                                                  camerasIndependent = FALSE,
                                                  minDeltaTime = 60)




??assessTemporalIndependence

write.csv(TUM_Temporal_Independance, "/Users/ilonapapp/Documents/Tom Project/CamTrapR Temporal Independance for each site/Temporal Independance each Site csv files/)


Attached is a screen shot of the top of one Excell sheet. They are all formatted in the same way. This  site is the one that returned only one species.

Thank you so much anyone who could shed some light on this!

Ilona



--
You received this message because you are subscribed to the Google Groups "camtrapR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camtrapr+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/camtrapr/f6b939ea-8068-433e-b237-60f0e17fcc9bn%40googlegroups.com.
<Screen Shot 2021-02-04 at 8.04.13 am.png>

Juergen Niedballa

unread,
Feb 9, 2021, 4:45:49 AM2/9/21
to camt...@googlegroups.com

Hi Ilona,

first, computation time: I believe the problem with manually running assessTemporalIndependence is that the amount of time it takes increases exponentially with the number of records. Normally it is called for each station individually, and then it doesn't take long (when running recordTable, assessTemporalIndependence  is called for every station). You can do the same by splitting your record table by stations (or station and camera, whichever is appropriate) with something like:

records_split <- split(records_filter_KOOM, f = list(records_filter_KOOM$Camera.Trap.name, records_filter_KOOM$Camera.Serial.Number))

records_split_independent <- lapply(records_split, FUN = camtrapR:::assessTemporalIndependence,
                                    deltaTimeComparedTo = "lastIndependentRecord",
                                    ...)    # add the other arguments

out <- do.call("rbind", records_split_independent)   # reassemble

Regarding one species only, I don't know why that would happen. How many species are there in
records_filter_TUM before running  assessTemporalIndependence? Feel free to email me the table and I'll try it myself. What confuses me though is that you first work on records_filter_TUM, then call assessTemporalIndependence(records_filter_SOJO.

Best regards,

Jürgen

Reply all
Reply to author
Forward
0 new messages