sidfex.read.obs: Read SIDFEx Observations

View source: R/sidfex.read.obs.R

sidfex.read.obsR Documentation

Read SIDFEx Observations

Description

Read observations corresponding to one or more SIDFEx targets. Optionally (default), in case of multiple data points (rows) valid for the same position time and coordinates, only the first is used, and data points with NA_values in any of the columns relevant for the trajectories (time and loaction) will be removed.

Usage

sidfex.read.obs(index = NULL, TargetID = NULL, data.path = NULL, NA_values = -999,
                unique_POS_time = TRUE, add_RelTimeDay_Ref = "firstobs")

Arguments

index

an index data frame specifying the SIDFEx forecasts for which the corresponding observations are to be read. Used only if TargetID=NULL.

TargetID

a character or character vector specifying which observations are to be read. If TargetID is specified, index is ignored.

data.path

NULL or a character specifying the directory of the observational data. If NULL, it is attempted to source a file named .SIDFEx in the home directory where a character variable data.path.obs needs to be defined.

NA_values

a numeric scalar or vector specifying one or more values to be considered NA; rows with such value in any of the columns Year, POS_DOY, Lat, or Lon will be removed. If NULL, no values will be considered NA. The default is -999 as this value is used as NA at least in some buoy data.

unique_POS_time

a logical value specifying whether or not in case of multiple data points (rows) valid for the same position time and coordinates, all rows expect the first shall be removed. Default is TRUE.

add_RelTimeDay_Ref

this argument specifies whether a column with a relative time axis (days since ...) shall be added. Valid values are NULL (no axis is added), 'firstobs' (default; the first data time is used as reference), and a 2-element numeric vector specifying the Year and the DayOfYear of the reference time. Note that the DayOfYear definition for SIDFEx (adopted from IABP) is that January 1st start at DOY=1.000, meaning that noon on January first is DOY=1.500. To get the same in the relative time axis for a particular year, one must set add_RelTimeDay_Ref=c(YYYY,365) where YYYY is the previous (non-leap-)year (the second element would be 366 in leap years).

Value

If observations for more than one TargetID are read based on the argument index, a list with the two elements: index.map maps the rows in index to the Target IDs, and res.list is a list with one entry (a list with the entries filename, TargetID, RelTime_RefYearDOY, and data) for each Target ID. If observations for more than one TargetID are read based on the argument TargetID, a list with one entry (a list with the entries filename, TargetID, RelTime_RefYearDOY, and data) for each Target ID. If observations for just one TargetID, not matter if based on which argument, a list with the entries filename, TargetID, and data.

Author(s)

Helge Goessling

See Also

sidfex.download.obs, sidfex.read.fcst

Examples

# Download observations corresponding to an IABP buoy with IMEI 300234063991680
res = sidfex.download.obs(TargetID="300234063991680")
# Read the data
dat = sidfex.read.obs(TargetID="300234063991680")
# Show the data header
head(dat$data)
# Make a line plot for the latitude against the relative time axis
plot(dat$data$RelTimeDay,dat$data$Lat,type="l")
# Note that for this buoy, the plot reveals spurious data points at the beginning where the buoy hadn't been deployed yet

helgegoessling/SIDFEx documentation built on March 15, 2024, 2:26 p.m.