Skip to content

Commit

Permalink
argo is back up fix #358
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jun 12, 2020
1 parent 3556c07 commit 251cb32
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 98 deletions.
14 changes: 3 additions & 11 deletions R/argo.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#' Get Argo buoy data
#'
#' THE ARGO API IS DOWN. WE'VE BEEN UNSUCCESSFUL FIGURING OUT WHERE
#' THE API MOVED TO OR IF IT STILL EXISTS. SEE "API Status" SECTION
#' BELOW FOR MORE DETAILS.
#'
#' @export
#' @name argo
Expand All @@ -14,7 +10,6 @@ argo_search <- function(func = NULL, of = NULL, qwmo = NULL, wmo = NULL,
from =NULL, to = NULL, dmode = NULL, pres_qc = NULL, temp_qc = NULL,
psal_qc = NULL, doxy_qc = NULL, ticket = NULL, limit = 10, ...) {

stop("the argo API is down", call. = FALSE)
if (!is.null(box)) box <- paste0(box, collapse = ",")
args <- noaa_compact(list(get = func, of = of, qwmo = qwmo, wmo = wmo,
box = box, area = area, around = around, year = year, yearmin = yearmin,
Expand All @@ -29,7 +24,6 @@ argo_search <- function(func = NULL, of = NULL, qwmo = NULL, wmo = NULL,
#' @export
#' @rdname argo
argo_files <- function(wmo = NULL, cyc = NULL, ...) {
stop("the argo API is down", call. = FALSE)
args <- noaa_compact(list(wmo = wmo, cyc = cyc, file = ""))
res <- argo_GET(argo_base, argo_api, args, ...)
jsonlite::fromJSON(parse_argo(res))
Expand All @@ -38,7 +32,6 @@ argo_files <- function(wmo = NULL, cyc = NULL, ...) {
#' @export
#' @rdname argo
argo_qwmo <- function(qwmo, limit = 10, ...) {
stop("the argo API is down", call. = FALSE)
args <- noaa_compact(list(qwmo = qwmo, limit = limit))
res <- argo_GET(argo_base, argo_api, args, ...)
jsonlite::fromJSON(parse_argo(res))
Expand All @@ -47,7 +40,6 @@ argo_qwmo <- function(qwmo, limit = 10, ...) {
#' @export
#' @rdname argo
argo_plan <- function(...) {
stop("the argo API is down", call. = FALSE)
args <- noaa_compact(list(plan = ""))
res <- argo_GET(argo_base, argo_api, args, ...)
jsonlite::fromJSON(parse_argo(res))
Expand All @@ -60,7 +52,7 @@ argo_buoy_files <- function(dac, id, ...) {
url <- paste0(argo_ftp(), sprintf('dac/%s/%s/profiles/', dac, id))
download.file(url, destfile = tfile, quiet = TRUE)
res <- readLines(tfile, warn = FALSE)
tab <- read.table(text = res, stringsAsFactors = FALSE,
tab <- read.table(text = res, stringsAsFactors = FALSE,
allowEscapes = TRUE, fill = TRUE)
tab[, NCOL(tab)]
}
Expand All @@ -82,7 +74,7 @@ argo <- function(dac, id, cycle, dtype, ...) {
dir.create(path, showWarnings = FALSE, recursive = TRUE)
url <- a_remote(dac, id, cycle, dtype)
f <- tryCatch(
suppressWarnings(argo_GET_disk(url, apath, ...)),
suppressWarnings(argo_GET_disk(url, apath, ...)),
error = function(e) e
)
if (inherits(f, "error")) {
Expand All @@ -109,7 +101,7 @@ argo_GET_disk <- function(url, file, ...) {

parse_argo <- function(x) x$parse("UTF-8")

argo_base <- "http://www.umr-lops.fr"
argo_base <- "https://www.umr-lops.fr"
argo_api <- "naarc/api/v1/"
argo_ftp <- function() "ftp://ftp.ifremer.fr/ifremer/argo/"

Expand Down
64 changes: 32 additions & 32 deletions man-roxygen/argo_egs.R
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
#' @examples \dontrun{
#' # Search Argo metadata
#' ## Number of profiles
#' # argo_search("np", limit = 3)
#' argo_search("np", limit = 3)
#' ## Number of floats
#' # argo_search("nf", limit = 3)
#' argo_search("nf", limit = 3)
#' ## Number of both profiles and floats
#' # argo_search("n", limit = 3)
#' argo_search("n", limit = 3)
#' ## return the coordinates in time and space of profiles
#' # argo_search("coord", limit = 3)
#' argo_search("coord", limit = 3)
#' ## return the coordinates in time and space of profiles, plus other metadata
#' # argo_search("fullcoord", limit = 3)
#' argo_search("fullcoord", limit = 3)
#'
#' ## List various things, e.g,...
#' ### data assembly centers
#' # argo_search("list", "dac")
#' argo_search("list", "dac")
#' ### data modes
#' # argo_search("list", "dmode", limit = 5)
#' argo_search("list", "dmode", limit = 5)
#' ### World Meteorological Organization unique float ID's
#' # argo_search("list", "wmo", limit = 5)
#' argo_search("list", "wmo", limit = 5)
#' ### Profile years
#' # argo_search("list", "year", limit = 5)
#' argo_search("list", "year", limit = 5)
#'
#' ## coord or fullcoord with specific buoy id
#' # argo_search("coord", wmo = 13857, limit = 3)
#' # argo_search("fullcoord", wmo = 13857, limit = 3)
#' argo_search("coord", wmo = 13857, limit = 3)
#' argo_search("fullcoord", wmo = 13857, limit = 3)
#'
#' # Spatial search
#' ### search by bounding box (see param def above)
#' # argo_search("coord", box = c(-40, 35, 3, 2))
#' argo_search("coord", box = c(-40, 35, 3, 2))
#' ### search by area
#' # argo_search("coord", area = 0)
#' argo_search("coord", area = 0)
#' ### search by around
#' # argo_search("coord", around = '-40,35,100')
#' argo_search("coord", around = '-40,35,100')
#'
#' # Time based search
#' ### search by year
#' # argo_search("coord", year = 2006)
#' argo_search("coord", year = 2006)
#' ### search by yearmin and yearmax
#' # argo_search("coord", yearmin = 2007)
#' # argo_search("coord", yearmin = 2007, yearmax = 2009)
#' argo_search("coord", yearmin = 2007)
#' argo_search("coord", yearmin = 2007, yearmax = 2009)
#' ### search by month
#' # argo_search("coord", month = '12,1,2')
#' argo_search("coord", month = '12,1,2')
#' ### search by from or to
#' # argo_search("coord", from = 20090212)
#' # argo_search("coord", to = 20051129)
#' argo_search("coord", from = 20090212)
#' argo_search("coord", to = 20051129)
#'
#' # Data mode search
#' # argo_search("coord", dmode = "R")
#' # argo_search("coord", dmode = "R,A")
#' argo_search("coord", dmode = "R")
#' argo_search("coord", dmode = "R,A")
#'
#' # Data quality based search
#' # argo_search("coord", pres_qc = "A,B")
#' # argo_search("coord", temp_qc = "A")
#' # argo_search("coord", pres_qc = "A", temp_qc = "A")
#' argo_search("coord", pres_qc = "A,B")
#' argo_search("coord", temp_qc = "A")
#' argo_search("coord", pres_qc = "A", temp_qc = "A")
#'
#' # Ticket search
#' # argo_search("coord", ticket = 0)
#' argo_search("coord", ticket = 0)
#'
#' ## Search on partial float id number
#' # argo_qwmo(qwmo = 49)
#' # argo_qwmo(qwmo = 49, limit = 2)
#' argo_qwmo(qwmo = 49)
#' argo_qwmo(qwmo = 49, limit = 2)
#'
#' ## Get files
#' # argo_files(wmo = 13857)
#' # argo_files(wmo = 13857, cyc = 12)
#' # argo_files(wmo = 13857, cyc = 45)
#' argo_files(wmo = 13857)
#' argo_files(wmo = 13857, cyc = 12)
#' argo_files(wmo = 13857, cyc = 45)
#'
#' ## Get planned buoys data, accepts no parameters
#' # argo_plan()
#' argo_plan()
#'
#' # Get files for a buoy, must specify data assembly center (dac)
#' argo_buoy_files(dac = "bodc", id = 1901309)
Expand Down
13 changes: 3 additions & 10 deletions man-roxygen/argo_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@
#' on your machine.
#'
#' @section API Status:
#' The API is down as of 2019-11-07, and probably some time before that. The
#' following functions won't work anymore (future package versions may bring
#' them back if the API comes back):
#' The API weas down as of 2019-11-07, and probably some time before that. The
#' following functions were defunct:
#'
#' \itemize{
#' \item argo_search
Expand All @@ -115,11 +114,5 @@
#' \item argo_plan
#' }
#'
#' The following functions still work as they are based off the FTP server
#' that still exists:
#'
#' \itemize{
#' \item argo_buoy_files
#' \item argo
#' }
#' These functions are working again as of 2020-06-12.

81 changes: 36 additions & 45 deletions man/argo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 251cb32

Please sign in to comment.