read_grid
is a generic function to read gridded data from a file. A
transformation can optionally be applied to those data.
Usage
read_grid(
file_name,
parameter,
is_forecast = TRUE,
dttm = NULL,
file_format = NULL,
file_format_opts = list(),
vertical_coordinate = c("pressure", "model", "height", NA),
lead_time = NULL,
members = NULL,
transformation = c("none", "interpolate", "regrid", "xsection", "subgrid"),
transformation_opts = list(),
param_defs = get("harp_params"),
show_progress = TRUE,
data_frame = FALSE,
readable_times = TRUE,
spread_members = FALSE,
...
)
read_grid_interpolate(file_name, parameter, file_format = NULL, ...)
Arguments
- file_name
A character string with the (full) file name.
- parameter
The parameter to be read.
- is_forecast
Logical. If TRUE (the default), data are filtered based on the forecast initialization time and the lead time. If FALSE, the data are filtered on the valid time.
- dttm
A vector of date time strings of the form YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, or YYYYMMDDhhmmss. For forecast data these would be the forecast initialization times.
seq_dttm
can be used to generate a vector of equally spaced date-time strings.- file_format
The file format. Possible values include grib, netcdf, FA, hdf5... Whatever the value is, it is supposed to correspond to a function "read_XXX" that can deal with the format. If not specified, the format can often be guessed correctly from file extension or the first few bytes.
- file_format_opts
Options for the file format as generated by one of the options functions, e.g.
netcdf_opts
.- vertical_coordinate
The vertical coordinate for upper air data. May be "pressure" for pressure levels, "model" for model levels or "height" for height levels.
- lead_time
The lead times to read from a forecast file. If set to NULL, all lead times will be read from the file.
- members
For ensemble data, the ensemble members to read from the file. If set to NULL all members will be read.
- transformation
The transformation to apply to the gridded data. Can be "none", "interpolate", "regrid" or "xsection".
- transformation_opts
Options for the transformation as generated by
interpolate_opts
,regrid_opts
orxsection_opts
.- param_defs
A list of parameter definitions that includes the file format to be read. By default the built in list
harp_params
is used. Modifications and additions to this list can be made usingmodify_param_def
andadd_param_def
respectively.- show_progress
Show progress when reading large amounts of data.
- data_frame
Logical. For compatibility with current version of harpSpatial, make sure only a geofield is returned rather than a data frame when set to FALSE.
- readable_times
When
data_frame = TRUE
, whether to convert times in unix format to a data-time format. The default is TRUE.- spread_members
When
data_frame = TRUE
, whether to spread the members into a column for each member.- ...
All arguments passed to the specified reader function.
Examples
if (requireNamespace("Rgrib2", quietly = TRUE) & requireNamespace("harpData", quietly = TRUE)) {
read_grid(
system.file(
"grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp",
package = "harpData"
),
parameter = "T2m"
)
read_grid(
system.file(
"grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp",
package = "harpData"
),
parameter = "S10m"
)
read_grid(
system.file(
"grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp",
package = "harpData"
),
parameter = "tcc"
)
}
#> Reading /home/andrewts/R/x86_64-pc-linux-gnu-library/4.3/harpData/grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp
#> Reading /home/andrewts/R/x86_64-pc-linux-gnu-library/4.3/harpData/grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp
#> Reading /home/andrewts/R/x86_64-pc-linux-gnu-library/4.3/harpData/grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp
#> eidb : TCC Total cloud cover
#> Time:
#> 2018/07/10 00:00 +0
#> Domain summary:
#> 100 x 100 domain
#> Projection summary:
#> proj= lcc
#> NE = ( 23.31109 , 78.2607 )
#> SW = ( 8.042 , 77.968 )
#> Data summary:
#> 0.01281738 1 1 0.9805575 1 1