This function provides an easy way to look up values within an argoFloats object, without the need to know the exact structure of the data. The action taken by [[ depends on the type element in the metadata slot of the object (which is set by the function that created the object), on the value of i and, in some cases, on the value of j; see “Details”.

# S4 method for argoFloats
[[(x, i, j, ...)

Arguments

x

an argoFloats object.

i

a character value that specifies the item to be looked up; see “Details”.

j

supplemental index value, used for some x types and i values; see “Details”.

...

ignored.

Value

the indicated item, or NULL if it is neither stored within the first argument nor computable from its contents.

Details

There are several possibilities, depending on the object type, as listed below. Note that these possibilities are checked in the order listed here.

  1. For all object types:

    1. If i is "metadata" then the metadata slot of x is returned.

    2. Otherwise, if i is "data" then the data slot of x is returned.

    3. Otherwise, if i is "cycle" then a character vector of the cycle numbers is returned.

    4. Otherwise, if i is "processingLog" then the processingLog slot of x is returned.

    5. Otherwise, if i is "ID" then a character vector of the ID numbers is returned.

    6. Otherwise, the following steps are taken, depending on type.

  2. If type is "index", i.e. if x was created with getIndex() or with subset,argoFloats-method() acting on the result of getIndex(), then:

    1. If i is numeric and j is unspecified, then i is taken to be an index that identifies the row(s) of the data frame that was constructed by getIndex() based on the remote index file downloaded from the Argo server. This has elements file for the remote file name, date for the date of the entry, latitude and longitude for the float position, etc.

    2. If i is the name of an item in the metadata slot, then that item is returned. The choices are: "destdir", "destfileRda", "filename", "ftpRoot", "header", "server", "type", and "url".

    3. Otherwise, if i is the name of an item in the data slot, then that item is returned. The choices are: "date", "date_update", "file", "institution", "latitude", "longitude", "ocean", and "profiler_type". Note that "time" and "time_update" may be used as synonyms for "date" and "date_update".

    4. Otherwise, if i=="index" then that item from the data slot of x is returned. (For the possible names, see the previous item in this sub-list.)

    5. Otherwise, if i is an integer, then the i-th row of the index item in the data slot is returned. This is a good way to learn the longitude and latitude of the profile, the file name on the server, etc.

    6. Otherwise, if i is "ID" then the return value is developed from the index$file item within the data slot of x, in one of three cases:

      1. If j is not supplied, the return value is a vector holding the identifiers (character codes for numbers) for all the data files referred to in the index.

      2. Otherwise, if j is numeric, then the return value is a subset of the ID codes, as indexed by j.

      3. Otherwise, an error is reported.

    7. If i is "length", the number of remote files pointed to by the index is returned.

  3. Otherwise, if type is "profiles", i.e. if x was created with getProfiles(), then:

    1. If i is numeric and j is unspecified, then return the local file name(s) that are identified by using i as an index.

    2. If i is the name of an item in the metadata slot, then that item is returned. The choices are: "type" and "destdir".

    3. Otherwise, if i is the name of an item in the data slot, then that item is returned. There is only one choice: "file".

    4. If i is "length", the number of local file names that were downloaded by getProfiles() is returned.

  4. Otherwise, if type is "argos", i.e. if x was created with readProfiles(), then:

    1. If i is equal to "argos", and j is unspecified, then a list holding the oce::argo objects stored within x is returned.

    2. If i is equal to "argos", and j is provided, then the associated oce::argo object is returned.

    3. If i is numeric and j is unspecified, then return the argo objects identified by using i as an index.

    4. If i is the name of an item in the metadata slot, then that item is returned. There is only choice, "type".

    5. Otherwise, if i is the name of an item in the data slot, then that item is returned as a named list. (At present, there is only one choice: "argos".)

    6. Otherwise, if i is "length" then the number of oce-type argo objects in x is returned.

    7. Otherwise, if i is a character value then it is taken to be an item within the metadata or data slots of the argo objects stored in x, and the returned value is a list containing that information with one (unnamed) item per profile. If j is provided and equal to "byLevel", then the items from the metadata are repeated (if necessary) and formed into matrix or vector of the same shape as the "pressure" field; this can be convenient for computations involving items that only occur once per profile, such as "longitude", but it should not be used for items that are not level-specific, such as the various "HISTORY_*" elements, which apply to a dataset, not to a level

    8. Otherwise, NULL is reported.

  5. Otherwise, an error is reported.

References

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

Author

Dan Kelley

Examples

data(index)
# Full remote filename for first two item in index
paste0(index[["server"]], "/dac/", index[["cycle", 1:2]])
#> [1] "https://data-argo.ifremer.fr/dac/124"
#> [2] "https://data-argo.ifremer.fr/dac/125"
# File names and geographical locations of first 5 items in index
index5 <- subset(index, 1:5)
#> Kept 5 cycles (0.496%)
data.frame(file=gsub(".*/", "", index5[["file"]][1]),
           lon=index5[["longitude"]],
           lat=index5[["latitude"]])
#>              file     lon    lat
#> 1 D1901584_124.nc -76.231 27.705
#> 2 D1901584_124.nc -76.024 27.773
#> 3 D1901584_124.nc -76.320 28.064
#> 4 D1901584_124.nc -76.520 28.101
#> 5 D1901584_124.nc -77.108 27.794