harphub / harpIO

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

Precipitation grib file reading #65

Closed meteorolog90 closed 3 years ago

meteorolog90 commented 3 years ago
library(harp)
library(tidyverse)

station <- read.csv("/users/ext005//HARP/STANICE.csv")

forecast <- read_forecast(
start_date = 2021022000, 
end_date =   2021022000,
fcst_model="alaro_cy40_45km",
parameter="Pcp",
lead_time= seq(0,3,1),
by="12h",
file_path="/data/nwp/oper/grib/shmu",
file_template="{YYYY}-{MM}-{DD}_{HH}/SURFPREC_TOTAL_{LDT2}.grb",
transformation="interpolate",
transformation_opts=interpolate_opts(stations=station,
clim_file="/users/ext005/app/harp/etc/geo_aladin45km.grb"),
return_data=TRUE,
show_progress =TRUE
)

Reading /users/ext005/app/harp/etc/geo_aladin45km.grb Reading /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_00.grb Warning: Problem with mutate() input forecast_data. i Parameter "Pcp" (shortName: "tp") not found in grib file. i Input forecast_data is purrr::map2(.data[["file_name"]], .data[["data"]], safe_read_grid). i The error occurred in group 1: file_name = "/data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_00.grb". Reading /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_01.grb Warning: Problem with mutate() input forecast_data. i Parameter "Pcp" (shortName: "tp") not found in grib file. i Input forecast_data is purrr::map2(.data[["file_name"]], .data[["data"]], safe_read_grid). i The error occurred in group 2: file_name = "/data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_01.grb". Reading /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_02.grb Warning: Problem with mutate() input forecast_data. i Parameter "Pcp" (shortName: "tp") not found in grib file. i Input forecast_data is purrr::map2(.data[["file_name"]], .data[["data"]], safe_read_grid). i The error occurred in group 3: file_name = "/data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_02.grb". Reading /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_03.grb Warning: Problem with mutate() input forecast_data. i Parameter "Pcp" (shortName: "tp") not found in grib file. i Input forecast_data is purrr::map2(.data[["file_name"]], .data[["data"]], safe_read_grid). i The error occurred in group 4: file_name = "/data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_03.grb". Warning: No data found for 202102200000. Warning message: There were problems reading: /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_00.grb /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_01.grb /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_02.grb /data/nwp/oper/grib/shmu/2021-02-20_00/SURFPREC_TOTAL_03.grb

Replacing parameter name with : AccPcp, AccPcp1h, tc, accpcp, accpcp1h + combination with "as_harp_parameter()" not helping

Precipitation grib data: exmaple.zip

andrew-MET commented 3 years ago

Closing this as it is the same as #46

eccodes doesn't understand that the parameter ID in these grib files, 206, is total precipitation.

I will prioritize getting a solution to this as soon as I can.

andrew-MET commented 3 years ago

With some new features in harpIO, you should now be able to read these data. See #66.

For your case you would add the argument file_format_opts = grib_opts(...) as follows:

forecast <- read_forecast(
  start_date          = 2021022000, 
  end_date            = 2021022000,
  fcst_model          = "alaro_cy40_45km",
  parameter           = "Pcp",
  lead_time           = seq(0,3,1),
  by                  = "12h",
  file_path           = "/data/nwp/oper/grib/shmu",
  file_template       = "{YYYY}-{MM}-{DD}_{HH}/SURFPREC_TOTAL_{LDT2}.grb",
  file_format_opts    = grib_opts(param_find = list(Pcp = use_grib_indicatorOfParameter(206))),
  transformation      = "interpolate",
  transformation_opts = interpolate_opts(stations=station,
  clim_file           = "/users/ext005/app/harp/etc/geo_aladin45km.grb"),
  return_data         = TRUE,
  show_progress       = TRUE
)
meteorolog90 commented 3 years ago

I confirm, it works now. Thanks