harpIO includes a number of functions for creating lists of options for, for
example, file formats and transformations. modify_opts
allows you to
change the values for given options in an already generated options list.
Arguments
- opts
The options list to be modified.
- ...
Expressions that give new values for options in
opts
.- add_options
If
add_options = TRUE
, options that are not already found inopts
will be added toopts
. The default is FALSE and will give a warning for each option not found inopts
Details
modify_opts
is designed to be used in a pipeline so that an options
list can easily be modified. It is particularly useful for modifying options
set via, for example, an options set in netcdf_opts
.
Examples
# Default value for z_var is "height1" with
# options_set = "met_norway_eps"
netcdf_opts(options_set = "met_norway_eps")
#> $options_set
#> [1] "met_norway_eps"
#>
#> $param_find
#> list()
#>
#> $proj4_var
#> [1] "projection_lambert"
#>
#> $proj4_att
#> [1] "proj4"
#>
#> $proj4
#> NULL
#>
#> $x_dim
#> [1] "x"
#>
#> $y_dim
#> [1] "y"
#>
#> $lon_var
#> [1] "longitude"
#>
#> $lat_var
#> [1] "latitude"
#>
#> $x_rev
#> [1] FALSE
#>
#> $y_rev
#> [1] FALSE
#>
#> $dx
#> NULL
#>
#> $dy
#> NULL
#>
#> $z_var
#> [1] "height1"
#>
#> $member_var
#> [1] "ensemble_member"
#>
#> $time_var
#> [1] "time"
#>
#> $ref_time_var
#> [1] "forecast_reference_time"
#>
#> $force_param_name
#> [1] FALSE
#>
# Change z_var to "height0", keeping all other
# options from options_set = "met_norway_eps"
netcdf_opts(options_set = "met_norway_eps") %>%
modify_opts(z_var = "height2")
#> $options_set
#> [1] "met_norway_eps"
#>
#> $param_find
#> list()
#>
#> $proj4_var
#> [1] "projection_lambert"
#>
#> $proj4_att
#> [1] "proj4"
#>
#> $proj4
#> NULL
#>
#> $x_dim
#> [1] "x"
#>
#> $y_dim
#> [1] "y"
#>
#> $lon_var
#> [1] "longitude"
#>
#> $lat_var
#> [1] "latitude"
#>
#> $x_rev
#> [1] FALSE
#>
#> $y_rev
#> [1] FALSE
#>
#> $dx
#> NULL
#>
#> $dy
#> NULL
#>
#> $z_var
#> [1] "height2"
#>
#> $member_var
#> [1] "ensemble_member"
#>
#> $time_var
#> [1] "time"
#>
#> $ref_time_var
#> [1] "forecast_reference_time"
#>
#> $force_param_name
#> [1] FALSE
#>