Skip to contents

Make a ctd object adhere more closely with the expected form, e.g. by moving certain things from the data slot to the metadata slot, where other oce functions may assume they will be located. This can be handy for objects that were set up incorrectly, perhaps by inappropriate user insertions.

Usage

ctdRepair(x, debug = getOption("oceDebug"))

Arguments

x

a ctd object.

debug

an integer specifying whether debugging information is to be printed during the processing. This is a general parameter that is used by many oce functions. Generally, setting debug=0 turns off the printing, while higher values suggest that more information be printed. If one function calls another, it usually reduces the value of debug first, so that a user can often obtain deeper debugging by specifying higher debug values.

Value

A ctd object that is based on x, but possibly with some elements changed as described in the “Details” section.

Details

The possible changes fall into the following categories.

  1. If unit-length values for latitude, longitude, time, or station exist in the data slot, move them to the metadata slot. However, leave them in data if their length exceeds 1, because this can arise with towyo data.

  2. If the metadata or data slot contains items named time, recoveryTime, startTime, or systemUploadTime, and if these are not in POSIXt format, then use as.POSIXct() with tz="UTC" to convert them to POSIXt format. If that conversion fails, owing to an unrecognizable format, then the original value is retained, unaltered.

Author

Dan Kelley

Examples

library(oce)
data(ctd)
# Insert location information into 'data' slot, although it belongs in 'metadata'.
ctd@data$latitude <- ctd@metadata$latitude # Done by experts only!
ctd@data$longitude <- ctd@metadata$longitude # Done by experts only!
repaired <- ctdRepair(ctd)
#> Warning: moving unit-length data$longitude to metadata$longitude
#> Warning: moving unit-length data$latitude to metadata$latitude
#> Warning: changed metadata$recoveryTime to a POSIXct value