ErikKusch / KrigR

An R Package for downloading, preprocessing, and statistical downscaling of the European Centre for Medium-range Weather Forecasts ReAnalysis 5 (ERA5) family provided by the European Centre for Medium‐Range Weather Forecasts (ECMWF).
MIT License
104 stars 24 forks source link

Error message: CDS Request & Data Download #87

Closed helenahespanhol closed 4 hours ago

helenahespanhol commented 4 hours ago

Hi,

I have been using KrigR to download ERA5-Land variables and I followed the updates on your page: https://www.erikkusch.com/courses/krigr/. Thanks for sharing this.

At the beginning of October I installed the KrigR development version and I managed to download temperature variables for different countries from Europe. However, now, after installing KrigR_0.9.2, a persistent error shows up while trying to download other variables. I tried using older krigR developments versions, but still can't download the requested variables.

Error message:

CDS Request & Data Download

[1] "Building request" [1] "Checking request validity" Error in names(Meta_vec) <- c("Variable", "CumulVar", "DataSet", "Type", : 'names' attribute [14] must be the same length as the vector [13] In addition: Warning message: In Meta.Check(DataSet = DataSet, Type = Type, VariableCheck = QueryVariable, : Cannot validate user-specified end date (DateStop) because specified data set is being updated regularly (Lag = 3 month). User-specification may lead to an error.

R code here:

Temp_dew_SW <- CDownloadS( Variable = "2m_dewpoint_temperature", DataSet = "reanalysis-era5-land", DateStart = "2023-06-01", DateStop = "2024-09-30", TResolution = "hour", TStep = 1, Extent = Extent_ext_SW, Dir = Dir.Data, FileName = "Temp_dew_SW", API_User = API_User, API_Key = API_Key, FUN = NULL )

Session information:

sessionInfo() R version 4.4.1 (2024-06-14 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: Europe/Lisbon tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] KrigR_0.9.2 terra_1.7-78

loaded via a namespace (and not attached): [1] tidyselect_1.2.1 viridisLite_0.4.2 dplyr_1.1.4 viridis_0.6.5 fastmap_1.2.0 reshape_0.8.9 promises_1.3.0 digest_0.6.36
[9] timechange_0.3.0 mime_0.12 lifecycle_1.0.4 sf_1.0-19 ellipsis_0.3.2 magrittr_2.0.3 compiler_4.4.1 rlang_1.1.4
[17] progress_1.2.3 tools_4.4.1 doSNOW_1.0.20 utf8_1.2.4 FNN_1.1.4.1 prettyunits_1.2.0 htmlwidgets_1.6.4 sp_2.1-4
[25] pkgbuild_1.4.4 classInt_0.4-10 plyr_1.8.9 pkgload_1.4.0 abind_1.4-8 KernSmooth_2.23-24 miniUI_0.1.1.1 purrr_1.0.2
[33] grid_4.4.1 fansi_1.0.6 urlchecker_1.0.1 profvis_0.3.8 xts_0.14.1 xtable_1.8-4 e1071_1.7-16 colorspace_2.1-1
[41] ggplot2_3.5.1 scales_1.3.0 iterators_1.0.14 cli_3.6.3 crayon_1.5.3 intervals_0.15.5 generics_0.1.3 remotes_2.5.0
[49] rstudioapi_0.17.1 httr_1.4.7 sessioninfo_1.2.2 ncdf4_1.23 DBI_1.2.3 pbapply_1.7-2 cachem_1.1.0 proxy_0.4-27
[57] ecmwfr_2.0.2 stringr_1.5.1 stars_0.6-7 parallel_4.4.1 vctrs_0.6.5 devtools_2.4.5 hms_1.1.3 foreach_1.5.2
[65] tidyr_1.3.1 units_0.8-5 snow_0.4-4 glue_1.8.0 codetools_0.2-20 cowplot_1.1.3 gstat_2.1-2 lubridate_1.9.3
[73] stringi_1.8.4 gtable_0.3.6 later_1.3.2 raster_3.6-26 munsell_0.5.1 tibble_3.2.1 pillar_1.9.0 htmltools_0.5.8.1 [81] R6_2.5.1 automap_1.1-12 shiny_1.9.0 lattice_0.22-6 memoise_2.0.1 httpuv_1.6.15 class_7.3-22 Rcpp_1.0.13-1
[89] gridExtra_2.3 spacetime_1.3-2 fs_1.6.4 zoo_1.8-12 usethis_2.2.3 pkgconfig_2.0.3

Perhaps you can find something to help me, Thanks!!

ErikKusch commented 4 hours ago

Hiya,

thanks for logging this issue and using KrigR!

The fix to your issue is quite simple, do not set FUN = NULL. Since you ask for the raw data at hourly resolution anyways, the FUN argument does not come into play - after all, there will be no temporal aggregation happening. You can thus safely leave the default of FUN = mean.

Why does this happen when you set FUN = NULL? Well, with the newer versions of KrigR, we store the download call made with CDownloadS directly as metadata in your final file on your hard drive. To do so, we need to create a named vector of the arguments you set. Unfortunately, naming a vector entry that is NULL leads to issues.

Hope that helps and you feel you can get back on board with your work.

Enjoy your weekend!