ctdTrim {oce}R Documentation

Trim Beginning and Ending of a CTD cast

Description

Often in CTD profiling, the goal is to isolate only the downcast, discarding measurements made in the air, in an equilibration phase in which the device is held below the water surface, and then the upcast phase that follows the downcast. This is handled reasonably well by ctdTrim with method="downcast", although it is almost always best to use plotScan() to investigate the data, and then use the method="index" or method="scan" method based on visual inspection of the data.

Usage

ctdTrim(
  x,
  method,
  removeDepthInversions = FALSE,
  parameters = NULL,
  indices = FALSE,
  debug = getOption("oceDebug")
)

Arguments

x

a ctd object.

method

A string (or a vector of two strings) specifying the trimming method, or a function to be used to determine data indices to keep. If method is not provided, "downcast" is assumed. See “Details”.

removeDepthInversions

Logical value indicating whether to remove any levels at which depth is less than, or equal to, a depth above. (This is needed if the object is to be assembled into a section, unless ctdDecimate() will be used, which will remove the inversions.

parameters

A list whose elements depend on the method; see “Details”.

indices

Logical value indicating what to return. If indices=FALSE (the default), then the return value is a subsetted ctd object. If indices=TRUE, then the return value is a logical vector that could be used to subset the data with subset,ctd-method() or to set data-quality flags.

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.

Details

ctdTrim begins by examining the pressure differences between subsequent samples. If these are all of the same value, then the input ctd object is returned, unaltered. This handles the case of pressure-binned data. However, if the pressure difference varies, a variety of approaches are taken to trimming the dataset.

Value

Either a ctd object or a logical vector of length matching the data. In the first case, which is the default, the elements of the data slot will have been trimmed, along with some elements of the metadata slot (e.g. metadata4flags and, if present and of length matching data$pressure, both metadata$longitude and metadata$latitude). The second case, achieved by setting indices=FALSE, may be helpful for advanced users who wish to do things like construct data flags to be inserted into the object.

Historical Note

The subsetting of longitude and latitude in the metadata slot was introduced on 2022-12-13, for use with ctd objects created using as.ctd() on rsk objects created by using read.rsk() on Ruskin files that hold data from RBR CTD instruments linked with phone/tablet devices equipped with GPS sensors.

Sample of Usage

library(oce)
data(ctdRaw)
# Example 1: focus on downcast
plot(ctdTrim(ctdRaw))
# Example 2: user-supplied function.
trimByIndex<-function(data, parameters) {
    parameters[1] < data$scan & data$scan < parameters[2]
}
trimmed <- ctdTrim(ctdRaw, trimByIndex, parameters=c(130, 380))
plot(trimmed)

Author(s)

Dan Kelley and Clark Richards

References

The Seabird CTD instrument is described at ⁠http://www.seabird.com/products/spec_sheets/19plusdata.htm⁠.

Seasoft V2: SBE Data Processing, SeaBird Scientific, 05/26/2016

See Also

Other things related to ctd data: CTD_BCD2014666_008_1_DN.ODF.gz, [[,ctd-method, [[<-,ctd-method, as.ctd(), cnvName2oceName(), ctd-class, ctd.cnv.gz, ctdDecimate(), ctdFindProfilesRBR(), ctdFindProfiles(), ctdRaw, ctdRepair(), ctd_aml.csv.gz, ctd, d200321-001.ctd.gz, d201211_0011.cnv.gz, handleFlags,ctd-method, initialize,ctd-method, initializeFlagScheme,ctd-method, oceNames2whpNames(), oceUnits2whpUnits(), plot,ctd-method, plotProfile(), plotScan(), plotTS(), read.ctd.aml(), read.ctd.itp(), read.ctd.odf(), read.ctd.odv(), read.ctd.saiv(), read.ctd.sbe(), read.ctd.ssda(), read.ctd.woce.other(), read.ctd.woce(), read.ctd(), setFlags,ctd-method, subset,ctd-method, summary,ctd-method, woceNames2oceNames(), woceUnit2oceUnit(), write.ctd()


[Package oce version 1.8-2 Index]