Converts user inputs to list. Wind sector information is used to highlight specific wind sectors on the plots (e.g., tsplot, windrose).

windsector_convert(x)

Arguments

x

NULL, list, matrix, or data.frame. see 'Details' for more information.

Value

Returns a list object with the windsector information as used by the different functions and methods of the foehnix package.

Returns NULL (if input was NULL) or a named or unnamed with one or multiple entries. Each entry is a numeric vector of length two and specifies a wind sector.

Details

Some foehnix functions allow to specify custom wind sectors. This function is a convenience function which takes inputs in different formats (e.g., as matrix, data.frame, ...) and converts the information in the format the foehnix functions expect wind sector definitions.

Author

Reto Stauffer

Examples

# No wind sector (NULL) simply returns NULL
foehnix:::windsector_convert(NULL)
#> NULL

# Input can also be:
# - unnamed list
# - a matrix
# - a data.frame without row names
foehnix:::windsector_convert(matrix(c(10, 30, 90, 140), byrow = TRUE, ncol = 2))
#> [[1]]
#> [1] 10 30
#> 
#> [[2]]
#> [1]  90 140
#> 
foehnix:::windsector_convert(list(c(10, 30), c(90, 140)))
#> [[1]]
#> [1] 10 30
#> 
#> [[2]]
#> [1]  90 140
#> 
foehnix:::windsector_convert(data.frame(from = c(30, 90), to = c(30, 140)))
#> [[1]]
#> [1] 30 30
#> 
#> [[2]]
#> [1]  90 140
#> 

# Or named objects can be used
# - named list
# - matrix with rownames
# - data.frame with rownames
# If names are set these names will be used to label the
# highlighted wind sectors.
foehnix:::windsector_convert(matrix(c(10, 30, 90, 140), byrow = TRUE, ncol = 2,
                         dimnames = list(c("A", "B"), c("from", "to"))))
#> $A
#> [1] 10 30
#> 
#> $B
#> [1]  90 140
#> 
foehnix:::windsector_convert(list(A = c(10, 30), B = c(90, 140)))
#> $A
#> [1] 10 30
#> 
#> $B
#> [1]  90 140
#> 
foehnix:::windsector_convert(structure(data.frame(from = c(30, 90), to = c(30, 140)),
                                       row.names = c("foo", "bar")))
#> $foo
#> [1] 30 30
#> 
#> $bar
#> [1]  90 140
#>