Skip to content

Commit

Permalink
rebuild. remove special characters from project names.
Browse files Browse the repository at this point in the history
  • Loading branch information
agmacpha committed Jan 11, 2024
1 parent 027f29f commit 04414a8
Show file tree
Hide file tree
Showing 27 changed files with 46 additions and 73 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(wt_audio_scanner)
export(wt_auth)
export(wt_chop)
Expand Down Expand Up @@ -51,4 +50,3 @@ import(tools)
import(tuneR)
import(unmarked)
import(utils)
importFrom(magrittr,"%>%")
30 changes: 20 additions & 10 deletions R/api.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ wt_get_download_summary <- function(sensor_id) {
#' \item main
#' \item project
#' \item location
#' \item point count
#' \item point_count
#' \item definitions
#' }
#'
Expand Down Expand Up @@ -138,11 +138,19 @@ wt_download_report <- function(project_id, sensor_id, reports, weather_cols = TR
stop("Please authenticate with wt_auth().", call. = FALSE)

# Check if the project_id is valid:
i <- wt_get_download_summary(sensor_id = sensor_id)
i <- unlist(i$project_id)
i <- wt_get_download_summary(sensor = sensor_id) %>%
tibble::as_tibble() %>%
dplyr::select(project_id, sensor)

if (!project_id %in% i) {
sensor_value <- i %>%
rename('id' = 1) %>%
dplyr::filter(id == project_id) %>%
dplyr::pull(sensor)

if (!project_id %in% i$project_id) {
stop("The project_id you specified is not among the projects you are able to download for.", call. = TRUE)
} else if (sensor_value == 'ARU' & sensor_id == 'PC'){
stop('You will not be able to convert a PC project to ARU since the data does not contain media.', call. = TRUE)
}

# Make sure report is specified
Expand Down Expand Up @@ -213,6 +221,7 @@ wt_download_report <- function(project_id, sensor_id, reports, weather_cols = TR
if ("megadetector" %in% reports) query_list$megaDetectorReport <- TRUE
if ("megaclassifier" %in% reports) query_list$megaClassifierReport <- TRUE

# Include metadata
query_list$includeMetaData <- TRUE
query_list$splitLocation <- TRUE

Expand All @@ -221,7 +230,7 @@ wt_download_report <- function(project_id, sensor_id, reports, weather_cols = TR
# tmp directory
td <- tempdir()

# Create POST request
# Create GET request
r <- httr::GET(
httr::modify_url("https://www-api.wildtrax.ca", path = "/bis/download-report"),
query = query_list,
Expand All @@ -232,7 +241,6 @@ wt_download_report <- function(project_id, sensor_id, reports, weather_cols = TR
httr::progress()
)


# Stop if an error or bad request occurred
if (httr::http_error(r))
stop(sprintf(
Expand All @@ -248,11 +256,13 @@ wt_download_report <- function(project_id, sensor_id, reports, weather_cols = TR
abstract <- list.files(td, pattern = "*_abstract.csv", full.names = TRUE, recursive = TRUE)
file.remove(abstract)

# List data files, read into R as a list
files <- gsub(".csv", "", list.files(td, pattern = ".csv", recursive = TRUE))
files.full <- list.files(td, pattern = ".csv", full.names = TRUE, recursive = TRUE)
# Remove special characters
list.files(td, pattern = "*.csv", full.names = TRUE) %>%
purrr::map(~file.rename(.x, gsub("[:()?!~;]", "", .x)))
files.full <- list.files(td, pattern= "*.csv", full.names = TRUE)
files.less <- basename(files.full)
x <- purrr::map(.x = files.full, .f = ~ readr::read_csv(., show_col_types = F, skip_empty_rows = T)) %>%
purrr::set_names(files)
purrr::set_names(files.less)

# Remove weather columns, if desired
if(weather_cols) {
Expand Down
14 changes: 0 additions & 14 deletions R/utils-pipe.R

This file was deleted.

2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/SUPPORT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ articles:
camera-data-wrangling: camera-data-wrangling.html
introduction: introduction.html
tutorials: tutorials.html
last_built: 2024-01-09T19:58Z
last_built: 2024-01-10T02:19Z
urls:
reference: https://abbiodiversity.github.io/wildRtrax/reference
article: https://abbiodiversity.github.io/wildRtrax/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/dot-wt_api_pr.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/dot-wt_auth.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/dot-wt_auth_expired.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wildRtrax.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_audio_scanner.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_auth.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_download_report.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_get_download_summary.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_run_ap.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_signal_level.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/wt_wac_info.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions man/pipe.Rd

This file was deleted.

1 change: 0 additions & 1 deletion vignettes/tutorials.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ data <- wt_download_report(605,'ARU',c('birdnet','main'))
The results from the `main` report can then be anti-joined against the `birdnet` report to determine if any species were detected than a human did not find. It's recommended to use high threshold values from BirdNET and species that should occur or be allowed in the project.

```{r}
birdnet_report <- data[[1]] %>%
dplyr::filter(is_species_allowed_in_project == 't',
confidence > 50) %>%
Expand Down

0 comments on commit 04414a8

Please sign in to comment.