Skip to content

Spatio temporal subsetting

Sixto Herrera García edited this page Feb 19, 2016 · 3 revisions

Function subsetFied in loadeR allows to make subsets of the loaded grid data, hence, the needed data can be loaded at once and then make subsets of the geographic domain or the time period creating several objects from the same data.

Time period:

data(NCEP_Iberia_tas)
range(NCEP_Iberia_tas$Dates)

## [1] "1990-12-01 GMT" "2000-03-01 GMT"
sub.time <- subsetField(NCEP_Iberia_tas, years = 1995:1998)
range(sub.time$Dates)

## [1] "1994-12-01 GMT" "1998-03-01 GMT"

str(sub.time)

## List of 4
##  $ Variable:List of 2
##   ..$ varName: chr "tas"
##   ..$ level  : NULL
##   ..- attr(*, "is_standard")= logi TRUE
##   ..- attr(*, "units")= chr "degrees Celsius"
##   ..- attr(*, "longname")= chr "2-meter air temperature"
##   ..- attr(*, "daily_agg_cellfun")= chr "min"
##   ..- attr(*, "monthly_agg_cellfun")= chr "none"
##   ..- attr(*, "verification_time")= chr "DD"
##  $ Data    : num [1:361, 1:7, 1:9] 19 17.1 16 15.7 17.2 ...
##   ..- attr(*, "dimensions")= chr [1:3] "time" "lat" "lon"
##  $ xyCoords:List of 2
##   ..$ x: num [1:9] -9.38 -7.5 -5.62 -3.75 -1.88 ...
##   ..$ y: num [1:7] 33.3 35.2 37.1 39 41 ...
##   ..- attr(*, "projection")= chr "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
##  $ Dates   :List of 2
##   ..$ start: chr [1:361] "1994-12-01 GMT" "1994-12-02 GMT" "1994-12-03 GMT" "1994-12-04 GMT" ...
##   ..$ end  : chr [1:361] "1994-12-02 GMT" "1994-12-03 GMT" "1994-12-04 GMT" "1994-12-05 GMT" ...
##   ..- attr(*, "subset")= chr "subsetYears"
##  - attr(*, "dataset")= chr "NCEP"
##  - attr(*, "source")= chr "ECOMS User Data Gateway"
##  - attr(*, "URL")= chr "<http://meteo.unican.es/trac/wiki/udg/ecoms>"

Geographic domain:

data(NCEP_Iberia_tas)
plotMeanField(NCEP_Iberia_tas)

sub.geo <- subsetField(NCEP_Iberia_tas, lonLim = c(-1, 3), latLim = c(39,43))
plotMeanField(sub.geo)

subsetField can be applied to a multifield:

data(NCEP_Iberia_tp)

multi <- makeMultiField(NCEP_Iberia_tas, NCEP_Iberia_tp)

plotMeanField(multi)

sub.geo.multi <- subsetField(multi, lonLim = c(-1, 3), latLim = c(39,43))
plotMeanField(sub.geo.multi)

Grid from a multigrid:

sub.field <- subsetField(multi, var = "tp")
plotMeanField(sub.field)

If the data is multimember, function subsetFied can also be applied to select some members.


<-- Home page of the Wiki

print(sessionInfo())

## R version 3.2.3 (2015-12-10)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 14.04.3 LTS
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
##  [3] LC_TIME=es_ES.UTF-8           LC_COLLATE=en_US.UTF-8       
##  [5] LC_MONETARY=es_ES.UTF-8       LC_MESSAGES=en_US.UTF-8      
##  [7] LC_PAPER=es_ES.UTF-8          LC_NAME=es_ES.UTF-8          
##  [9] LC_ADDRESS=es_ES.UTF-8        LC_TELEPHONE=es_ES.UTF-8     
## [11] LC_MEASUREMENT=es_ES.UTF-8    LC_IDENTIFICATION=es_ES.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] loadeR_0.2-0      loadeR.java_1.1-0 rJava_0.9-8      
## 
## loaded via a namespace (and not attached):
##  [1] lattice_0.20-31 digest_0.6.8    bitops_1.0-6    grid_3.2.3     
##  [5] formatR_1.2     magrittr_1.5    spam_1.3-0      evaluate_0.7   
##  [9] stringi_0.4-1   sp_1.1-0        akima_0.5-12    rmarkdown_0.6.1
## [13] tools_3.2.3     stringr_1.0.0   RCurl_1.95-4.7  maps_3.0.2     
## [17] fields_8.3-6    yaml_2.1.13     abind_1.4-3     htmltools_0.2.6
## [21] knitr_1.10.5