Last data update: 2014.03.03

R: Get model data at a specific point.
BuildProfileR Documentation

Get model data at a specific point.

Description

Takes the output of ReadGrib or DODSGrab and extracts data at a specific point, performing interpolation if required.

Usage

BuildProfile(model.data, lon, lat, spatial.average, points = 4)

Arguments

model.data

Data structure returned by ReadGrib or DODSGrab.

lon

Longitudes of points of interest.

lat

Latitudes of points of interest.

spatial.average

Whether to interpolate data using b-splines to obtain value at the requested point (spatial.average = TRUE) or use the nearest model node (spatial.average = FALSE).

points

How many points to include in the interpolation, will be ignored if spatial.average = FALSE.

Details

It is much more efficient to download a large chunk of data and extract profile points from that as opposed to downloading individual small model chunks in the vicinity of each point of interest.

Value

profile

A list with as many elements as profile points, with fields:

profile$profile.data

A levels x variables x time matrix with data at a specific point

profile$location

The location for which the profile is generated

profile$forecast.date

What dates and times the profile contains

profile$variables

The variables the profile contains

profile$levels

The levels the profile contains

Author(s)

Daniel C. Bowman daniel.bowman@unc.edu

See Also

ReadGrib, DODSGrab

Examples


#Get temperature profile in Chapel Hill, NC.

#First, define each location
lon <- -79.052094
lat <- 35.907562

#Get latest GFS 0.5 model, use analysis forecast
## Not run: 
model.url <- CrawlModels(abbrev = "gfs_0p50", depth = 1)[1]
pred <- ParseModelPage(model.url)$pred[1]

## End(Not run)

#Get levels
pressure <- c(1, 2, 3, 5, 7,
10, 20, 30, 50, 70,
seq(100, 1000, by = 25))
levels <- paste(pressure, " mb", sep = "")

#Variables - temperature and height only
variables <- c("TMP", "HGT")

## Not run: 
grib.info <- GribGrab(model.url, pred, levels, variables,
   model.domain = c(-85, -75, 37, 32))
grib.data <- ReadGrib(grib.info$file.name, levels, variables)

profile <- BuildProfile(grib.data, lon, lat, TRUE, points = 8)
plot(profile[[1]]$profile.data[,2, 1] - 272.15, 
   profile[[1]]$profile.data[,1, 1], xlab = "Temperature (C)",
   ylab = "Height (m)", main = "Temperature Profile above Chapel Hill, NC")

## End(Not run)

Results