pf_setup_record: List 'record' files from an AC/DC algorithm for PF

View source: R/pf_setup.R

pf_setup_recordR Documentation

List ‘record’ files from an AC/DC algorithm for PF

Description

This function creates an ordered list of ‘record’ files derived from the AC/DC/ACDC algorithm (ac, dc or acdc) for particle filtering (PF) via pf.

Usage

pf_setup_record(root, type = c("acs", "dc"), use_absolute_paths = FALSE, ...)

Arguments

root

A string that defines the directory in which files are loaded.

type

A character that defines the source of the files (type = "acs" refers to an AC* algorithm and type = "dc" refers to the DC algorithm).

use_absolute_paths

A logical variable that defines whether to return relative paths (FALSE) or absolute paths (TRUE) (see file_path_as_absolute).

...

Additional arguments passed to list.files (excluding full.names).

Details

This function requires the stringr package.

Value

The function returns an ordered list of file paths.

Author(s)

Edward Lavender

See Also

This function is designed to list outputs from ac, dc or acdc (see the write_record_spatial_for_pf argument) as required by pf (see the record argument).

Examples

#### Example (1): Example with the AC algorithm
# Define a directory in which to save files
root <- paste0(tempdir(), "/ac/")
dir.create(root)
# Implement the AC algorithm for some example time series
acc <- dat_acoustics[dat_acoustics$individual_id == 25, ][1:5, ]
out_ac <- ac(
  acoustics = acc,
  step = 120,
  bathy = dat_gebco,
  detection_containers = dat_containers,
  mobility = 250,
  write_record_spatial_for_pf = list(filename = root)
)
# List the files for pf()
files <- pf_setup_record(root, type = "acs", pattern = "*.grd")
utils::head(files)
# Implement pf() using files (not shown).

#### Example (2): Example with the DC algorithm
# Define a directory in which to save files
root <- paste0(tempdir(), "/dc/")
dir.create(root)
# Implement the DC algorithm for some example time series
depth <- dat_archival[dat_archival$individual_id == 25, ][1:5, ]
out_dc <- dc(
  archival = depth,
  bathy = dat_gebco,
  write_record_spatial_for_pf = list(filename = root)
)
# List the files for pf()
files <- pf_setup_record(root, type = "dc", pattern = "*.grd")
utils::head(files)
# Implement pf() using files (not shown).


edwardlavender/flapper documentation built on Jan. 22, 2025, 2:44 p.m.