Skip to contents

This function downloads AMSR data.

Usage

dod.amsr(
  date = Sys.Date() - 4L,
  destdir = ".",
  server = "https://data.remss.com/amsr2/ocean/L3/v08.2",
  type = "3day",
  quiet = FALSE,
  debug = 0
)

Arguments

date

either a Date object or a character or time object that can be converted to such an object with as.Date(). The default is four days prior to the present date, which is usually the latest view that can be obtained, if type is "3day", as is its default.

destdir

character giving destination directory (defaults to ".", the present directory). The directory must exist. The author usually sets this to "~/data/amsr", so that the file will be in a central location.

server

character value indicating the base server location. The default value ought to be used unless the data provider changes their web scheme ... but in that case, it is hoped that users will contact the developers so that the package can be updated.

type

character value indicating where to get the data. This may be "3day" (the default), for a composite covering 3 days of observation, which removes most viewing-path and cloud blanks, "daily" for a daily reading, "weekly" for a composite covering a week, or "monthly" for a composite covering a month. In the "daily" case, the data arrays are 3D, with the third dimension representing ascending and descending traces, but in all the other cases, the arrays are 2D.

quiet

a logical value, passed to curl::curl_download(), which does the downloading. If this is TRUE (the default), then the work is done quietly. Until version version 0.1.12, this parameter was called silent, but it was renamed to match the corresponding argument in curl::curl_download(), which may be more familiar to users.

debug

an integer value indicating the level of debugging. If this exceeds 0, then some debugging messages will be printed. This value is passed down to related functions, but with 1 subtracted for each pass.

Value

dod.amsr returns a character value holding the full pathname of the downloaded file.

Details

This works by constructing URLs based on the arguments provided. The author is unaware of any documentation that specifies the directory structure on the server, and so the construction is based on examining the server with a web browser. Obviously, this is a fragile approach that will lead to failed downloads if the remote directory structure changes.

Historical notes

  • Until September 2024 dod.amsr() required 3 parameters to specify a time (year, month and day). This was difficult to use and also led to messy coding, so these 3 parameters were replaced with date.

  • Until July 2023, dod.amsr() worked by calling oce::download.amsr(). However, at that time, the author noticed changes in both the directory structure of the remote server, and the format of the data files. The new directory structure was addressed by a complete rewrite of the code within dod, and a severing of the connection to the oce function.

See also

Other functions that download files: dod.buoy(), dod.coastline(), dod.ctd(), dod.ctd.bats(), dod.ctd.bbmp(), dod.ctd.gtspp(), dod.ctd.itp(), dod.met(), dod.tideGauge(), dod.topo()

Author

Dan Kelley

Examples

if (interactive()) { # sidestep a pkgdown::build_site() error
    library("oce")
    # Get temporary space (to obey CRAN rules)
    destdir <- tempdir()
    file <- dod.amsr(destdir = destdir)
    natl <- read.amsr(file) |>
        subset(-90 < longitude & longitude < 0) |>
        subset(20 < latitude & latitude < 70)
    plot(natl)
    # Clean up space
    unlink(destdir, recursive = TRUE)
}