read_members: Read ensemble members from a forecast file

Description Usage Arguments Value Examples

View source: R/read_members.R

Description

read_members reads all esemble members from a forecast file for a single lead time. It is possible to read from grib or netcdf files via the helper functions. It is assumed that grib files only contain one member and ntcdf files contain all members.

Usage

1
2
read_members(model_files, parameter, members = seq(0, 9),
  file_type = NULL, lead_time = NULL, progress_bar = TRUE, ...)

Arguments

model_files

Files to read. For NetCDF only 1 file is expected, but for grib a vector of files can be passed. The character string 'mbr' must be somewhere in the paths for the member numbes to be identified. It is assumed that grib files only contain one member. For grib2 (yet to be implemented) this might not be the case.

parameter

The parameter to read.

members

A vector of numbers identifying the members to read. This is ignored for grib files as it is assumed that the members were already decided when the filenames were obtained.

file_type

The forecast file format. The function can attempt to ascertain the format from the file name, but if it can't file_type must be passed as an argument.

lead_time

The lead time to read.

...

Arguments to be passed to read_netcf or read_grib

Value

A list containing:
model_data: The 3d field (the 3rd dimension is ensemble member).
x: The x coordinates in the projection of the forecast file.
y: The y coordinates in the projection of the forecast file.
proj4_string: The proj4 projection string for the forecast file.
parameter: The parameter that the 3d field represents.
filename: The full path to the forecast files.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
fname <- get_data_filename(20170801, 0)
model_field <- read_members(fname, "precipitation_amount_acc", lead_time = 24)
model_field <- read_members(fname, "Pcp", members = c(2, 4, 6), lead_time = 24)

my_static_path <- "/lustre/storeB/users/andrewts/surfacePerturbations/grib"
my_expt <- "MEPS_summer2017_sfcPertRef"
my_template <- file.path(
  "${YYYY}${MM}${DD}${HH}",
  "${experiment_name}",
  "mbr${MBR3}/fc${YYYY}${MM}${DD}${HH}+${LDT3}.grib"
)
fname <- get_data_filename(
  20170527, 0, data_source = "expt",
  static_path = my_static_path,
  experiment_name = my_expt,
  template = my_template,
  lead_time = 3, members = seq(0, 10)
)
model_field <- read_members(fname, "fog")

andrew-MET/mepsr documentation built on Nov. 9, 2019, 6:30 a.m.