Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Camtrap DP 1.0 #284

Closed
6 of 7 tasks
peterdesmet opened this issue Nov 2, 2023 · 3 comments · Fixed by #286
Closed
6 of 7 tasks

Add support for Camtrap DP 1.0 #284

peterdesmet opened this issue Nov 2, 2023 · 3 comments · Fixed by #286
Assignees
Labels

Comments

@peterdesmet
Copy link
Member

peterdesmet commented Nov 2, 2023

Camtrap DP 1.0 has been released: https://github.com/tdwg/camtrap-dp/releases/tag/1.0. We're planning to update the Agouti export to Camtrap DP 1.0 directly (and not have 1.0-RC.1). Before we can release that Agouti export however, camtraptor needs to be updated to support 1.0, otherwise users won't be able to read the data.

  • Update convert_to_0.1.6() and support 1.0 instead of 1.0-rc.1 (this version never made it to production in Agouti or IPT)
  • observations.taxonID has been removed, downconvert by including in observations (leave empty)
  • deployments.cameraDepth has been added, downconvert by removing it
  • Update
    by = c("taxonID", "scientificName")
    to only join on scientificName (since Camtrap DP 1.0 no longer has taxonID)
  • Downconvert media.captureMethod values activityDetection to motionDetection
  • Downconvert project.catureMethod (in metadata) values activityDetection to motionDetection
  • Pass all tests
@PietrH
Copy link
Member

PietrH commented Nov 3, 2023

version is not supported ...

# check version is supported
assertthat::assert_that(
version %in% supported_versions,
msg = paste0(
glue::glue("Version {version} "),
"is not supported. Supported versions: ",
glue::glue_collapse(glue::glue("{supported_versions}"),
sep = " ",
last = " and "),
".")
)

convert_metadata_to_0.1.6():

camtraptor/R/zzz.R

Lines 431 to 484 in db6c53a

#' Convert a Camtrap DP to version 0.1.6
#'
#' This conversion function takes as input a Camtrap DP and returns
#'
#' @param package Camera trap data package object.
#' @param from Character identifying the version of `package`.
#' @param media If `TRUE` (default), read media records into memory. If `FALSE`,
#' ignore media file to speed up reading larger Camtrap DP packages.
#' @noRd
convert_to_0.1.6 <- function(package, from = "1.0-rc.1", media = TRUE){
if (from == "0.1.6") {
message(glue::glue("package's version: {from}. No conversion needed."))
return(package)
}
# check version
supported_versions <- c("1.0-rc.1")
assertthat::assert_that(
from %in% supported_versions,
msg = paste0(
"Only conversion from ",
glue::glue_collapse(glue::glue("{supported_versions}"),
sep = " ",
last = " and "),
" to 0.1.6 is supported."
)
)
# check data slot is present in package
assertthat::assert_that(
"data" %in% names(package),
msg = "Can't find `data` element in `package`."
)
# notify about conversion
message(
writeLines(
c(
"The dataset uses Camtrap DP version 1.0-rc.1, it has been converted to 0.1.6.",
"See https://inbo.github.io/camtraptor/#camtrap-dp for details."
)
)
)
# convert metadata
package <- convert_metadata_to_0.1.6(package, from)
# convert deployments
package <- convert_deployments_to_0.1.6(package, from)
# convert media
if (media) {
package <- convert_media_to_0.1.6(package, from)
}
# convert observations
package <- convert_observations_to_0.1.6(package, from)
return(package)
}

In the future we'll stack these functions, every incoming version will be upgraded to the next version serially from version to version.

Everything will internally be converted to the newest version.

At the moment the internal datamodel needs to be changed to v1.0 still.


What we want to change here is that convert_metadata_to_0.1.6() so it supports v1.0, and drop support for the rc since it's not in the wild.

In the future we want the internal data model to change to use the most recent version, but not for this issue.

@PietrH
Copy link
Member

PietrH commented Nov 3, 2023

Differences between RC and v1.0

  • taxonID has been removed from observations, we need to create this field for version v0.1.6
    How will we populate this field?

Peter proposes to leave it empty. So add it but leave it empty.

The function that links the taxonomy with the observations (add_taxonomic_info() -> get_species())

by = c("taxonID", "scientificName")

Needs to change to only join on scientificName

  • Do we need additional tests? Unclear if all changes are covered

@PietrH
Copy link
Member

PietrH commented Nov 3, 2023

example package to test on: https://github.com/tdwg/camtrap-dp/tree/main/example

@PietrH PietrH linked a pull request Nov 3, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants