loadValuePredictions: Load VALUE predictions data

View source: R/loadValuePredictions.R

loadValuePredictionsR Documentation

Load VALUE predictions data

Description

Load predictions data, either deterministic (one single txt file) or stochastic (several realizations stored in sepparate txt files, bundled in a single zip file).

Usage

loadValuePredictions(stationObj, predictions.file, tz = "",
  na.strings = "NA", n.mem = NULL)

Arguments

stationObj

A station data object returned by loadValueStations. See details.

predictions.file

Path to the file (either text or zip) containing the predictions.

tz

Optional. A time zone specification to be used for the conversion of dates. See more details in loadValueStations.

na.strings

Optional. A character vector of strings which are to be interpreted as NA values. Blank fields are also considered to be missing values in logical, integer, numeric and complex fields. This argument is passed to read.csv.

n.mem

Optional An integer value greater than zero indicating the number of members to be loaded. Default to NULL, so all the realizations are loaded. If n.mem is specified, the first n.mem members will be returned (i.e., from the 1st to the n.mem-th).

Details

The idea of this function is to rely on the previously loaded observations data, so all the information required to define the predictions subset (time and station codes) is retrieved from the observations data subset.

Value

A predictions object. This is equivalent to the stations object (see loadValueStations), but the data element may vary its shape to include the "member" dimension in case of stochastic predictions with several realizations. Also, a global attribute "datatype" is set, and assigned the value "predictions" to differentiate it from observations data.

See Also

Other loading: loadValueStations

Examples

 ## Not run: 
#Example predictions
obs.dataset <- file.path(find.package("R.VALUE"), "example_datasets", "VALUE_ECA_86_v2.zip")
obs <- loadValueStations(obs.dataset, "tmin", season = 6:8, years = 2001)
# Loading deterministic predictions
pred.file1 <- file.path(find.package("R.VALUE"),
                        "example_datasets",
                        "example_predictions_tmin_portal_exp1a_deterministic.zip")
pred <- loadValuePredictions(obs, pred.file1)
str(pred$Data) # 2D array
# Loading stochastic predictions (several realizations)
pred.file2 <- file.path(find.package("R.VALUE"),
                        "example_datasets",
                        "example_predictions_tmin_portal_exp1a_stochastic.zip")
pred2 <- loadValuePredictions(obs, pred.file2)
str(pred2$Data) # 3D array with 'member' dimension
# Selecting the first 2 members using 'n.mem':
pred3 <- loadValuePredictions(obs, pred.file2, n.mem=2)
str(pred3$Data) # 3D array with 'member' dimension of length 2

## End(Not run)

SantanderMetGroup/R_VALUE documentation built on July 4, 2023, 4:27 a.m.