Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor doc suggestion #153

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/wf_set_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ wf_set_key <- function(key, user = "ecmwfr") {
)
}
browseURL(wf_key_page(service))
message("Login or register to get a Personal Access Token")
key <- getPass::getPass(msg = "Personal Access Token: ")
message("Login or register to get a API Token")
key <- getPass::getPass(msg = "API Token: ")
if (is.null(key))
stop("No key supplied.")
}
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,20 @@ to the ECMWF using [the public forum](https://forum.ecmwf.int/t/changes-to-grib-
## Use: ECMWF Data Store services

Create a ECMWF account by [self
registering](https://accounts.ecmwf.int/auth/realms/ecmwf/protocol/openid-connect/auth?client_id=cms-www&response_type=code&scope=openid%20email%20profile&redirect_uri=https%3A//www.ecmwf.int/openid-connect/). Once your user account has been verified you can get your personal access token or *key* by visiting one of the Data Stores user profiles, for example the CDS [user profile](https://cds.climate.copernicus.eu/profile).
registering](https://www.ecmwf.int/user/login). Once your user account has been verified you can get your API token (or `key` in `ecmwfr`) by visiting one of the Data Stores user profiles, for example the CDS [user profile](https://cds.climate.copernicus.eu/profile).

The Personal Access Token is a long string of letters and numbers:
The API Token is a [UUID](https://fr.wikipedia.org/wiki/Universally_unique_identifier) and should look something like:

``` json
Personal Access Token: abcd1234-foo-bar-98765431-XXXXXXXXXX
```
This Personal Access Token gives you access to all Data Store services, including the climate atmosphere and emergency management services. This information is required to be able to retrieve data via the `ecmwfr` package. Use the
API: abcd1234-foo-bar-98765431-XXXXXXXXXX
```

This API Token gives you access to all Data Store services, including the climate atmosphere and emergency management services. This information is required to be able to retrieve data via the `ecmwfr` package. Use the
`ecmwfr` [`wf_set_key`](references/wf_set_key.html) function to store
your login information in the system keyring (see below).

In order to download the data, you will also need to accept the licence agreement on the bottom of the [user profile page](https://cds.climate.copernicus.eu/profile).

### Setup

You have to save your login information before proceeding. The
Expand Down
11 changes: 6 additions & 5 deletions vignettes/advanced_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This is a brief overview of some of the more advanced options in the `ecmwfr` pa

## Piped requests

Another hidden feature of `ecmwfr` is the fact that the request is the first argument in the `wf_request()` function. This means that any valid list can be piped into this function (using the %>% or pipe symbol).
Another hidden feature of `ecmwfr` is the fact that the request is the first argument in the `wf_request()` function. This means that any valid list can be piped into this function (using the magrittr `%>%` or native pipe symbol `|>`).

```{r eval = FALSE}
list(
Expand All @@ -52,7 +52,7 @@ list(

Once a valid request has been created it can be made into a dynamic function using `achetypes`. Archetype functions are build using a valid `ecmwfr` ECMWF or CDS request and the vector naming the field which are to be set as dynamic.

The `wf_archetype()` function creates a new function with as parameters the dynamic fields previously assigned. The below example show how to use the function to generate the custom `dynamic_request()` function. We then use this new function to alter the `area` and `day` fields and pipe (%>%) into the `wf_request()` function to retrieve the data.
The `wf_archetype()` function creates a new function with as parameters the dynamic fields previously assigned. The below example show how to use the function to generate the custom `dynamic_request()` function. We then use this new function to alter the `day` and `target` fields and pipe (`|>`) into the `wf_request()` function to retrieve the data.

```{r eval = FALSE}
# this is an example of a request
Expand All @@ -72,7 +72,8 @@ dynamic_request <- wf_archetype(
dynamic_fields = c("day", "target"))

# change the day of the month
dynamic_request(day = "01", target = "new.grib")
dynamic_request(day = "01", target = "new.grib") |>
wf_request()
```

## Batch (parallel) requests
Expand Down Expand Up @@ -147,9 +148,9 @@ files <- wf_request_batch(
For those familiar to ECMWF _mars_ syntax: CDS/ADS does not
accept `date = "2000-01-01/to/2000-12-31"` specifications at the moment. It is possible to specify one specific date via `date = "2000-01-01"` or multiple days via `date = ["2000-01-01","2000-01-02","2000-10-20"]` or `date = "YYYY-MM-DD/YYYY-MM-DD"` but not via `".../to/..."`.

## Environmental variables
## Environmental variables for API token

Alternatively, you can set an environmental variable containing your Personal Access Token.
Alternatively to using `wf_set_key()`, you can set an environmental variable containing your API.

```{r eval=FALSE}
Sys.setenv(ecmwfr_PAT="abcd1234-foo-bar-98765431-XXXXXXXXXX")
Expand Down
Loading