When reading gridded data, three transformations are available: interpolate, regrid and xsection. Each of these transformations requires their own set of options, and these functions are used to generate those options.
Usage
interpolate_opts(
stations,
method = c("nearest", "bilinear", "bicubic", "closest"),
correct_t2m = TRUE,
keep_model_t2m = FALSE,
lapse_rate = 0.0065,
clim_file = NULL,
clim_file_format = NULL,
clim_file_opts = NULL,
clim_param = "sfc_geo",
use_mask = FALSE,
weights = NULL,
keep_raw_data = FALSE
)
regrid_opts(
new_domain = NULL,
method = "nearest",
clim_file = NULL,
clim_file_format = NULL,
clim_file_opts = NULL,
clim_param = "sfc_geo",
weights = NULL,
keep_raw_data = FALSE
)
xsection_opts(
a,
b,
horizontal_res = 2500,
vertical_res = log(10),
clim_file = NULL,
clim_file_format = NULL,
clim_file_opts = NULL,
clim_param = "sfc_geo",
method = "bilinear",
levels_ascending = TRUE,
keep_raw_data = FALSE,
...
)
subgrid_opts(x1, x2, y1, y2, ...)
Arguments
- stations
A data frame of points to interpolate to. Must have the columns 'SID', for a station ID, lat for latitude and lon for longitude.
- method
The interpolation method. Can be 'nearest' or 'closest' for nearest neighbour interpolation, 'bilinear', or 'bicubic'. For
regrid_opts
'mean' is also available for upscaling.- correct_t2m
Logical. Whether to make a height correction to 2m temperature to account for differences between the model elevation and the station elevation.
- keep_model_t2m
Logical. Whether to keep the uncorrected 2m temperature if
correct_t2m = TRUE
.- lapse_rate
The lapse rate in K/m to use for the 2m temperature heigth correction. The default is the standard moist adiabitic lapse rate of 0.0065 K/m.
- clim_file
A file containing model orography or surface geopential on the same grid as the data to be read in so that height corrections to 2m temperature can be made. It will also contain a land sea mask if masked interpolation is to be done. For initialising the domain, any parameter, passed in 'clim_param' can be used.
- clim_file_format
The format of the clim_file. If set to NULL, a guess will be made.
- clim_file_opts
Options for reading the clim_file, depending on the format of the clim_file.
- clim_param
The parameter to read from 'clim_file'. If
correct_t2m = TRUE
then this should be either surface geopotential or terrain height in meters, otherwise for the purposes of intialising interpolation weights, any paramter that exists in 'clim_file' can be used.- use_mask
Logical. Whether to use a mask in the interpolation. Requires that 'stations' has an 'lsm' column and clim_file includes a land-sea mask.
- weights
Interpolation weights if they have already been calculated.
- keep_raw_data
Logical. Whether to keep the untransformed full gridded data field. The default is FALSE.
- new_domain
A geofield or geodomain object on the grid to which the data should be regridded.
- a
A length 2 numeric vector with the longitude and latitude of the left hand edge of the cross section.
- b
A length 2 numeric vector with the longitude and latitude of the right hand edge of the cross section.
- horizontal_res
The horizontal grid length of the cross section in meters. The default is 2500m.
- vertical_res
The vertical grid length of the cross section. For data on pressure levels or model levels this should be in hPa. For data on height levels this should be in meters. The default is log(10).
- levels_ascending
The order of the level values. In the output the levels are numbered for simple plotting. Set to
TRUE
(the default) for the levels to be numbered in ascending order of the level values andFALSE
for the numbering to be done in descending order.- x1
left x index of the subdomain
- x2
right x index of the subdomain
- y1
bottom y index of the subdomain
- y2
top y index of the subdomain
Details
interpolate_opts
generates options for interpolating gridded data to
points, or stations. If no stations are passed, a default list of stations,
accessed from the harpIO built in dataset stations_list is used. If 2m
temperature is to be read, the deafult behaviour is to attempt to height
correct for differences between the model elevation and the elevation at the
actual station. The default interpolation method is nearest-neighbour.
regrid_opts
generates options to regrid the data from its native grid
to a new grid. The new grid is specified either as a
geofield or geodomain object.
read_grid can be used to read a geofield, or
Make.domain can be used to make a geodomain. The default
interpolation method is nearest-neighbour.
xsection_opts
generates options to extract a vertical cross section
from three dimensional gridded data. a
and b
denote the left
and right hand extents of the vertical cross section. By defualt the cross
sections are interpolated horizontally to a 2.5 km grid length. In the
vertical, if data are on model levels or pressure levels, these are converted
to log(pressure) and by default interpolated to to log(10) hPa levels. The
default interpolation method is bilinear interpolation.
Examples
interpolate_opts()
#> No stations specified. Using default stations: 'station_list'
#> $stations
#> # A tibble: 13,417 × 5
#> SID lat lon elev name
#> <int> <dbl> <dbl> <dbl> <chr>
#> 1 1001 70.9 -8.67 9.4 JAN MAYEN
#> 2 1002 80.1 16.2 8 VERLEGENHUKEN
#> 3 1003 77 15.5 11.1 HORNSUND
#> 4 1004 78.9 11.9 8 NY-ALESUND II
#> 5 1006 78.3 22.8 14 EDGEOYA
#> 6 1007 78.9 11.9 7.7 NY-ALESUND
#> 7 1008 78.2 15.5 26.8 SVALBARD AP
#> 8 1009 80.7 25.0 5 KARL XII OYA
#> 9 1010 69.3 16.1 13.1 ANDOYA
#> 10 1011 80.1 31.5 10 KVITOYA
#> # ℹ 13,407 more rows
#>
#> $method
#> [1] "nearest"
#>
#> $correct_t2m
#> [1] TRUE
#>
#> $keep_model_t2m
#> [1] FALSE
#>
#> $lapse_rate
#> [1] 0.0065
#>
#> $clim_file
#> NULL
#>
#> $clim_file_format
#> NULL
#>
#> $clim_file_opts
#> NULL
#>
#> $clim_param
#> [1] "sfc_geo"
#>
#> $use_mask
#> [1] FALSE
#>
#> $weights
#> NULL
#>
#> $keep_raw_data
#> [1] FALSE
#>
if (requireNamespace("Rgrib2", quietly = TRUE) & requireNamespace("harpData", quietly = TRUE)) {
new_domain = read_grid(
system.file(
"grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp",
package = "harpData"
),
parameter = "T2m"
)
regrid_opts(new_domain = new_domain)
}
#> Reading /home/andrewts/R/x86_64-pc-linux-gnu-library/4.3/harpData/grib/AROME_Arctic/2018/07/10/00/fc2018071000+000grib_fp
#> $new_domain
#> eidb : T Temperature K
#> 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:
#> 270.9636 275.1887 276.3596 276.5172 278.2578 279.9568
#>
#> $method
#> [1] "nearest"
#>
#> $clim_file
#> NULL
#>
#> $clim_file_format
#> NULL
#>
#> $clim_file_opts
#> NULL
#>
#> $clim_param
#> [1] "sfc_geo"
#>
#> $weights
#> NULL
#>
#> $keep_raw_data
#> [1] FALSE
#>
xsection_opts(a = c(5.3, 60.5), b = c(10.8, 59.9))
#> $a
#> [1] 5.3 60.5
#>
#> $b
#> [1] 10.8 59.9
#>
#> $horizontal_res
#> [1] 2500
#>
#> $vertical_res
#> [1] 2.302585
#>
#> $clim_file
#> NULL
#>
#> $clim_file_format
#> NULL
#>
#> $clim_file_opts
#> NULL
#>
#> $clim_param
#> [1] "sfc_geo"
#>
#> $method
#> [1] "bilinear"
#>
#> $levels_ascending
#> [1] TRUE
#>
#> $keep_raw_data
#> [1] FALSE
#>