Changes between Version 17 and Version 18 of udg/ecoms/RPackage/examples/continentalSelection


Ignore:
Timestamp:
Sep 4, 2014 12:42:18 PM (7 years ago)
Author:
juaco
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • udg/ecoms/RPackage/examples/continentalSelection

    v17 v18  
    4848[[Image(image-20140902-170632.png)]]
    4949
    50 
    51 {{{#!comment
    52 
    53 We load now the reference observations for the spatio-temporal domain previously chosen:
    54 
    55 
    56 {{{
    57 #!text/R
    58 > ex2.obs <- loadECOMS(dataset = "WFDEI", var = "tasmin", lonLim = c(-15,35), latLim = c(32, 75), season = c(12,1,2), years = 2001:2010)
    59 [2014-09-02 17:07:43] Defining homogeneization parameters for variable "tasmin"
    60 [2014-09-02 17:07:44] Defining geo-location parameters
    61 [2014-09-02 17:07:44] Defining time selection parameters
    62 [2014-09-02 17:07:44] Retrieving data subset ...
    63 [2014-09-02 17:07:58] Done
    64 > print(object.size(ex2.obs), units = "Mb")
    65 60.6 Mb
    66 }}}
    67 
    68 This is the map of the observed mean minimum surface temperature observed for DJF 2001-2010:
    69 
    70 {{{
    71 #!text/R
    72 > plotMeanField(ex2.obs)
    73 }}}
    74 
    75 [[Image(image-20140902-171138.png)]]
    76 
    77 Note that WFDEI provides data for land areas only, and its spatial resolution is finer than CFS (1º vs 0.5º). In order to compare both datasets, it is first necessary to put them in the same grid (i.e., to interpolate). We use bilinear interpolation to this aim, using the `downscaleR` function `interpGridData` in combination with the `getGrid` method, useful to recover the parameters defining the grid of a dataset to pass them to the interpolator:
    78 
    79 {{{
    80 #!text/R
    81 > obs.regridded <- interpGridData(gridData = ex2.obs, new.grid = getGrid(ex2), method = "bilinear")
    82 [2014-09-02 17:22:11] Performing bilinear interpolation... may take a while
    83 [2014-09-02 17:22:30] Done
    84 Warning messages:
    85 1: In interpGridData(gridData = ex2.obs, new.grid = getGrid(ex2), method = "bilinear") :
    86   The new longitudes are outside the data extent
    87 2: In interpGridData(gridData = ex2.obs, new.grid = getGrid(ex2), method = "bilinear") :
    88   The new latitudes are outside the data extent
    89 }}}
    90 
    91 Note the warnings reminding us that the extent of the input grid is wider that that of CFS. However, in this case we can safely ignore this warnings, since all the land areas we are interest in are within the CFS domain.
    92 
    93 {{{
    94 #!text/R
    95 > plotMeanField(obs.regridded)
    96 }}}
    97 
    98 
    99 [[Image(image-20140902-172529.png)]]
    100 
    101 
    102 Now that both model data and observations are in the same grid, we can compute the bias. First, we calculate the spatial mean of WFDEI, which is the reference against which to compute the biases:
    103 
    104 {{{
    105 #!text/R
    106 > ref <- apply(obs.regridded$Data, MARGIN = c(3,2), mean, na.rm = TRUE)
    107 }}}
    108 
    109 The following lines of code compute the bias of each member w.r.t. the reference and plot them:
    110 
    111 {{{
    112 #!text/R
    113 # Now we compute the difference agains each of the multimember spatial means:
    114 > require(fields)
    115 > n.members <- dim(ex2$Data)[1]
    116 > par(mfrow = c(1,2))
    117 > for (i in 1:n.members) {
    118 +       member <- apply(ex2$Data[i, , , ], MARGIN = c(3,2), mean, na.rm = TRUE)
    119 +       bias <- member - ref     
    120 +       image.plot(ex2$xyCoords$x, ex2$xyCoords$y, bias, xlab = "lon", ylab = "lat", asp = 1)
    121 +       title(paste("Bias member", i))
    122 +       world(add = TRUE)
    123 + }
    124 > par(mfrow = c(1,1)) # To reset the graphical window
    125 }}}
    126 
    127 [[Image(image-20140902-180232.png)]]
    128 
    129 
    130