ropensci / camsRad

R Client for CAMS Radiation Service
https://docs.ropensci.org/camsRad
Other
9 stars 0 forks source link

Examples does not work #1

Closed matteodefelice closed 8 years ago

matteodefelice commented 8 years ago

Hi, I have created an account and I tried to execute the sample commands in the GitHub homepage of the package:

> df <- cams_get_radition(username, lat=60, lon=15, 
                        date_begin="2016-01-01", date_end="2016-01-15")
Error in cams_get_radition(username, lat = 60, lon = 15, date_begin = "2016-01-01",  : 
  unused argument (lon = 15)

it seems that the argument is now lng instead of lon. I tried the right argument:

> df <- cams_get_radition(username, lat=60, lng =15, 
                        date_begin="2016-01-01", date_end="2016-01-15")
Error in match.arg(encode) : 
  'arg' should be one of “multipart”, “form”, “json”

the problem comes from httr::POST in cams_api, in line 95 you set as argument encode the value raw but my httr doc says:

POST(url = NULL, config = list(), ..., body = NULL,
  encode = c("multipart", "form", "json"), multipart = TRUE,
  handle = NULL)

the encode raw option is instead present in httr version 1.2.1 but not in the 1.1.0 I have on my Microsoft R 3.3.0. So, you should add a dependency to this particular version of httr.

UPDATE: I have installed the latest httr from Hadley's repository on GitHub and now I get:

> filename <- paste0(tempfile(), ".nc")
> 
> r <- cams_api(username, 60, 15, "2016-06-01", "2016-06-10", 
+               format = "application/x-netcdf", filename = filename)
No encoding supplied: defaulting to UTF-8.
xmlXPathEval: evaluation failed
xmlXPathEval: evaluation failed
xmlXPathEval: evaluation failed
Warning messages:
1: In node_find_all(x$node, x$doc, xpath = xpath, nsMap = ns) :
  Undefined namespace prefix [1219]
2: In node_find_all(x$node, x$doc, xpath = xpath, nsMap = ns) :
  Undefined namespace prefix [1219]
3: In node_find_all(x$node, x$doc, xpath = xpath, nsMap = ns) :
  Undefined namespace prefix [1219]

and r$ok is FALSE.

lukas-rokka commented 8 years ago

Thank you for feedback, @matteodefelice.

  1. Documentation now updated. lon -> lng
  2. cams_api is POSTing a string with xml/text content, but seems like the "multipart" options work just as well as "raw". So should now work with older httr as well.
matteodefelice commented 8 years ago

thank you for the update, unfortunately I still get the last error...

lukas-rokka commented 8 years ago

What version of xml2 do you have?

matteodefelice commented 8 years ago

I had the 0.1.2, after updating to the latest dev release now your package works!

lukas-rokka commented 8 years ago

Ok, thanks. That could be it. CRAN version of xml2 is at 1.0.0.

I've now updated it with conservative dependency settings in the DESCRIPTION file. So if you reinstall it should updated those as well.

It works on Travis-CI (Linux) and on my computer with windows/rstudio with latest CRAN updates (also with httr as github dev version).

If you still get errors, could you please run it with verbose=TRUE in the call to cams_api/cams_get_radiation and paste the output here or email it to me.

FYI: the package is also under review to onboard to rOpenSci.

matteodefelice commented 8 years ago

Now it works smoothly, it is very useful.