getRaster: NWP forecasts for a region

Description Usage Arguments Details Value Author(s) References Examples

Description

The getRaster* functions get outputs of the NWP models for a region.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
getRaster(var = "swflx", day = Sys.Date(), run = "00",
          frames = 'complete', box, resolution = NULL,
          names, remote = TRUE, service = mfService(),
          dataDir = ".", use00H = FALSE, ...)

getRasterDays(var = "swflx", start = Sys.Date(), end,
              remote = TRUE, dataDir = ".", ...)

getRasterDay(var = "swflx", day = Sys.Date(),
              remote = TRUE, dataDir = ".", ...)

checkDays(start, end, vars, remote = FALSE,
          service = mfService(), dataDir = '.')

Arguments

var, vars

Character. The name of the variable (or variables in checkDays) to retrieve. Use grepVar to know what variables are available in each service.

day

Date or character. In getRaster it defines the day when the forecast was produced. In getRasterDay it defines the day to be forecast.

run

Character. For example, the meteogalicia service executes the model at OOUTC and 12UTC. Therefore run can be '00' or '12'.

start

Date or character. First day of the time period to retrieve.

end

Date or character. Last day of the time period to retrieve.

frames

Numeric. It defines the number of hourly forecasts (frames) to retrieve. If frames = 'complete', the full set of frames is downloaded. For example, the meteogalicia service produces 96 hourly forecasts (frames) with run='00' and 84 frames with run='12'.

box

The bounding box, defined using longitude and latitude values. A Extent or an object that can be coerced to that class with extent: a 2x2 matrix (first row: xmin, xmax; second row: ymin, ymax), vector (length=4; order= xmin, xmax, ymin, ymax) or list (with at least two elements, with names 'x' and 'y').

resolution

Numeric. Resolution in kilometers of the raster. Valid choices are 4, 12, and 36. It is only used with service = 'meteogalicia'.

names

Character. Names of the layers of the resulting RasterBrick. If missing, a predefined vector is assigned the combination of day and hour.

remote

Logical. If TRUE (default) data is downloaded from the remote service. If FALSE the RasterBrick is produced with the files available in the local folder.

service

Character, which service to use, 'meteogalicia', 'gfs', 'nam' or 'rap'.

use00H

Logical. Only used when service is 'gfs', 'nam', or 'rap'. If FALSE (default), the first frame of each run or 00H "forecast" is not considered. This first frame is only produced for some variables. Therefore, with use00H = TRUE fewer frames that the number defined with frames could be obtained for some variables.)

dataDir

Character, path of the folder where files are stored (if remote = 'FALSE')

...

Additional arguments. Not used in getRaster.

Details

getRaster downloads data from the MeteoGalicia and NCDC (GFS, RAP, and NAM) servers using the NetCDF Subset Service. The result is returned as a RasterBrick object, with one or more NetCDF files stored in the temporary folder (as defined by tempdir()). Each frame or layer of the RasterBrick corresponds to a certain hour of the forecast.

getRasterDay uses getRaster to download the results corresponding to a certain day. If the day is in the future, the most recent forecast is downloaded with getRaster, and the corresponding frames are extracted. If the day is in the past, getRaster is used to download the corresponding frames of the forecast produced that day.

getRasterDays uses getRaster to download the results cast each day comprised between start and end using the 00UTC run. Then it subsets the first 24 frames of each result, and binds them together to produce a RasterBrick. Therefore, each frame of this RasterBrick is a forecast for an hour of the day when the forecast was cast.

checkDays explores a local folder looking for NetCDF files corresponding to a time sequence and a set of variables. It returns a Date vector comprising the days with files available for the requested variables. If remote = TRUE it only checks that start is after 2008-01-01 (first date of the archived forecasts of MeteoGalicia.)

Value

The getRaster* functions return a RasterBrick with a layer for each hour of the NWP forecast.

The time zone of the time index of this RasterBrick, stored in its z slot (accesible with getZ) is UTC.

MeteoGalicia, NAM, and RAP use the Lambert Conic Conformal projection. GFS files use longitude-latitude coordinates.

Author(s)

Oscar Perpiñán with contributions from Marcelo Almeida.

References

http://www.meteogalicia.es/web/modelos/threddsIndex.action

https://www.ncei.noaa.gov/thredds/catalog/gfs-004-files/catalog.html

https://www.ncei.noaa.gov/thredds/catalog/rap130/catalog.html

https://www.ncei.noaa.gov/thredds/catalog/nam218/catalog.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
## Not run: 
today <- Sys.Date()
testDay <- today - 7

## Retrieve raster data
wrf <- getRaster('temp', day = testDay)

## Display results with rasterVis
library(rasterVis)

levelplot(wrf, layers = 10:19)

hovmoller(wrf)

## Using box and frames specification
mfExtent('gfs')
cloudGFS <- getRaster('Temperature_surface',
                      day = testDay,
                      box = c(-10, 10, -10, 10),
                      service = 'gfs')

mfExtent('nam')
cloudNAM <- getRaster('Temperature_surface',
                      day = testDay,
                      box = c(-100, -80, 30, 50),
                      frames = 10,
                      service = 'nam')
mfExtent('rap')
cloudRAP <- getRaster('Temperature_surface',
                      day = testDay,
                      box = c(-100, -80, 30, 50),
                      frames = 10,
                      service = 'rap')


## Day sequence of cloud cover
wrfDays <- getRasterDays('cft',
                         start = testDay - 3,
                         end = testDay + 2,
                         box = c(-2, 35, 2, 40))

levelplot(wrfDays, layers = 10:19)

## animation
levelplot(wrfDays, layout = c(1, 1), par.settings = BTCTheme)

## Hövmoller graphic
hovmoller(wrfDays, par.settings = BTCTheme, contour = TRUE, cuts = 10)

NAMDays <- getRasterDays('Temperature_surface',
                         start = testDay - 3,
                         end = testDay + 2,
                         box = c(-100, -80, 30, 50),
                         service = 'nam')

## Extract data at some locations

st <- data.frame(name=c('Almeria','Granada','Huelva','Malaga','Caceres'),
               elev=c(42, 702, 38, 29, 448))

coordinates(st) <- cbind(c(-2.46, -3.60, -6.94, -4.42, -6.37),
                         c(36.84, 37.18, 37.26, 36.63, 39.47)
                         )
proj4string(st) <- '+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0'


## Extract values for some locations
vals <- extract(wrf, st)
vals <- zoo(t(vals), getZ(wrf))
names(vals) <- st$name

xyplot(vals)

## End(Not run)

oscarperpinan/meteoForecast documentation built on May 24, 2019, 4:11 p.m.