read_forecast() can be used to read forecasts from any file format.
read_forecast() are generated from templates. Dynamic parts of the file name are in { }read_forecast() are generated from templates. Dynamic parts of the file name are in { }file_path <- "/my/path"
fcst_model <- "MEPS"
start_date <- 2021031900
end_date <- 2021031912
by <- "6h"
lead_time <- seq(0, 3, 3)
members <- c(0, 2)
template <- "{fcst_model}/{YYYY}/{MM}/{DD}/{fcst_model}_fc{YYYY}{MM}{DD}T{HH}Z_mbr{MBR3}+{LDT3}"## /my/path/MEPS/2021/03/19/MEPS_fc20210319T00Z_mbr000+000
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T00Z_mbr002+000
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T00Z_mbr000+003
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T00Z_mbr002+003
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T06Z_mbr000+000
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T06Z_mbr002+000
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T06Z_mbr000+003
## /my/path/MEPS/2021/03/19/MEPS_fc20210319T06Z_mbr002+003
## # A tibble: 33 x 2
## template_name template
## <chr> <chr>
## 1 arome_arctic_extrac… /lustre/storeB/immutable/archive/projects/metproduction…
## 2 arome_arctic_full /lustre/storeB/immutable/archive/projects/metproduction…
## 3 arome_arctic_sfx /lustre/storeB/immutable/archive/projects/metproduction…
## 4 fctable {file_path}/{fcst_model}/{YYYY}/{MM}/FCTABLE_{parameter…
## 5 fctable_det {file_path}/{det_model}/{YYYY}/{MM}/FCTABLE_{parameter}…
## 6 fctable_eps {file_path}/{eps_model}/{YYYY}/{MM}/FCTABLE_{parameter}…
## 7 fctable_eps_all_cyc… {file_path}/{eps_model}/{YYYY}/{MM}/FCTABLE_{parameter}…
## 8 fctable_eps_all_lea… {file_path}/{eps_model}/{YYYY}/{MM}/FCTABLE_{parameter}…
## 9 glameps_grib {file_path}/{eps_model}/{sub_model}/{YYYY}/{MM}/{DD}/{H…
## 10 harmoneps_grib {file_path}/{YYYY}/{MM}/{DD}/{HH}/mbr{MBR3}/fc{YYYY}{MM…
## 11 harmoneps_grib_fp {file_path}/{YYYY}/{MM}/{DD}/{HH}/mbr{MBR3}/fc{YYYY}{MM…
## 12 harmoneps_grib_sfx {file_path}/{YYYY}/{MM}/{DD}/{HH}/mbr{MBR3}/fc{YYYY}{MM…
## 13 harmonie_grib {file_path}/{YYYY}/{MM}/{DD}/{HH}/fc{YYYY}{MM}{DD}{HH}+…
## 14 harmonie_grib_fp {file_path}/{YYYY}/{MM}/{DD}/{HH}/fc{YYYY}{MM}{DD}{HH}+…
## 15 harmonie_grib_sfx {file_path}/{YYYY}/{MM}/{DD}/{HH}/fc{YYYY}{MM}{DD}{HH}+…
## 16 meps_cntrl_extracted /lustre/storeB/immutable/archive/projects/metproduction…
## 17 meps_cntrl_sfx /lustre/storeB/immutable/archive/projects/metproduction…
## 18 meps_det /lustre/storeB/immutable/archive/projects/metproduction…
## 19 meps_extracted /lustre/storeB/immutable/archive/projects/metproduction…
## 20 meps_full /lustre/storeB/immutable/archive/projects/metproduction…
## 21 meps_lagged_6h_subs… /lustre/storeB/immutable/archive/projects/metproduction…
## 22 meps_sfx /lustre/storeB/immutable/archive/projects/metproduction…
## 23 meps_subset /lustre/storeB/immutable/archive/projects/metproduction…
## 24 obstable {file_path}/OBSTABLE_{YYYY}.sqlite
## 25 vfld {file_path}/{fcst_model}/vfld{fcst_model}{YYYY}{MM}{DD}…
## 26 vfld_det {file_path}/{det_model}/vfld{det_model}{YYYY}{MM}{DD}{H…
## 27 vfld_det_noexp {file_path}/{det_model}/vfld{YYYY}{MM}{DD}{HH}{LDT2}
## 28 vfld_eps {file_path}/{sub_model}/vfld{sub_model}mbr{MBR3}{YYYY}{…
## 29 vfld_eps_noexp {file_path}/{sub_model}/vfldmbr{MBR3}{YYYY}{MM}{DD}{HH}…
## 30 vfld_multimodel {file_path}/{sub_model}/vfld{sub_model}mbr{MBR3}{YYYY}{…
## 31 vfld_multimodel_noe… {file_path}/{sub_model}/vfldmbr{MBR3}{YYYY}{MM}{DD}{HH}…
## 32 vfld_noexp {file_path}/{fcst_model}/vfldmbr{MBR3}{YYYY}{MM}{DD}{HH…
## 33 vobs {file_path}/vobs{YYYY}{MM}{DD}{HH}
show_file_templates().harp_fcst objectread_forecast() is a harp_fcst object - named list of data frames - one for each fcst_modelharp_fcst object## ● MEPS
## # A tibble: 6 x 11
## fcdate lead_time parameter validdate level_type level
## <dttm> <dbl> <chr> <dttm> <chr> <dbl>
## 1 2021-03-12 00:00:00 12 Pcp 2021-03-12 12:00:00 unknown 0
## 2 2021-03-12 00:00:00 24 Pcp 2021-03-13 00:00:00 unknown 0
## 3 2021-03-12 06:00:00 12 Pcp 2021-03-12 18:00:00 unknown 0
## 4 2021-03-12 06:00:00 24 Pcp 2021-03-13 06:00:00 unknown 0
## 5 2021-03-12 12:00:00 12 Pcp 2021-03-13 00:00:00 unknown 0
## 6 2021-03-12 12:00:00 24 Pcp 2021-03-13 12:00:00 unknown 0
## # … with 5 more variables: units <chr>, fcst_cycle <chr>,
## # MEPS_mbr000 <geolist>, MEPS_mbr010 <geolist>, MEPS_mbr020 <geolist>
dplyr verbs on harp_fcst objectsfcst %>%
select(fcdate, lead_time, starts_with("MEPS"))
## ● MEPS
## # A tibble: 6 x 5
## fcdate lead_time MEPS_mbr000 MEPS_mbr010 MEPS_mbr020
## <dttm> <dbl> <geolist> <geolist> <geolist>
## 1 2021-03-12 00:00:00 12 <geofield [949 … <geofield [949… <geofield [949…
## 2 2021-03-12 00:00:00 24 <geofield [949 … <geofield [949… <geofield [949…
## 3 2021-03-12 06:00:00 12 <geofield [949 … <geofield [949… <geofield [949…
## 4 2021-03-12 06:00:00 24 <geofield [949 … <geofield [949… <geofield [949…
## 5 2021-03-12 12:00:00 12 <geofield [949 … <geofield [949… <geofield [949…
## 6 2021-03-12 12:00:00 24 <geofield [949 … <geofield [949… <geofield [949…fcst %>%
select(fcdate, lead_time, MEPS_mbr000) %>%
filter(lead_time == 12)
## ● MEPS
## # A tibble: 3 x 3
## fcdate lead_time MEPS_mbr000
## <dttm> <dbl> <geolist>
## 1 2021-03-12 00:00:00 12 <geofield [949 × 1,069]>
## 2 2021-03-12 06:00:00 12 <geofield [949 × 1,069]>
## 3 2021-03-12 12:00:00 12 <geofield [949 × 1,069]>plot_field(
fcst, fcst_model = "MEPS", plot_col = MEPS_mbr000,
fcdate = 2021031200, lead_time = 12
)plot_field(
fcst, fcst_model = "MEPS", plot_col = MEPS_mbr000,
fcdate = 2021031200, lead_time = 12,
palette = c("transparent", viridis::viridis(255)),
breaks = c(0, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64)
)read_forecast() can transform the data by interpolating to points, to a new grid (and / or projection), or to a vertical cross section (soonish!)fcst <- read_forecast(
2021031200,
2021031212,
c("MEPS", "AROME_ARCTIC"),
"T2m",
lead_time = seq(0, 12, 3),
file_template = list(
MEPS = "meps_det",
AROME_ARCTIC = "arome_arctic_extracted"
),
file_format_opts = netcdf_opts("met_norway_det"),
transformation = "interpolate",
show_progress = TRUE,
return_data = TRUE
)fcst %>%
select(fcdate, lead_time, SID, ends_with("_det"))
## ● AROME_ARCTIC
## # A tibble: 3,630 x 4
## fcdate lead_time SID AROME_ARCTIC_det
## <dttm> <dbl> <int> <dbl>
## 1 2021-03-12 00:00:00 0 1001 269.
## 2 2021-03-12 00:00:00 0 1010 273.
## 3 2021-03-12 00:00:00 0 1014 271.
## 4 2021-03-12 00:00:00 0 1015 272.
## 5 2021-03-12 00:00:00 0 1018 268.
## 6 2021-03-12 00:00:00 0 1023 267.
## 7 2021-03-12 00:00:00 0 1025 271.
## 8 2021-03-12 00:00:00 0 1026 270.
## 9 2021-03-12 00:00:00 0 1027 271.
## 10 2021-03-12 00:00:00 0 1028 266.
## # … with 3,620 more rows
##
## ● MEPS
## # A tibble: 20,895 x 4
## fcdate lead_time SID MEPS_det
## <dttm> <dbl> <int> <dbl>
## 1 2021-03-12 00:00:00 0 1001 271.
## 2 2021-03-12 00:00:00 0 1010 273.
## 3 2021-03-12 00:00:00 0 1014 271.
## 4 2021-03-12 00:00:00 0 1015 272.
## 5 2021-03-12 00:00:00 0 1018 269.
## 6 2021-03-12 00:00:00 0 1023 267.
## 7 2021-03-12 00:00:00 0 1025 270.
## 8 2021-03-12 00:00:00 0 1026 270.
## 9 2021-03-12 00:00:00 0 1027 270.
## 10 2021-03-12 00:00:00 0 1028 266.
## # … with 20,885 more rowsoutput_file_opts = sqlite_opts(path = <path>)read_forecast(
2021031200,
2021031212,
c("MEPS", "AROME_ARCTIC"),
"T2m",
lead_time = seq(0, 12, 3),
file_template = list(
MEPS = "meps_det",
AROME_ARCTIC = "arome_arctic_extracted"
),
file_format_opts = netcdf_opts("met_norway_det"),
transformation = "interpolate",
output_file_opts = sqlite_opts(path = "/path/to/output"),
show_progress = TRUE
)read_point_forecast() is used to read interpolated datafcst %>%
select(fcdate, leadtime, SID, ends_with("det"))
## ● MEPS
## # A tibble: 20,895 x 4
## fcdate leadtime SID MEPS_det
## <dttm> <int> <int> <dbl>
## 1 2021-03-12 00:00:00 0 1001 271.
## 2 2021-03-12 00:00:00 0 1010 273.
## 3 2021-03-12 00:00:00 0 1014 271.
## 4 2021-03-12 00:00:00 0 1015 272.
## 5 2021-03-12 00:00:00 0 1018 269.
## 6 2021-03-12 00:00:00 0 1023 267.
## 7 2021-03-12 00:00:00 0 1025 270.
## 8 2021-03-12 00:00:00 0 1026 270.
## 9 2021-03-12 00:00:00 0 1027 270.
## 10 2021-03-12 00:00:00 0 1028 266.
## # … with 20,885 more rows
##
## ● AROME_ARCTIC
## # A tibble: 3,630 x 4
## fcdate leadtime SID AROME_ARCTIC_det
## <dttm> <int> <int> <dbl>
## 1 2021-03-12 00:00:00 0 1001 269.
## 2 2021-03-12 00:00:00 0 1010 273.
## 3 2021-03-12 00:00:00 0 1014 271.
## 4 2021-03-12 00:00:00 0 1015 272.
## 5 2021-03-12 00:00:00 0 1018 268.
## 6 2021-03-12 00:00:00 0 1023 267.
## 7 2021-03-12 00:00:00 0 1025 271.
## 8 2021-03-12 00:00:00 0 1026 270.
## 9 2021-03-12 00:00:00 0 1027 271.
## 10 2021-03-12 00:00:00 0 1028 266.
## # … with 3,620 more rowsvobs data
/scratch/ms/dk/nhz/oprint/OBS4frost coming soon(ish) [based on miIO]vobs to SQLite with read_obs_convert()SQLite with read_point_obs()read_point_forecast()read_point_forecast()read_point_obs()read_point_forecast()read_point_obs()join_to_forecast()read_point_forecast()read_point_obs()join_to_forecast()det_verify() / ens_verify()read_point_forecast()read_point_obs()join_to_forecast()det_verify() / ens_verify()plot_point_verif()read_point_forecast()read_point_obs()join_to_forecast()det_verify() / ens_verify()plot_point_verif()save_point_verif()shiny_plot_point_verif()This presentation
https://andrew-met.github.io/harp_presentations/suv_verif_202103.html