Consider an example below which uses sample data from the ensembleBMA package. This works fine. How can I achieve the same using high temporal resolution data say at 3 hourly? Or is this works only for daily data and not intermediate hours of the day? Please see my codes below;
rm( list = ls(all.names = TRUE) ) # Clear all
# Load libraries to use
library("ensembleBMA")
library("ensembleMOS")
# Get sample data
data("ensBMAtest", package = "ensembleBMA")
# Ensemble names
ensMemNames <- c("gfs","cmcg","eta","gasp","jma","ngps","tcwb","ukmo")
# Prepare input variable & target
obs <- paste("MAXWSP10","obs", sep = ".")
ens <- paste("MAXWSP10", ensMemNames, sep = ".")
# Prepare an ensemble data object. This uses "ensembleBMA" package
windTestData <- ensembleData( forecasts = ensBMAtest[, ens],
dates = ensBMAtest[, "vdate"],
observations = ensBMAtest[, obs],
station = ensBMAtest[, "station"],
forecastHour = 48,
initializationTime = "00")
# Train EMOS model
date_target <- format( seq( ISOdate(2007, 12, 27, 0), by = "1 day",
length.out = 7 ), "%Y%m%d%H" )
windFitLN <- ensembleMOS( ensembleData = windTestData,
trainingDays = 25,
dates = date_target,
model = "lognormal")
# Get the CRPS
windCRPS <- crps( windFitLN, windTestData )
# Get the quantile forecast
windFcst <- quantileForecast( fit = windFitLN,
quantiles = seq(0.1, 0.9, 0.1),
ensembleData = windTestData,
dates = date_target )
#===============================================================================
#========== Now I modify the dates to 3-hourly high temporal resolution ========
# Load libraries to use
library("ensembleBMA")
library("ensembleMOS")
# Get sample data
data("ensBMAtest", package = "ensembleBMA")
# Ensemble names
ensMemNames <- c("gfs","cmcg","eta","gasp","jma","ngps","tcwb","ukmo")
# Prepare input variable & target
obs <- paste("MAXWSP10","obs", sep = ".")
ens <- paste("MAXWSP10", ensMemNames, sep = ".")
# Generate new date with high time resolution
new_vdate <- rep( format( seq( ISOdate(2007, 12, 27, 0),
by = "3 hour",
length.out = nrow(ensBMAtest)*0.5 ),
"%Y%m%d%H" ), each = 2 )
new_ensBMAtest <- dplyr::mutate( ensBMAtest[, -1], vdate = new_vdate )
# new ensemble data object using "ensembleBMA" package
new_windTestData <- ensembleData( forecasts = new_ensBMAtest[, ens],
dates = new_ensBMAtest[, "vdate"],
observations = ensBMAtest[, obs],
station = ensBMAtest[, "station"],
forecastHour = 3, # We change to 3 hour from 48 hour
initializationTime = "00")
# Build the lognormal EMOS model
new_date_target <- new_vdate[49:66]
new_windFitLN <- ensembleMOS( ensembleData = new_windTestData,
trainingDays = 25,
dates = new_date_target,
model = "lognormal")
#> Warning in ensembleMOSlognormal(ensembleData = new_windTestData, trainingDays =
#> 25, : valid dates do not have a unique forecast hour
#> Warning in ensembleMOSlognormal(ensembleData = new_windTestData, trainingDays =
#> 25, : dates do not have a unique forecast hour
#> Error in ensembleMOSlognormal(ensembleData = new_windTestData, trainingDays = 25, : some dates precede the first training period