sidfex.download.obs: Download SIDFEx Observations

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

sidfex.download.obsR Documentation

Download SIDFEx Observations

Description

Download observations corresponding to one or more SIDFEx target(s), or from other IABP buoys.

Usage

sidfex.download.obs(index=NULL,TargetID=NULL,data.path=NULL,baseurl=NULL,try.N=30,try.timeout=20)

Arguments

index

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

TargetID

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

data.path

NULL or a character specifying the directory where the observational data are to be stored. 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.

baseurl

NULL or a character or character vector specifying the URL from where to fetch the data. If NULL (default), different default locations are used for different targets (IABP versus non-IABP).

try.N

an integer that specifies how often the download of each individual file shall be tried. Default is 10.

try.timeout

a numeric value that specifies a time limit for each try of a file download in seconds. Default is 30.

Value

A character vector with the TargetIDs for which observations have been downloaded.

Author(s)

Helge Goessling

See Also

sidfex.read.obs, sidfex.download.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

# To download forecasts corresponding to an index which in turn corresponds to SIDFEx forecast data, you need to download the forecast data first using sidfex.download.fcst(). Otherwise the subsequent line will fail. Note that the second line downloads data for all buoys for which any forecast data have been downloaded (which is documented in the index).
# First load the index that refelcts the currently downloaded forecast data.
index = sidfex.load.index()
# Show for which TargetIDs forecast data exist
unique(index$TargetID)
res = sidfex.download.obs(index=index)
# (the same can be achieved with sidfex.download.obs(TargetID=unique(index$TargetID)) )

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