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
circle
with numeric elements namedlongitude
,latitude
andradius
. The first two give the center of the subset region, and the third gives the radius of that region, in kilometers.A list named
rectangle
that has elements namedlongitude
andlatitude
, two-element numeric vectors giving the western and eastern, and southern and northern limits of the selection region.A list named
polygon
that has elements namedlongitude
andlatitude
that 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
parameter
that 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
time
that has elementsfrom
andto
that are either POSIXt times, or character strings thatsubset()
will convert to POSIXt times usingas.POSIXct()
withtz="UTC"
.A list named
institution
that 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
deep
that holds a logical value indicating whether argo floats are deep argo (i.e.profiler_type
849, 862, and 864).A list named
ID
that holds a character value specifying a float identifier.A list named
ocean
that 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 eitherrealtime
ordelayed
, that selects whether to retain real-time data or delayed data. There are two possibilities, depending on thetype
of thex
argument. Case 1. Ifx
is oftype="index"
, then the subset is done by looking for the lettersR
orD
in 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 ofrealtime
oradjusted
mode. Case 2. Ifx
is 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
cycle
that 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,001
will match both*_001.nc
and*_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
profile
that selects which profiles to retain. Note that this type of subset is possible only for objects of type"argos"
.An integer value named
cycle
that selects which cycles to retain.A character value named
dataStateIndicator
, equal to either "0A", "1A", "2B", "2B+", "2C", "2C+", "3B", or "3C" that selects whichdataStateIndicator
to keep (see table 6 of Reference 1 for details of these codes). This operation only works for objects of type"argos"
.A list named
section
that 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 bothwidth
andsegments
are optional. If given,width
is taken as maximal distance between an Argo and the spine, for that float to be retained. Ifwidth
is not given, it defaults to 100km. If given,segments
is eitherNULL
or a positive integer. Settingsegments
toNULL
will cause the float-spine distance to be computed along a great-circle route. By contrast, ifsegments
is an integer, then the spine is traced usingstats::approx()
, creatingsegments
new points. Ifsegments
is 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"))