Skip to contents

Check that DAS file has accepted formatting and values

Usage

das_check(
  file,
  skip = 0,
  file.out = NULL,
  sp.codes = NULL,
  print.cruise.nums = TRUE
)

Arguments

file

filename(s) of one or more DAS files

skip

integer: see read_fwf. Default is 0

file.out

filename to which to write the error log; default is NULL

sp.codes

character; filename of .dat file from which to read accepted species codes. If NULL, species codes will not be checked. Default is NULL

print.cruise.nums

logical; indicates if a table with all the cruise numbers in the x should be printed using table. Default is TRUE

Value

A data frame with columns: the file name, line number, cruise number, 'ID' (columns 4-39 from the DAS file), and description of the issue

If file.out is not NULL, then the error log data frame is also written to file.out using write.csv

A warning is printed if any events are r events; see das_process for details about r events

Details

Precursor to a more comprehensive DASCHECK program. This function checks that the following is true:

  • Event codes are one of the following: #, *, ?, 1, 2, 3, 4, 5, 6, 7, 8, A, B, C, E, F, k, K, N, P, Q, r, R, s, S, t, V, W, g, G, p, X, Y, Z

  • Latitude values are between -90 and 90 (inclusive; NA values are ignored)

  • Longitude values are between -180 and 180 (inclusive; NA values are ignored)

  • The effort dot matches effort determined using B, R, and E events

  • There are an equal number of R and E events, and they alternate occurrences

  • A BR event series or R event does not occur while already on effort

  • An E event does not occur while already off effort

  • All Data# columns for non-C events are right-justified

  • Only C events have data past the 99th column in the DAS file

  • The following events have NA (blank) Data# columns: *

  • All of *, B, R, E, V, W, N, P, and Q events have NA Data# columns where specified (see format pdf for more details)

  • Event/column pairs meet the following requirements:

ItemEventColumnRequirement
Cruise numberBData1Can be converted to a numeric value
ModeBData2Must be one of C, P, c, p, or NA (blank)
Echo sounderBData4Must be one of Y, N, y, n, or NA (blank)
Effort typeRData1Must be one of F, N, S, or NA (blank)
ESW sidesRData2Effective strip width; must be one of F, H, or NA (blank)
CourseNData1Can be converted to a numeric value
SpeedNData2Can be converted to a numeric value
BeaufortVData1Must be a whole number between 0 and 9
Swell heightVData2Can be converted to a numeric value
Wind speedVData5Can be converted to a numeric value
Rain or fogWData1Must be between 0 and 5 and either a whole number or have decimal value .5
Horizontal sunWData2Must be a whole number between 0 and 12
Vertical sunWData3Must be a whole number between 0 and 12
VisibilityWData5Can be converted to a numeric value
Sighting (mammal)S, K, MData3-7Can be converted to a numeric value
Sighting (mammal)GData5-7Can be converted to a numeric value
Sighting cue (mammal)S, K, MData3Must be a whole number between 1 and 6
Sighting method (mammal)S, K, M, GData4Must be a whole number between 1 and 7
Bearing (mammal)S, K, M, GData5Must be a whole number between 0 and 360
PhotosAData3Must be one of N, Y, n, y, or NA (blank)
BirdsAData4Must be one of N, Y, n, y, or NA (blank)
Calibration schoolS, K, MData10Must be one of N, Y, n, y, or NA (blank)
Aerial photos takenS, K, MData11Must be one of N, Y, n, y, or NA (blank)
Biopsy takenS, K, MData12Must be one of N, Y, n, y, or NA (blank)
Species codesAData5-8If a species codes file is provided, must be one of the provided codes
Resights, kData2-5Can be converted to a numeric value
Turtle speciestData2If a species codes file is provided, must be one of the provided codes
Turtle sightingtData3-5, 7Can be converted to a numeric value
Turtle JFRtData6Must be one of F, J, N, R, or NA (blank)
Fishing vesselFData2-4Can be converted to a numeric value
Sighting info1-8Data2-8Can be converted to a numeric value
Sighting info1-8Data9The Data9 column must be NA (blank) for events 1-8

In the table above, 'between' means inclusive.

Long-term items, and checks that are not performed:

  • Check that datetimes are sequential, meaning they 1) are the same as or 2) come after the previous event

  • Check that A events only come immediately after a G/S/K/M event, and all G/S/K/M events have an A after them. And that each has at least one group size estimate (1:8 event)

Examples

y <- system.file("das_sample.das", package = "swfscDAS")
if (interactive()) das_check(y)