pfmc-assessments / PacFIN.Utilities

R code to manipulate data from the PacFIN database for assessments
http://pfmc-assessments.github.io/PacFIN.Utilities
Other
7 stars 1 forks source link

Warning when length scale may be incorrect #83

Closed brianlangseth-NOAA closed 1 year ago

brianlangseth-NOAA commented 1 year ago

Is your feature request related to a problem? Please describe. cleanPacFIN can result in incorrectly scaled lengths. For canary bds data, samples with unknown length units are assumed to be in mm and are divided by 10, even when the length is pretty clearly in cm. These are different than samples without lengths (NA)

To Reproduce Steps to reproduce the behavior:

  1. Read canary bds data dir <- "//nwcfile/FRAM/Assessments/Assessment Data/2023 Assessment Cycle/canary rockfish/PacFIN data" load(file.path(dir, "PacFIN.CNRY.bds.01.Sep.2022.RData")) pacfin <- bds.pacfin pacfin2 <- cleanPacFIN(Pdata=pacfin,CLEAN=TRUE,verbose=TRUE)
  2. run pacfin2[which(pacfin2$FISH_LENGTH_UNITS=="UNK"),]
  3. length is in the 40s but lengthcm is 4

Expected behavior This may be super rare, but it does require additional checks on the users part. Possible solutions are 2) remove samples with unknown lengths 3) run a convoluted checker to determine whether an issue is likely based on the entered length

Describe the solution you'd like 1) Output a warning highlighting that X number of fish may have unit issues, where X is the number of samples with unknown length

Describe alternatives you've considered 2) remove samples with unknown lengths 3) run a convoluted checker to determine whether an issue is likely based on the entered length

Additional context image

kellijohnson-NOAA commented 1 year ago

Thanks @brianlangseth-NOAA for reporting this. Instead of writing convoluted checkers that will likely miss something for someone along the way, I opted to write more informative stop and message statements that tell the user that their data contains measurements with unknown units and a valid unit must be assigned before they can move on.