Skip to content

Inconsistent handling of serialnumber in StoX... does it have a different meaning in Biotics and StoX? #290

Description

@yreecht

Hi,

I believe what follows is rather an issue with StoX than improperly entered data for some surveys in Biotics. It may also be linked to issue #267.

Here is a minimal example for reproducing the issue:

library(dplyr)
library(RstoxData)

## Last snapshot downloaded from https://datasetexplorer.hi.no/apps/datasetexplorer/v2/navigation/Cruises/Forskningsfart%C3%B8y/2018/G.O.Sars_LMEL/2018102
dataFile <- "./biotic_cruiseNumber_2018102_G+O+Sars_2021-01-21T08.58.28.744Z.xml"

dataB <- RstoxData::ReadBiotic(FileNames = dataFile)
dataSB <- RstoxData::StoxBiotic(BioticData = dataB)

dataSB <- AddToStoxBiotic(StoxBioticData = dataSB, BioticData = dataB,
                          VariableNames = c("serialnumber"))


dataSB$Haul %>%
    filter(HaulKey %in% c(60038:60039))

## Serial number is attached to the station:
dataSB$Station %>%
    filter(serialnumber %in% c(60038:60039))

hh <- MergeStoxBiotic(StoxBioticData = dataSB, TargetTable = "Haul")

## Inconsistency between serialnumber and HaulKey (which corresponds to serialnumber in Biotics file)
hh %>%
    filter(HaulKey %in% c(60038:60039) |
           serialnumber %in% c(60038:60039))

## Note that position, time, depth,... above are now wrong for the second haul of the station!
dataB[[1]]$fishstation %>%
    select(missiontype:longitudeend) %>%
    filter(serialnumber %in% c(60038:60039))

This happens when several hauls were done at the same location (called station in BioticEditor: see contextual help screenshots below).
Biotic_2023-03-03_09-31

2023-03-03_10-30

2023-03-03_10-46

It seems however that StoX attaches the serial number, supposed in Biotics to be unique to the sampling unit, to the station rather than the haul.

For the time being I will be using, as a workaround, the HaulKey (which otherwise seems to be consistently the same as serialnumber) where I was usually using the serial number (and drop that one), but this is quite confusing and leads to inconsistent data when merging tables.

Best wishes,
Yves

[EDIT:]
There is in fact a warning message regarding multiple hauls per station that cannot been handled:

Warning message:
In firstPhase(BioticData, datatype, stoxBioticObject, SplitTableAllocation = SplitTableAllocation) :
  StoX: There are more than one **'serialnumber' (HaulKey in StoxBioticData)** for 14 out of 88 'station'(StationKey in StoxBioticData) in the NMDBiotic data. In DefineBioticAssignment() it is currently only possible to asssing all hauls of a station in the map (manual assignment). If certain Hauls should be exclcuded, use FilterStoxBiotic(). More than one serialnumber for the following cruise/station (of the fishstation table of the BioticData):
	2018102/38
	2018102/39
        [...]

What is confusing is then why is "serialnumber" attached to the Station table, and not the Haul in the StoxBiotic object.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions