Learn R Programming

swfscDAS (version 0.4.0)

das_check: Check DAS file

Description

Check that DAS file has accepted 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, the 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 is also written to a text file

A warning is printed if any events are r events

Details

Precursor to a more comprehensive DASCHECK program. 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.

  • 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:

Item Event Column Requirement
Cruise number B Data1 Can be converted to a numeric value
Mode B Data2 Must be one of C, P, c, p, or NA (blank)
Echo sounder B Data4 Must be one of Y, N, y, n, or NA (blank)
Effort type R Data1 Must be one of F, N, S, or NA (blank)
Effective strip width sides R Data2 Must be one of F, H, or NA (blank)
Course N Data1 Can be converted to a numeric value
Speed N Data2 Can be converted to a numeric value
Beaufort V Data1 Must be a whole number between 0 and 9
Swell height V Data2 Can be converted to a numeric value
Wind speed V Data5 Can be converted to a numeric value
Rain or fog W Data1 Must be between 0 and 5 and be either a whole number or have a decimal value of 0.5
Horizontal sun W Data2 Must be a whole number between 0 and 12
Vertical sun W Data3 Must be a whole number between 0 and 12
Visibility W Data5 Can be converted to a numeric value
Sighting (mammal) S, K, M Data3-7 Can be converted to a numeric value
Sighting (mammal) G Data5-7 Can be converted to a numeric value
Sighting cue (mammal) S, K, M Data3 Must be a whole number between 1 and 6
Sighting method (mammal) S, K, M, G Data4 Must be a whole number between 1 and 7
Bearing (mammal) S, K, M, G Data5 Must be a whole number between 0 and 360
Photos A Data3 Must be one of N, Y, n, y, or NA (blank)
Birds A Data4 Must be one of N, Y, n, y, or NA (blank)
Calibration school S, K, M Data10 Must be one of N, Y, n, y, or NA (blank)
Aerial photos taken S, K, M Data11 Must be one of N, Y, n, y, or NA (blank)
Biopsy taken S, K, M Data12 Must be one of N, Y, n, y, or NA (blank)
Species codes A Data5-8 If a species codes file is provided, must be one of the provided codes
Resight s, k Data2-5 Can be converted to a numeric value
Turtle species t Data2 If a species codes file is provided, must be one of the provided codes
Turtle sighting t Data3-5, 7 Can be converted to a numeric value
Turtle JFR t Data6 Must be one of F, J, N, R, or NA (blank)
Fishing vessel F Data2-4 Can be converted to a numeric value
Sighting info 1-8 Data2-8 Can be converted to a numeric value
Sighting info 1-8 Data9 The Data9 column must be NA (blank) for events 1-8

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

  • Add check for sequential date/time

  • Add column with cruise number to output

  • 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)

  • Check that lat/lon values are within [-90, 90] and [-180, 180]

Examples

Run this code
# NOT RUN {
y <- system.file("das_sample.das", package = "swfscDAS")
das_check(y)

# }

Run the code above in your browser using DataLab