Description Usage Arguments Details Value Author(s) Examples
Built to extract certain variables/forecast times from NetCDF files.
1 2 |
nc |
Open |
init |
|
varname |
|
steps |
Optional. If not set all forecast steps from the |
level |
Used when loading variables from pressure level files where the
level has to be specified as a |
subset |
Optional, default |
silent |
|
subset
allows to only load parts of the data from the nc
connection.
If subset
is of class Extent
(see extent
) then
only (a spatial) subset of the data will be taken. If subset
is of class RasterLayer
(see raster
) the extent of the RasterLayer
will be used to crop
the data, the resolution (or grid specification) of this RasterLayer
will be used to
re-sample the data. This allows to change the resolution when loading the data.
Returns a RasterLayer
(if only one step
) is loaded or a RasterStack
object where each layer corresponds to a forecast step. Names of the layers contain the
initial initial date plus the forecast step.
Reto Stauffer
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 | ## Not run:
library('maps'); library("raster")
# Open netcdf connections
init <- as.POSIXct("2011-11-18 00:00")
init_str <- strftime(init,"
ncs <- nc_open(sprintf("costgrib/ECMWF_cost_sfc_
ncp <- nc_open(sprintf("costgrib/ECMWF_cost_pl_
# Loading "tcw" from surface file, step 24, full field
x <- getdata(ncs,init,"tcw",24)
plot(x); map(add=T)
# Using an extent subset and loading three different steps
x <- getdata(ncs,init,"tcw",c(12,24,48),subset=extent(c(10,30,40,50)))
plot(x)
# Loading pressure level data (u on 700 hPa) and resample the data
# onto a coarser resolution.
template <- raster(xmn=9.5,xmx=30.5,ymn=39.5,ymx=50.5,nrows=21,ncols=11,
crs=crs("+proj=longlat +datum=WGS84 +ellps=WGS84 +no_defs +towgs84=0,0,0"))
x <- getdata(ncp,init,"u",144,level=700,subset=template)
plot(x); map(add=T)
# Close connections
nc_close(ncs)
nc_close(ncp)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.