matchEnvData,AcousticEvent-method {PAMpal}R Documentation

Match Environmental Data to an AcousticStudy Object

Description

Extracts all variables from a netcdf file matching Longitude, Latitude, and UTC coordinates of the start of each AcousticEvent object. Matched values are stored in the "ancillary" slot of each event

Usage

## S4 method for signature 'AcousticEvent'
matchEnvData(
  data,
  nc = NULL,
  var = NULL,
  buffer = c(0, 0, 0),
  FUN = c(mean),
  fileName = NULL,
  progress = TRUE,
  depth = 0,
  ...
)

## S4 method for signature 'AcousticStudy'
matchEnvData(
  data,
  nc = NULL,
  var = NULL,
  buffer = c(0, 0, 0),
  FUN = c(mean),
  fileName = NULL,
  progress = TRUE,
  depth = 0,
  ...
)

Arguments

data

an AcousticStudy or AcousticEvent object that must have GPS data added to it using the addGps functions

nc

name of a netcdf file, ERDDAP dataset id, or an edinfo object

var

(optional) vector of variable names

buffer

vector of Longitude, Latitude, and Time (seconds) to buffer around each datapoint. All values within the buffer will be used to report the mean, median, and standard deviation

FUN

a vector or list of functions to apply to the data. Default is to apply mean, median, and standard deviation calculations

fileName

(optional) file name to save downloaded nc file to. If not provided, then no nc files will be stored, instead small temporary files will be downloaded and then deleted. This can be much faster, but means that the data will need to be downloaded again in the future. If fileName is provided, then the function will attempt to download a single nc file covering the entire range of your data. If your data spans a large amount of time and space this can be problematic.

progress

logical flag to show progress bar

depth

depth values (meters) to use for matching, overrides any Depth column in the data or can be used to specify desired depth range when not present in data. Variables will be summarised over the range of these depth values. NULL uses all available depth values

...

other parameters to pass to ncToData

Value

original data object with environmental data added to the ancillary slot of each event. Complete data will be stored in ancillary(data)$environmental, and the mean of each downloaded variable will be stored in ancillary(data)$measures so that it can be exported for modeling. For each event the coordinates associated with the earliest UTC value in that event are used to match

Author(s)

Taiki Sakai taiki.sakai@noaa.gov

Examples


data(exStudy)
nc <- system.file('extdata', 'sst.nc', package='PAMmisc')
# suppressing warnings because nc coordinates dont align with this data,
# function warns of possible coordinate mismatch
exStudy <- suppressWarnings(matchEnvData(exStudy, nc=nc, progress=FALSE))
str(ancillary(exStudy[[1]])$environmental)
ancillary(exStudy[[1]])$measures


[Package PAMpal version 1.2.1 Index]