find_best_spar: Find the best spar value for spline smoothing using dive...

View source: R/helper_functions.R

find_best_sparR Documentation

Find the best spar value for spline smoothing using dive statistics

Description

Function recovers a record 21 separate times, between 0 and 1 with increments of 0.05 and assess how each change in spar value influences the dive statistics gathered by the record. It also finds the ideal spar value for that record by assessing changes in bottom distance. This function will take a while to run because it is recovering the same record multiple times, calibrating it, and retrieving the dive statistics. However, I believe this is the best method for finding the best spar value.

Usage

find_best_spar(
  filepath_trace = "WS_25_1981_trace.csv",
  filepath_timedots = "WS_25_1981_time_dots.csv",
  filepath_args = "WS_25_1981_args.csv",
  filepath_results = system.file("extdata", "WS_25_1981", package = "recoverKBTDR")
)

Arguments

filepath_trace

file path of raw trace csv file

filepath_timedots

file path of raw time dots csv file

filepath_args

file path of csv file containing:

  • radius : the length of the radius arm in cm. This is constant across all records, but some of the earlier records that I have were magnified by a slightly larger amount, and therefore the scale is slightly different.

  • center_y: height of the pivot point of the transducer arm from depth = 0 in cm. In other words, the y-value of the center of the circle that draws the dive record. This value may change across records, but helper functions are available to provide estimates (?find_center_y).

  • center_along_y: distance in cm used for centering the record. All time dots will be centered along y = -center_along_y

  • time_period_min: time elapsed between two time dots.

  • spar_h : spar value used for high depths of the records to increase resolution for the smooth_trace_dive() function.

  • depth_thresh: depth threshold to use for the rolling mean function to determine what depths should be considered diving behavior.

  • date_start: start of the record in y:m:d h:m:s format.

  • max_depth: maximum depth to use for depth transformation. Only for records without a psi calibration curve.

  • k_h : larger window to use for zoc() function, if needed.

  • depth_bounds_l, depth_bounds_h: low and high depth bounds that encapsulate where depth = 0 is likely to be. Used for zoc() function.

  • on_seal : time the tdr was placed on seal. In y:m:d h:m:s format.

  • off_seal: time the tdr was taken off seal. In y:m:d h:m:s format.

filepath_results

directory where you would like to store csv files of each spar scenario

Value

folder in /results that contains a csv for all spar scenarios, a dive_stats data frame containing all dive stats for each spar scenario to the global environment, and the best spar value to use for this record.

Examples

## Not run: 
filepath <- system.file("extdata", "WS_25_1981", package = "recoverKBTDR")
filepath_trace <- paste(filepath, "WS_25_1981_trace.csv", sep = "/")
filepath_timedots <- paste(filepath, "WS_25_1981_time_dots.csv", sep = "/")
filepath_args <- paste(filepath, "WS_25_1981_args.csv", sep = "/")

find_best_spar(filepath_trace, filepath_timedots, filepath_args, filepath_results = filepath)

## End(Not run)

EmmaLiTsai/recoverKBTDR documentation built on Aug. 29, 2024, 10:38 a.m.