Changes between Version 2 and Version 3 of udg/ecoms/RPackage/examples/bias


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

--

Legend:

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

    v2 v3  
    88{{{
    99#!text/R
    10 > ex2.obs <- loadECOMS(dataset = "WFDEI", var = "tasmin", lonLim = c(-15,35), latLim = c(32, 75), season = c(12,1,2), years = 2001:2010)
    11 [2014-09-02 17:07:43] Defining homogeneization parameters for variable "tasmin"
    12 [2014-09-02 17:07:44] Defining geo-location parameters
    13 [2014-09-02 17:07:44] Defining time selection parameters
    14 [2014-09-02 17:07:44] Retrieving data subset ...
    15 [2014-09-02 17:07:58] Done
    16 > print(object.size(ex2.obs), units = "Mb")
    17 60.6 Mb
     10ex2.obs <- loadECOMS(dataset = "WFDEI", var = "tasmin", lonLim = c(-15,35), latLim = c(32, 75), season = c(12,1,2), years = 2001:2010)
     11print(object.size(ex2.obs), units = "Mb") # 60.6 Mb
    1812}}}
    1913
     
    2216{{{
    2317#!text/R
    24 > plotMeanField(ex2.obs)
     18plotMeanField(ex2.obs)
    2519}}}
    2620
     
    3226{{{
    3327#!text/R
    34 > obs.regridded <- interpGridData(gridData = ex2.obs, new.grid = getGrid(ex2), method = "bilinear")
    35 [2014-09-02 17:22:11] Performing bilinear interpolation... may take a while
    36 [2014-09-02 17:22:30] Done
     28obs.regridded <- interpGridData(gridData = ex2.obs, new.grid = getGrid(ex2), method = "bilinear")
     29}}}
     30
     31Note 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.
     32
     33{{{
    3734Warning messages:
    38351: In interpGridData(gridData = ex2.obs, new.grid = getGrid(ex2), method = "bilinear") :
     
    4239}}}
    4340
    44 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.
    4541
    4642{{{
    4743#!text/R
    48 > plotMeanField(obs.regridded)
     44plotMeanField(obs.regridded)
    4945}}}
    5046
     
    5753{{{
    5854#!text/R
    59 > ref <- apply(obs.regridded$Data, MARGIN = c(3,2), mean, na.rm = TRUE)
     55ref <- apply(obs.regridded$Data, MARGIN = c(3,2), mean, na.rm = TRUE)
    6056}}}
    6157
     
    6561#!text/R
    6662# Now we compute the difference agains each of the multimember spatial means:
    67 > require(fields)
    68 > n.members <- dim(ex2$Data)[1]
    69 > par(mfrow = c(1,2))
    70 > for (i in 1:n.members) {
    71 +       member <- apply(ex2$Data[i, , , ], MARGIN = c(3,2), mean, na.rm = TRUE)
    72 +       bias <- member - ref     
    73 +       image.plot(ex2$xyCoords$x, ex2$xyCoords$y, bias, xlab = "lon", ylab = "lat", asp = 1)
    74 +       title(paste("Bias member", i))
    75 +       world(add = TRUE)
    76 + }
    77 > par(mfrow = c(1,1)) # To reset the graphical window
     63require(fields)
     64n.members <- dim(ex2$Data)[1]
     65par(mfrow = c(1,2))
     66for (i in 1:n.members) {
     67      member <- apply(ex2$Data[i, , , ], MARGIN = c(3,2), mean, na.rm = TRUE)
     68      bias <- member - ref     
     69      image.plot(ex2$xyCoords$x, ex2$xyCoords$y, bias, xlab = "lon", ylab = "lat", asp = 1)
     70      title(paste("Bias member", i))
     71      world(add = TRUE)
     72}
     73par(mfrow = c(1,1)) # To reset the graphical window
    7874}}}
    7975