RAnEnExtra::subsetStations is a convevient function to subset stations from forecast and observation lists. Given an index vector, presumably from the ID.R column from RAnEnExtra::subsetCoordinates, this function can subset the desired stations from a forecast or observation list.

subsetStations(index, l, verbose = T)

Arguments

index

An index vector for stations to extract

l

A forecast or observation list. For how to create such a list, please see this tutorial. For what members to include in the list, see this doc.

verbose

Whether to print progress information.

Value

A forecast or observation list depending on your input list type with the subset stations.

Details

RAnEnExtra::subsetStations will select the stations based on the input index from the following members of the input list (if they exist):

  • StationNames

  • Xs

  • Ys

  • Data

Examples

# Subset a forecast list forecasts <- list( StationNames = paste0('Station', 1:10), Xs = 1:10, Ys = 10:1, Data = array(1:200, dim = c(2, 10, 5, 2)) ) index <- c(1, 5) forecasts.sub <- subsetStations(index, forecasts)
#> Subset the list member StationNames ... #> Subset the list member Xs ... #> Subset the list member Ys ... #> Subset the list member Data ... #> Done (subsetStations)
forecasts.sub$StationNames
#> [1] "Station1" "Station5"
dim(forecasts$Data)
#> [1] 2 10 5 2
dim(forecasts.sub$Data)
#> [1] 2 2 5 2
# Subset an observation list observations <- list( StationNames = paste0('Station', 1:10), Xs = 1:10, Ys = 10:1, Data = array(1:100, dim = c(2, 10, 5)) ) index <- 6 observations.sub <- subsetStations(index, observations)
#> Subset the list member StationNames ... #> Subset the list member Xs ... #> Subset the list member Ys ... #> Subset the list member Data ... #> Done (subsetStations)
observations.sub$StationNames
#> [1] "Station6"
dim(observations$Data)
#> [1] 2 10 5
dim(observations.sub$Data)
#> [1] 2 1 5