bluegreen-labs / ecmwfr

Interface to the public ECMWF API Web Services
https://bluegreen-labs.github.io/ecmwfr/
Other
106 stars 30 forks source link

`wf_request_batch()` fails. #137

Closed eliocamp closed 3 months ago

eliocamp commented 3 months ago

I get this error message. Seems to be related to keyring management.

library(ecmwfr)

requests <- lapply(01:03, \(m) {
  list(
    dataset_short_name = "reanalysis-era5-land",
    variable = "2m_temperature",
    year = "1950",
    month = m,
    day = c("02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"),
    time = "00:00",
    data_format = "netcdf",
    download_format = "unarchived",
    area = c(0, 0, -90, 360),
    target = paste0("TMPFILE", m, ".nc")
  )
})

files <- wf_request_batch(requests, path = "~/Downloads/")
#> Error in b_ss_list(self, private, service, keyring): Did not find collection: 'ecmwfr'

Created on 2024-08-25 with reprex v2.1.1

khufkens commented 3 months ago

Typo, default user should be ecmwfr the package name (missing r).

https://github.com/bluegreen-labs/ecmwfr/blob/96681bd620b5e456c300cec320fd6eb5257bbb4e/R/wf_request_batch.R#L15

khufkens commented 3 months ago

Fixed in #138

khufkens commented 3 months ago

Given the current setup I realized you can now easily mix and match requests. I don't think you could previously as the username would be different.

# CDS
cds_request <-
  list(
      product_type = 'reanalysis',
      variable = 'geopotential',
      year = '2024',
      month = '03',
      day = '01',
      time = '13:00',
      pressure_level = '1000',
      data_format = 'grib',
      dataset_short_name = 'reanalysis-era5-pressure-levels',
      target = 'test.grib'
)

# ADS
ads_request <- list(
  dataset_short_name = "cams-global-radiative-forcings",
  variable = "radiative_forcing_of_carbon_dioxide",
  forcing_type = "instantaneous",
  band = "long_wave",
  sky_type = "all_sky",
  level = "surface",
  version = "2",
  year = "2018",
  month = "06",
  target = "download.grib"
)

combined_request <- list(
  cds_request,
  ads_request
)

files <- wf_request_batch(combined_requests, path = "~/Downloads/")