wiki:udg/ecoms/RPackage/biascorrection

Version 5 (modified by gutierjm, 7 years ago) (diff)

--

Multi-variable bias correction of seasonal forecast

Taking into account the users' needs, in the following example a calibration of all the variables available, and needed by the users, in the ECOMS-UDG data server.

Since the R language has been adopted for some key tasks in the EUPORIAS and SPECS projects (including the development of comprehensive validation and statistical-downscaling packages), the ecomsUDG.Raccess is envisaged as a user-friendly, R-based interface to the ECOMS User Data Gateway, enabling authentication and remote access to the different datasets (seasonal forecasting, observations, reanalysis) currently available. Moreover, ecomsUDG.Raccess implements data homogenization (a single vocabulary) and time filtering/aggregation functionality.

The ecomsUDG.Raccess package relies on the rJava package as an interface to the powerful capabilities of the Unidata's netCDF Java library.

The following panels show an illustrative use of ECOMS-UDG to obtain the minimum DJF temperature DJF bias for System4 hindcast (one-month lead time) over Europe. WFDEI is used as reference.

R code Output
# Packages and loging
library(downscaleR)
library(ecomsUDG.Raccess)
library(ncdf4) # Only needed to write NetCDF
loginECOMS_UDG(username = "username", password = "password")
# Loading data (two members)
obs <- loadECOMS(dataset = "WFDEI", 
                  var = "tas",
                  season = c(12,1,2,3,4,5),
                  lonLim = c(-15,35)
                  latLim = c(32, 75)
                  years =- c(2001:2010))
prd <- loadECOMS(dataset = "System4_seasonal_15", 
                  var = "tas", 
                  season = c(12,1,2,3,4,5), 
                  members = 1:2, 
                  leadMonth = 1,
                  lonLim = c(-15,35)
                  latLim = c(32, 75)
                  years = c(2001:2010))
prd <- interpGridData(prd, new.grid = getGrid(obs), 
                  method = "nearest");
# Bias correction and plotting
prd.bc <- biasCorrection(obs, prd, prd, 
                  method = "qqmap", 
                  multi.member=TRUE, 
                  window = 30) 
plotMeanField(obs) 
plotMeanField(prd, multi.member = FALSE) 
plotMeanField(prd.bc, multi.member = FALSE) 
# Exporting to netcdf4
fileName <- "tas_qqmap_System4_WFDEI_2001_2010.nc4"
grid2NetCDF(prd.bc, NetCDFOutFile = fileName, 
                  missval = 1e20, 
                  prec = "float")

# Creating a nc-file with the bias-corrected data: # The function grid2NetCDF builds a nc4-file using a downscaleR object, in this case the surface pressure bias corrected with the qq-map method. The resulting NetCDF is available in the link: # http://www.meteo.unican.es/work/datasets/psAdjust_System4_1_2_12_6_qqmap_WFDEI_2001_2010.nc4

First of all, the quantile-quantile mapping and the WFDEI data set are considered to calibrate the seven months corresponding to the initialization of November for the period 2001-2010 in an European domain. For the sake of the simplicity, only one member has been considered in this example.

library(downscaleR)
library(ecomsUDG.Raccess)
library(ncdf4) # Only needed to write NetCDF
loginECOMS_UDG(username = "username", password = "password")
# Seasonal forecast parameters:
dataset <- "System4_seasonal_15"
season <- c(12,1:5)
leadMonth <- 1
members <- 1:2
lonLim <- c(-15,35)
latLim <- c(32, 75)
years <- c(2001:2010)
time <- "DD"

# Bias correction parameters:
interpolationMethod <- "nearest" # Both observation and forecast should be define on the same grid. Options: "nearest" and "bilinear"
method <- "qqmap"
multi.member <- FALSE # Should members be adjusted sepparately (TRUE, default), or jointly (FALSE)?
pr.threshold <- 1 # The minimum value that is considered as a non-zero precipitation.
window <- 30 # Numeric value specifying the time window width used to calibrate. The window is centered on the target day. Default to \code{NULL}, which considers the whole period available.

It is important to note that some variables are derived from others (e.g. wss is estimated from the two wind components). For this reason, in order to reduce the memory requirements of the loading process, we have defined an "advisable order", which is used in this example. It is also advisable to remove non-necesary variables.

qqmap (with wet/dry frequency adjustment for precipitation)

# Advisable Order: taking into account the nature (raw/derived) of the target variables we suggest the following order.
variables <- c("ps","wss","huss","tas","tasmax","tasmin","tp","rsds","rlds")
for (v in 1:length(variables)){
   obs <- NULL
   prd <- NULL
   obs <- loadECOMS(dataset = "WFDEI", var = variables[v], 
        lonLim = lonLim, latLim = latLim, season = season, years = years[1])
   
   prd <- loadECOMS(dataset = dataset, var = variables[v], time = time, members = members, 
        lonLim = lonLim, latLim = latLim, season = season, years = years, leadMonth = leadMonth)
   
   prd <- interpGridData(prd, new.grid = getGrid(obs), method = interpolationMethod);
   
   if (any(grepl(obs$Variable$varName,c("tp")))){
        prd <- biasCorrection(obs, prd, prd, pr.threshold = pr.threshold,
             method = method, multi.member = multi.member, window = window)
   }else{
        prd <- biasCorrection(obs, prd, prd, 
             method = method, multi.member = multi.member, window = window)
   }
   # Exporting to netcdf4
   fileName <- paste(var[v],"System4_WFDEI.nc4",sep = "_")
   grid2NetCDF(prd.bc, NetCDFOutFile = fileName, 
                  missval = 1e20, 
                  prec = "float")
}

Attachments (1)

Download all attachments as: .zip