Hello everyone! I’m trying to download the variable “instantaneous 10m wind gust” from the latest version of cds using R (not python). The database is ERA5 hourly data on single levels from 1940 to present. Any idea for doing this?
Thanks!
Hello everyone! I’m trying to download the variable “instantaneous 10m wind gust” from the latest version of cds using R (not python). The database is ERA5 hourly data on single levels from 1940 to present. Any idea for doing this?
Thanks!
Just use the ecmwfr
package. Examples are provided in the documentation below.
# load the library
library(ecmwfr)
# formulate a request (first online, and then
# translated using the RStudio IDE addin)
request <- list(
dataset_short_name = "reanalysis-era5-single-levels",
product_type = "reanalysis",
variable = "instantaneous_10m_wind_gust",
year = c("1940", "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002",
"2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024"),
month = c("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"),
day = c("01", "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 = c("00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"),
data_format = "netcdf_legacy",
download_format = "unarchived",
area = c(60, -20, 33, 20),
target = "test.nc"
)
# initiate a download
file <- wf_request(
request,
path = "/your/data/path" ,
transfer = TRUE
)
# Read in data using the `terra`
# geospatial library
library(terra)
r <- rast(file)
Hi,
thank you for putting this package together, It’s really helpful!
I’m trying to get daily statistics from the post-processed daily statistics (ERA5 post-processed daily statistics on single levels from 1940 to present) but the package doesn’t seem to support it, or maybe I’m using it wrong?
I would appreciate any indication on how to get the daily means, minima and maxima with this package.
Thank you!
Normally this should work. Can you show me the code? Without a worked example it is hard to tell if this is a bug.
The general routine is to:
addin
in RSTudiowf_request()
The full description can be found here:
Hi, thank you for the prompt reply.
I guess there was something wrong with my syntax yesterday, it worked today!
Thank you.
Experience teaches that manually creating the requests is very tricky and not recommended. Best to use the Addin to translate from the python query on the CDS site.
Alternatively you can use modifiers (archetypes) for advanced use cases where certain parameters need to be changed consistently. This is all described in the advanced use case vignette:
https://bluegreen-labs.github.io/ecmwfr/articles/advanced_vignette.html
Thank you so much for your answer Koen!
Unfortunatelly the problem is not solved, I tried with the code proposed but it gives me an error message: Error in wf_request(request, path = “C:/Users/lstoll/Documents”, transfer = TRUE) :
Missing user credentials, please provide a valid user/ID! I think perhaps there is some issues with the .cdsapirc. Currently I have this format:
url: https://cds.climate.copernicus.eu/api/v2
key: 43629b3d-2553-4d6f-bd8f-248b3794a048 but I’m not sure that is the correct since the last updates. Thanks again!
Dear Luciana,
You need to set your key using wf_set_key(KEY)
, as described here:
The R package does not rely on the .cdsapirc file as it is prone to leak credentials.