swfscDAS (version 0.6.2)

das_sight: DAS sightings

Description

Extract sightings and associated information from processed DAS data

Usage

das_sight(x, ...)

# S3 method for data.frame das_sight(x, ...)

# S3 method for das_df das_sight( x, return.format = c("default", "wide", "complete"), return.events = c("S", "K", "M", "G", "s", "k", "m", "g", "t", "p", "F"), ... )

Value

Data frame with 1) the columns from x, excluding the 'Data#' columns, and 2) columns with sighting information extracted from 'Data#' columns. See das_format_pdf for more information the sighting information. If return.format is "default", then there is one row for each species of each sighting event; if return.format is "wide", then there is one row for each sighting event; if return.format is "complete", then there is one row for every group size estimate for each sighting event (excluding sperm whale "C" events - see the Details section).

The format-specific columns are described in their respective sections. The following sighting information columns are included in all return formats:

Sighting informationColumn nameNotes
Sighting numberSightNoCharacter
Subgroup codeSubgroupCharacter
Daily sighting numberSightNoDailySee below
Observer that made the sightingObs
Standard observerObsStdLogical; TRUE if Obs is one of ObsL, Rec or ObsR, and FALSE otherwise
Bearing to the sightingBearingNumeric; degrees, expected range 0 to 360
Number of reticle marksReticleNumeric
Distance (nautical miles)DistNmNumeric
Sighting cueCue
Sighting methodMethod
Photos of school?Photos
Birds present with school?Birds
Calibration school?CalibSchool
Aerial photos taken?PhotosAerial
Biopsy taken?Biopsy
Probable sightingProbLogical indicating if sighting has associated ? event; NA for non-S/K/M/G events
Number of species in sightingnSpNA for non-S/K/M/G events
Mixed species sightingMixedLogical; TRUE if nSp > 1
Group size of school - best estimateGsSchoolBestSee below
Group size of school - high estimateGsSchoolHighSee below
Group size of school - low estimateGsSchoolLowSee below
Course (true heading) of school at resightCourseSchoolNA for non-s/k/m events
Presence of associated JFRTurtleJFRNA for non-"t" events; JFR = jellyfish, floating debris, or red tide
Estimated turtle maturityTurtleAgeNA for non-"t" events
Perpendicular distance (km) to sightingPerpDistKmCalculated via (abs(sin(Bearing*pi/180) * DistNm) * 1.852)

SightNoDaily is a running count of the number of S/K/M/G sightings that occurred on each day. It is formatted as 'YYYYMMDD'_'running count', e.g. "20050101_1".

The GsSchoolBest, GsSchoolHigh, and GsSchoolLow columns are either: 1) the arithmetic mean across observer estimates, for the "default" and "wide" formats, or 2) the individual observer estimates, for the "complete" format. Note that for non-"complete" formats, na.rm = TRUE is used when calculating the mean, and thus blank elements of estimates (but not the whole incomplete estimate) are ignored.

To convert the perpendicular distance back to nautical miles, one would divide PerpDistKm by 1.852

Arguments

x

an object of class das_df, or a data frame that can be coerced to class das_df

...

ignored

return.format

character; can be one of "default", "wide", "complete", or any partial match thereof (case sensitive). Formats described below

return.events

character; event codes included in the output. Must be one or more of: "S", "K", "M", "G", "s", "k", "m", "g", "t", "p", "F" (case-sensitive). The default is all of these event codes

The "default" format output

This output data frame contains 'long' sighting data, meaning there is one row for each species of each sighting event. The GsSp... columns are calculated as follows: for each species and for each observer estimate, the best/high/low school size estimate is multiplied by the applicable species percent estimate. The values are grouped by species and then averaged to get single GsSpBest, GsSpHigh, and GsSpLow values for each species. (using mean with na.rm = TRUE)

Sighting information columns/formats present specifically in the "default" format output:

Sighting informationColumn nameNotes
Species codeSpCodeBoat type or mammal, turtle, or pinniped species codes
Probable species codeSpCodeProbProbable mammal species codes; NA if none or not applicable
Group size of species - best estimateGsSpBestThe product of the arithmetic means of GsSchoolBest and the corresponding species percentage
Group size of species - high estimateGsSpHighThe product of the arithmetic means of GsSchoolHigh and the corresponding species percentage
Group size of species - low estimateGsSpLowThe product of the arithmetic means of GsSchoolLow and the corresponding species percentage

Note that for the above calculations, the GsSchoolX value and corresponding species percentages were each averaged across observers, using na.rm = TRUE, before being multiplied to calculate GsSpX. For example, in the workflow: GsSpBest1 = mean(.data$Data2, na.rm = TRUE) * mean(.data$Data5, na.rm = TRUE)

The "wide" and "complete" format outputs

The "wide" and "complete" options have very similar columns in their output date frames. There are two main differences: 1) the "wide" format has one row for each sighting event, while the complete format has a row for every observer estimate for each sightings, and thus 2) in the "wide" format, all numeric information for which there are multiple observer estimates (school group size, species percentage, etc.) are averaged across estimated via an arithmetic mean (using mean with na.rm = TRUE)

With these formats, note that the species/type code and group size for turtle, pinniped, and boat sightings are in their own column

Sighting information columns present in the "wide" and "complete" format outputs:

Sighting informationColumn nameNotes
Observer code - estimateObsEstimateSee below
Species 1 codeSpCode1
Species 2 codeSpCode2
Species 3 codeSpCode3
Species 4 codeSpCode4
Species 1 probable codeSpCodeProb1Extracted from '?' event
Species 2 probable codeSpCodeProb2Extracted from '?' event
Species 3 probable codeSpCodeProb3Extracted from '?' event
Species 4 probable codeSpCodeProb4Extracted from '?' event
Percentage of Sp 1 in schoolSpPerc1
Percentage of Sp 2 in schoolSpPerc2
Percentage of Sp 3 in schoolSpPerc3
Percentage of Sp 4 in schoolSpPerc4
Group size of species 1GsSpBest1Present in "wide" output only; see below
Group size of species 2GsSpBest2Present in "wide" output only; see below
Group size of species 3GsSpBest3Present in "wide" output only; see below
Group size of species 4GsSpBest4Present in "wide" output only; see below
Turtle speciesTurtleSpNA for non-"t" events
Turtle group sizeTurtleGsNA for non-"t" events
Was turtle captured?TurtleCaptNA for non-"t" events
Pinniped speciesPinnipedSpNA for non-"p" events
Pinniped group sizePinnipedGsNA for non-"p" events
Boat or gear typeBoatTypeNA for non-"F" events
Number of boatsBoatGsNA for non-"F" events

ObsEstimate refers to the code of the observer that made the corresponding estimate. For the "wide" format, ObsEstimate is a list-column of all of the observer codes that provided an estimate. Also in the "wide" format, the GsSpBest# columns are the product of the means of GsSchoolBest and the corresponding species percentage (see the Default section for calculation details). These numbers, 1 to 4, correspond to the order of the data as it appears in the DAS file

Details

DAS events contain specific information in the 'Data#' columns, with the information depending on the event code for that row. The output data frame contains columns with this specific information extracted to dedicated columns as described below. This function recognizes the following types of sightings: marine mammal sightings (event codes "S", "K", or "M"), marine mammal resights (codes "s", "k", "m"), marine mammal subgroup sightings (code "G"), marine mammal subgroup resights (code "g"), turtle sightings (code "t"), pinniped sightings (code "p"), and fishing vessel sightings (code "F"). Warnings are printed if all S, K, M, and G events (and only these events) are not followed by an A event and at least one numeric event. See das_format_pdf for more information about events and event formats. Of specific note - sperm whale sightings (species code 046) often contain additional estimates recorded as "C" events immediately following the S, A, and numeric events. Because these estimates are recorded as"C" events, they are NOT included in the das_sight calculations or output for any return.format

The return.events argument simply provides a shortcut for filtering the output of das_sight by event codes

Abbreviations used in output column names: Gs = group size, Sp = species, Nm = nautical mile, Perc = percentage, Prob = probable, GsSchool = school-level group size info

This function makes the following assumptions, and alterations to the raw DAS data:

  • "A" events immediately following an S/K/M/G event have the same sighting number (Data1 value) as the S/K/M/G event

  • The 'nSp' column is equivalent to the number of non-NA values across the 'Data5', 'Data6', 'Data7', and 'Data8' columns for the pertinent "A" event

  • The following data are coerced to a numeric using as.numeric: Bearing, Reticle, DistNm, Cue, Method, species percentages, and group sizes (including for t, p, and F events). Note that if there are any formatting errors and these data are not numeric, the function will likely print a warning message

  • The values for the following columns are capitalized using toupper: 'Birds', 'Photos', 'CalibSchool', 'PhotosAerial', 'Biopsy', 'TurtleAge', and 'TurtleCapt'

Examples

Run this code
y <- system.file("das_sample.das", package = "swfscDAS")
y.proc <- das_process(y)

das_sight(y.proc)
das_sight(y.proc, return.format = "complete")

Run the code above in your browser using DataLab