Last data update: 2014.03.03

R: NWP forecasts for a location
getPointR Documentation

NWP forecasts for a location

Description

The getPoint* functions get outputs of the NWP models run by MeteoGalicia and NCEP (GFS, RAP, NAM) for a single location.

Usage

getPoint(point, vars = "swflx", day = Sys.Date(), run = "00",
         resolution = NULL, vertical = NA, service = mfService())

getPointDays(point, vars = "swflx", start = Sys.Date(), end,
             service = mfService(), ...)

getPointRuns(point, var = "swflx",
             start = Sys.Date() - 1, end = Sys.Date(),
             service = mfService(), ...) 


Arguments

point

Coordinates of the location. It can be a SpatialPoints or a numeric of length 2.

var, vars

Character. The name of the variables to retrieve. Use grepVar to know what variables are available in each service. getPointRuns only works with one variable.

day

Date or character

run

Character. The meteogalicia service executes the model at OOUTC and 12UTC. Therefore run can be '00' or '12'. With GFS and NAM run can be '00', '06', '12', and '18'. The RAP service is run every hour.

start

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

end

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

resolution

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

vertical

Numeric. Vertical coordinate for variables with several levels. Its default value is NA, meaning that only the first level will be retained.

service

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

...

Additional arguments for getPoint

Details

These functions download data from the MeteoGalicia and NCEP (GFS, RAP, NAM) servers using the NetCDF Subset Service. The result is returned as a zoo time series object, with one or more csv files stored in the temporary folder (as defined by tempdir()).

Value

getPoint and getPointDays produce a zoo time series with a column for each variable included in vars.

The time series returned by getPoint starts at 01UTC of day if run = '00' or 13UTC if run = '12'. It spans over 4 days (96 hours) if run = '00' or 84 hours if run = '12'.

The time series returned by getPointDays starts at 01UTC of start and finishes at 00UTC of end + 1. Each day comprised in the time period is constructed with the forecast outputs corresponding to the 00UTC run of that day. Therefore, only the first 24 values obtained with getPoint are used for each day.

The time series returned by getPointRuns starts at 01UTC of start and finishes at 00UTC of end + 1. It has 4 columns, named "D3_00", "D2_00", "D1_00" and "D0_00". The column "D3_00" corresponds to the forecast results produced 3 days before the time stamp of each row, and so on.

Author(s)

Oscar Perpiñán Lamigueiro with contributions from Marcelo Almeida

See Also

getRaster

Examples

## Not run: 
  today <- Sys.Date()
  testDay <- today - 7

  ## temperature (Kelvin) forecast from meteogalicia
  tempK <- getPoint(c(0, 40), vars = 'temp', day = testDay)
  ## Cell does not coincide exactly with request
  attr(tempK, 'lat')
  attr(tempK, 'lon')
  ## Units conversion
  tempC <- tempK - 273

  library(lattice)
  ## Beware: the x-axis labels display time using your local timezone.
  Sys.timezone()

  ## Use Sys.setenv(TZ = 'UTC') to produce graphics with the timezone
  ## of the objects provided by meteoForecast.
  xyplot(tempC)

  ## Multiple variables
  vars <- getPoint(c(0, 40), vars = c('swflx', 'temp'), day = testDay)
  xyplot(vars)

  ## Vertical coordinates
  tempK1000 <- getPoint(c(101,6),
                        vars = "Temperature",
                        day = testDay,
                        service ="gfs", vertical = 1000)

  ## Time sequence
  radDays <- getPointDays(c(0, 40),
                          start = testDay - 3,
                          end = testDay + 2)
  
  xyplot(radDays)

  ## Variability between runs
  radRuns <- getPointRuns(c(0, 40),
                          start = testDay - 3,
                          end = testDay + 2)
  xyplot(radRuns, superpose = TRUE)
  
  ## variability around the average
  radAv <- rowMeans(radRuns)
  radVar <- sweep(radRuns, 1, radAv)
  xyplot(radVar, superpose = TRUE)

## End(Not run)

Results