harphub / harpIO

IO functions for HARP
https://harphub.github.io/harpIO/
Other
6 stars 16 forks source link

Problem with read_forecast() when leadtimes are in minutes #92

Closed mpartio closed 2 years ago

mpartio commented 2 years ago

read_forecast() documentations states:

#' @param lead_time The lead times to read in. If a numeric vector is passed,
#'   the lead times are assumed to be in hours. Otherwise a character vector may
#'   be passed with a letter after each value to denote the time units: d =
#'   days, h = hours, m = minutes, s = seconds.

I'm trying to extract data from gribs from a model that has leadtime in minutes (15 min increments), but I get an error:

Error in leads_list[["time"]] + lags_in_lead_units : 
  non-numeric argument to binary operator
Calls: read_forecast -> <Anonymous> -> map -> .f -> do.call -> <Anonymous>

Is there something wrong in my call syntax?

Example:

$ cat test.R 
library(harpIO)

sessionInfo()

read_forecast(
    start_date      = "202201010000",
    end_date        = "202201020000",
    fcst_model      = "<model>",
    parameter       = "T2m",
    lead_time       = paste0(c(0,15,30,45),"m")
)

$ Rscript test.R 
R version 4.1.2 (2021-11-01)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Rocky Linux 8.5 (Green Obsidian)

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblas-r0.3.12.so

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

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

other attached packages:
[1] harpIO_0.0.0.9186

loaded via a namespace (and not attached):
[1] compiler_4.1.2 magrittr_2.0.2 cli_3.2.0      tools_4.1.2    rlang_1.0.1   
[6] renv_0.15.2   

Error in leads_list[["time"]] + lags_in_lead_units : 
  non-numeric argument to binary operator
Calls: read_forecast -> <Anonymous> -> map -> .f -> do.call -> <Anonymous>
In addition: Warning message:
In system("timedatectl", intern = TRUE) :
  running command 'timedatectl' had status 1
Execution halted
andrew-MET commented 2 years ago

We don't support sub hourly lead times yet for anything other than NetCDF. It's coming though: see #82

mpartio commented 2 years ago

Thanks Andrew. I'll wait for the support to be extended to grib; in the meanwhile I'll work with the data in hourly leadtimes.