| subset,argoFloats-method {argoFloats} | R Documentation |
Subset an argoFloats Object
Description
Return a subset of an argoFloats object. This applies
only to objects of type "index", as created with getIndex() or subset()
acting on such a value, or of type "argos", as created with readProfiles().
(It cannot be used on objects of type "profiles", as created with getProfiles().)
There are two ways to use subset(). Method 1. supply
the subset argument. This may be a logical vector indicating
which entries to keep (by analogy to the base-R subset()
function) or it may be an integer vector holding the indices of entries to
be retained. Method 2. do not supply subset. In this
case, the action is determined by the third (...)
argument; see ‘Details’.
Usage
## S4 method for signature 'argoFloats'
subset(x, subset = NULL, ...)
Arguments
x |
an |
subset |
optional numerical or logical vector that indicates which
indices of |
... |
the first entry here must be either (a) a list named |
Details
The possibilities for the ... argument are as follows.
An integer vector giving indices to keep.
A list named
circlewith numeric elements namedlongitude,latitudeandradius. The first two give the center of the subset region, and the third gives the radius of that region, in kilometers.A list named
rectanglethat has elements namedlongitudeandlatitude, two-element numeric vectors giving the western and eastern, and southern and northern limits of the selection region.A list named
polygonthat has elements namedlongitudeandlatitudethat are numeric vectors specifying a polygon within which profiles will be retained. The polygon must not be self-intersecting, and an error message will be issued if it is. If the polygon is not closed (i.e. if the first and last points do not coincide) the first point is pasted onto the end, to close it.A vector or list named
parameterthat holds character values that specify the names of measured parameters to keep. See section 3.3 of Reference 1 for a list of parameters.A list named
timethat has elementsfromandtothat are either POSIXt times, or character strings thatsubset()will convert to POSIXt times usingas.POSIXct()withtz="UTC".A list named
institutionthat holds a single character element that names the institution. The permitted values are:"AO"for Atlantic Oceanographic and Meteorological Laboratory;"BO"for British Oceanographic Data Centre;"CS"for Commonwealth Scientific and Industrial Research Organization;"HZ"for China Second Institute of Oceanography;"IF"for Ifremer, France;"IN"for India National Centre for Ocean Information Services;"JA"for Japan Meteorological Agency;"KM"for Korea Meteorological Agency;"KO"for Korea Ocean Research and Development Institute;"ME"for Marine Environment Data Section; and"NM"for National Marine Data & Information Service.A list named
deepthat holds a logical value indicating whether argo floats are deep argo (i.e.profiler_type849, 862, and 864).A list named
IDthat holds a character value specifying a float identifier.A list named
oceanthat holds a single character element that names the ocean. The permitted values are:"A"for Atlantic Ocean Area, from 70 W to 20 E,"P"for Pacific Ocean Area, from 145 E to 70 W, and"I"for Indian Ocean Area, from 20 E to 145 E.A character value named
dataMode, equal to eitherrealtimeordelayed, that selects whether to retain real-time data or delayed data. There are two possibilities, depending on thetypeof thexargument. Case 1. Ifxis oftype="index", then the subset is done by looking for the lettersRorDin the source filename. Note that a file in the latter category may contain some profiles that are of delayed mode and also some profiles that are ofrealtimeoradjustedmode. Case 2. Ifxis of typeargos, then the subset operation is done for each profile within the dataset. Sometimes this will yield data arrays with zero columns.An integer or character value named
cyclethat specifies which cycles are to be retained. This is done by regular-expression matching of the filename, looking between the underline character ("_") and the suffix (.nc), but note that the expression is made up of a compulsory component comprising 3 or 4 digits, and an optional component that is either blank or the character"D"(which designates a descending profile). Thus,001will match both*_001.ncand*_001D.nc. Note this can be used for both"index"and"argos"types.A character value named
direction, equal to either "descent" or "ascent", that selects whether to retain data from the ascent or decent phase.An integer value named
profilethat selects which profiles to retain. Note that this type of subset is possible only for objects of type"argos".An integer value named
cyclethat selects which cycles to retain.A character value named
dataStateIndicator, equal to either "0A", "1A", "2B", "2B+", "2C", "2C+", "3B", or "3C" that selects whichdataStateIndicatorto keep (see table 6 of Reference 1 for details of these codes). This operation only works for objects of type"argos".A list named
sectionthat has four elements:longitude,latitude,width, andsegments. The first two of these are numeric vectors that define the spine of the section, in degrees East and North, respectively. These are both mandatory, while bothwidthandsegmentsare optional. If given,widthis taken as maximal distance between an Argo and the spine, for that float to be retained. Ifwidthis not given, it defaults to 100km. If given,segmentsis eitherNULLor a positive integer. SettingsegmentstoNULLwill cause the float-spine distance to be computed along a great-circle route. By contrast, ifsegmentsis an integer, then the spine is traced usingstats::approx(), creatingsegmentsnew points. Ifsegmentsis not provided, it defaults to 100.
In all cases, the notation is that longitude is positive for degrees East and negative for degrees West, and that latitude is positive for degrees North and negative for degrees South. For more on this function, see Kelley et al. (2021).
Value
An argoFloats object, restricted as indicated.
Author(s)
Dan Kelley and Jaimie Harbin
References
Carval, Thierry, Bob Keeley, Yasushi Takatsuki, Takashi Yoshida, Stephen Loch, Claudia Schmid, and Roger Goldsmith. Argo User's Manual V3.3. Ifremer, 2019.
doi:10.13155/29825.Kelley, D. E., Harbin, J., & Richards, C. (2021). argoFloats: An R package for analyzing Argo data. Frontiers in Marine Science, (8), 636922. doi:10.3389/fmars.2021.635922
Examples
library(argoFloats)
data(index)
data(indexSynthetic)
# Subset to the first 3 profiles in the (built-in) index
indexFirst3 <- subset(index, 1:3)
# Subset to a circle near Abaco Island
indexCircle <- subset(index, circle=list(longitude=-77.5, latitude=27.5, radius=50))
# Subset to a rectangle near Abaco Island
lonlim <- c(-76.5, -76)
latlim <- c(26.5, 27.5)
indexRectangle <- subset(index, rectangle=list(longitude=lonlim, latitude=latlim))
# Subset to a polygon near Abaco Island
lonp <- c(-77.492, -78.219, -77.904, -77.213, -76.728, -77.492)
latp <- c( 26.244, 25.247, 24.749, 24.987, 25.421, 26.244)
indexPolygon <- subset(index, polygon=list(longitude=lonp, latitude=latp))
# Subset to year 2019
index2019 <- subset(index, time=list(from="2019-01-01", to="2019-12-31"))
# Subset to Canadian MEDS data
indexMEDS <- subset(index, institution="ME")
# Subset to profiles with oxygen data
indexOxygen <- subset(indexSynthetic, parameter="DOXY")
# Subset to profiles with both salinity and 380-nm downward irradiance data
indexSalinityIrradiance <- subset(indexSynthetic, parameter=c("PSAL", "DOWN_IRRADIANCE380"))