Changes between Version 14 and Version 15 of udg/ecoms/RPackage/examples/pointSelection
- Timestamp:
- May 15, 2015 12:16:17 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
udg/ecoms/RPackage/examples/pointSelection
v14 v15 1 1 = Single point selections 2 2 3 The following call to `loadECOMS` will load a time series of summer 2001 (JJA, `season = 6:8`, `years = 2001`) surface (2m) daily mean temperature (`var = "tas"`, as defined in the [http://meteo.unican.es/ecoms-udg/RPackage/Homogeneization vocabulary]) for the coordinate -3.7E 40.4N, (`lonLim = -3.7`, `latLim = 40.4`) corresponding to the city of Madrid (Spain), as forecasted the previous March (`leadMonth = 2`) by the CFSv2 hindcast (`dataset = "CFSv2_seasonal_16"`). We will select the first 10 members (`members = 1:10`). Note that the original variable is stored in the CFSv2 database as 6-hourly. Hence, we indicate to the function to compute the daily mean from the 6-hourly data using the argument `time = "DD".` 4 5 6 First of all, the library is called and we log-in into the ECOMS-UDG: 3 First of all, the user needs to be [https://meteo.unican.es/trac/wiki/udg/registration registered] in the ECOMS-UDG via the Thredds administration Panel (TAP) before using the package for accessing any dataset. Once registered, the user will have a valid username and password and can log-in using the `loginECOMS_UDG` function: 7 4 8 5 {{{ … … 12 9 }}} 13 10 14 Now we are ready for accessing the ECOMS-UDG: 11 Now we are ready for accessing the ECOMS-UDG. 12 13 The following call to `loadECOMS` will load a time series of summer 2001 (JJA, `season = 6:8`, `years = 2001`) daily (`time = "DD"`) mean (`aggr.d = "mean"`) surface (2m) temperature (`var = "tas"`), for the coordinate -3.7E 40.4N, (`lonLim = -3.7`, `latLim = 40.4`) corresponding to the city of Madrid (Spain), as forecasted the previous March (`leadMonth = 2`) by the CFSv2 hindcast (`dataset = "CFSv2_seasonal"`). We will select the first 10 members (`members = 1:10`). 14 15 15 16 16 {{{ 17 17 #!text/R 18 point.cfs <- loadECOMS(dataset = "CFSv2_seasonal _16",18 point.cfs <- loadECOMS(dataset = "CFSv2_seasonal", 19 19 var = "tas", 20 20 members = 1:10, … … 24 24 years = 2001, 25 25 leadMonth = 2, 26 time = "DD") 26 time = "DD", 27 aggr.d = "mean") 27 28 }}} 28 29 … … 30 31 31 32 {{{ 32 [201 4-09-02 15:28:42] Defining homogeneization parameters for variable "tas"33 NOTE: daily mean will be calculated from the 6-h model output 34 [201 4-09-02 15:28:42] Defining geo-locationparameters35 [2014-09-02 15:28:42] Defining initialization time parameters 36 [201 4-09-02 15:28:46] Retrieving data subset ...37 [201 4-09-02 15:31:25] Done33 [2015-05-15 11:46:49] Defining homogeneization parameters for variable "tas" 34 [2015-05-15 11:46:50] Defining geo-location parameters 35 [2015-05-15 11:46:50] Defining initialization time parameters 36 NOTE: Daily aggregation will be computed from 6-hourly data 37 [2015-05-15 11:46:54] Retrieving data subset ... 38 [2015-05-15 11:49:47] Done 38 39 }}} 40 41 The original variable is stored in the CFSv2 database as 6-hourly (see the [https://meteo.unican.es/trac/wiki/udg/ecoms/dataserver/listofvariables available variables] and their time resolution). Hence, we indicate to the function to perform a daily average using the argument `time = "DD"` via the `mean` function (`aggr.d = "mean"`).` 39 42 40 43 This is the size of the loaded object: 41 44 42 45 {{{#!text/R 43 print(object.size(point.cfs)) # 2 2456bytes46 print(object.size(point.cfs)) # 20128 bytes 44 47 }}} 45 48 46 47 The returned object contains all the necessary information for data representation (geo-location, time ...). In the next lines we plot the loaded time series for each member. The element `Data` contains the data itself. In this case, it is a 2D array with the dimensions `member` (10 members selected) and `time` (92 days for June, July and August), as indicated by the `dimensions` attribute. 49 The returned object contains all the necessary information for data representation (geo-location, time, other metadata...). In the next lines we plot the loaded time series for each member. The element `Data` contains the data itself. In this case, it is a 2D array with the dimensions `member` (10 members selected) and `time` (92 days for June, July and August), as indicated by the `dimensions` attribute. 48 50 49 51 … … 56 58 57 59 {{{ 58 num [1:10, 1:92] 1 6.3 17.1 12.9 10.4 15.3...60 num [1:10, 1:92] 13.3 16.3 17.1 12.9 10.4 ... 59 61 - attr(*, "dimensions")= chr [1:2] "member" "time" 60 62 }}} 61 63 62 64 63 Note that, by convention, the dimensions of the Data array will be always ordered in the canonical form ''member > time > lat > lon''. Several vertical levels are never loaded at the same time, so the dimension ''level'' will never appear. This will be indicated in the Variables element of the returned output if existing. In this case it is NULL, because the variable loaded is a surface variable:65 Note that, by convention, the dimensions of the Data array will be always ordered in the canonical form ''member > time > lat > lon''. Several vertical levels are never loaded at the same time, so the dimension ''level'' will never appear. This will be indicated in the Variables element of the returned output. In this case it is NULL, because the variable loaded is a surface variable. Other useful metadada are included in the Variables element: 64 66 65 67 {{{ … … 71 73 72 74 {{{ 73 List of 3 74 $ varName : chr "tas" 75 $ isStandard: logi TRUE 76 $ level : NULL 75 List of 2 76 $ varName: chr "tas" 77 $ level : NULL 78 - attr(*, "is_standard")= logi TRUE 79 - attr(*, "units")= chr "degrees Celsius" 80 - attr(*, "longname")= chr "2-meter air temperature" 81 - attr(*, "daily_agg_cellfun")= chr "mean" 82 - attr(*, "monthly_agg_cellfun")= chr "none" 83 - attr(*, "verification_time")= chr "DD" 77 84 }}} 78 79 85 80 86 In the following example we plot the time series with the multi-member mean and its dispersion (interquartilic range 25-75): … … 86 92 dates <- as.POSIXlt(point.cfs$Dates$start, tz="GMT") 87 93 plot(dates, ens.mean, ylim = range(point.cfs$Data), 88 type = 'n', ylab = "tas - Daily Mean", xlab = "time") 94 type = 'n', ylab = point.cfs$Variable$varName, xlab = "time", 95 main = attr(point.cfs$Variable, "longname")) 96 mtext(attr(point.cfs$Variable, "units")) 89 97 polygon(x = c(dates, rev(dates)), 90 98 y = c(quartiles[1, ], rev(quartiles[2, ])), … … 93 101 }}} 94 102 95 [[Image(image-201 40617-160406.png)]]103 [[Image(image-20150515-121332.png)]] 96 104 97 105 {{{#!comment … … 145 153 lines(dates, point.wfdei$Data, col = "red", lwd = 1.5) 146 154 }}} 147 148 [[Image(image-20140617-161214.png)]] 155 [[Image(image-20150515-121332.png)]] 149 156 150 157 We could include a legend in the figure to define the different elements shown: