wiki:udg/ecoms/RPackage/examples/visualization

Version 2 (modified by juaco, 6 years ago) (diff)

--

Forecast skill visualization: a worked example using visualizeR


NOTE: In this example we use the same forecast and observations datasets than in the previous example on forecast verification.


Package loading/install

We first load (and install if necessary) the required libraries. loadeR.ECOMS and visualizeR, used for data loading and visualization respectively (see the installation instructions for loadeR.ECOMS and visualizeR packages. In addition, downscaleR will be used for data manipulation (regridding).

library(loadeR.ECOMS)
library(visualizeR)
library(downscaleR

Data loading from the ECOMS-UDG

We load the predictions:

tx.forecast <- loadECOMS(dataset = "CFSv2_seasonal",
                         var = "tasmax",
                         members = 1:4,
                         lonLim = c(-10 ,15),
                         latLim = c(35, 50),
                         season = 6:8,
                         years = 1991:2000,
                         leadMonth = 2)

## [2016-05-12 12:56:18] Defining homogeneization parameters for variable "tasmax"
## [2016-05-12 12:56:18] Opening dataset...
## [2016-05-12 12:56:48] The dataset was successfuly opened
## [2016-05-12 12:56:48] Defining geo-location parameters
## [2016-05-12 12:56:49] Defining initialization time parameters
## [2016-05-12 12:56:51] Retrieving data subset ...
## [2016-05-12 13:07:02] Done

plotMeanGrid(tx.forecast, multi.member = TRUE)

And then we load the verifying observations (WFDEI dataset):

tx.obs <- loadECOMS(dataset = "WFDEI",
                    var = "tasmax",
                    lonLim = c(-10 ,15),
                    latLim = c(35, 50),
                    season = 6:8,
                    years = 1991:2000)
## [2016-05-12 14:03:40] Defining homogeneization parameters for variable "tasmax"
## [2016-05-12 14:03:40] Opening dataset...
## [2016-05-12 14:03:42] The dataset was successfuly opened
## [2016-05-12 14:03:42] Defining geo-location parameters
## [2016-05-12 14:03:42] Defining time selection parameters
## [2016-05-12 14:03:42] Retrieving data subset ...
## [2016-05-12 14:03:52] Done

plotMeanGrid(tx.obs)

In order to compare the predictions against the observations, these need to be in the same reference grid. We use the interpolation capabilities of downscaleR to this aim:

obsintp <- interpGrid(tx.obs,
                  new.coordinates = getGrid(tx.forecast),
                  method = "nearest")
## [2016-05-13 16:06:45] Calculating nearest neighbors...
## [2016-05-13 16:06:45] Performing nearest interpolation... may take a while
## [2016-05-13 16:06:45] Done
## Warning message:
## In interpGrid(tx.obs, new.coordinates = getGrid(tx.forecast), method = "nearest") :
##   The new longitudes are outside the data extent

visualizeR uses its own particular classes for handling data. It is necessary to convert to the visualizeR classes before using the visualization functions:

prd <- as.MrEnsemble(tx.forecast)
class(prd)
## [1] "MrEnsemble"
## attr(,"package")
## [1] "visualizeR"
obs <- as.MrGrid(obsintp)
class(obs)
## [1] "MrGrid"
## attr(,"package")
## [1] "visualizeR"

Attachments (6)

Download all attachments as: .zip