if (FALSE) {
library(RNCEP)
## Retrieve data for a specified spatial and temporal extent ##
wx.extent <- NCEP.gather(variable = "air", level=850,
months.minmax = 11, years.minmax = 2000,
lat.southnorth = c(50, 60), lon.westeast = c(0, 10),
reanalysis2 = FALSE, return.units = TRUE)
## Visualize the first layer (i.e. first timestep) of the
## variable on a map
## Note how to specify the plot's title
## Note also the adjustment of the Kernal span argument for
## interpolation using interp.loess.args
NCEP.vis.area(wx.data=wx.extent, layer=1, show.pts=TRUE, draw.contours=TRUE,
cols=heat.colors(64), transparency=.6, title.args=list(main="Example"),
interp.loess.args=list(span=.75))
## Now visualize a particular layer by specifying its datetime ##
NCEP.vis.area(wx.data=wx.extent, layer='2000-11-01 18', show.pts=TRUE,
draw.contours=TRUE, cols=terrain.colors(64), transparency=.6,
title.args=list(main="Example: select layer by datetime"),
interp.loess.args=list(span=0.5))
## Now produce the same graph as above ##
## This time, label the color-bar legend ##
NCEP.vis.area(wx.data=wx.extent, layer='2000-11-01 18', show.pts=TRUE,
draw.contours=TRUE, cols=terrain.colors(64), transparency=.6,
title.args=list(main="Example: select layer by datetime"),
interp.loess.args=list(span=0.5),
image.plot.args=list(legend.args=list(text='Kelvin', cex=1.15, padj=-1, adj=-.25)))
## Now produce the same graph as above ##
## This time, explicitly specify the size and location
## of the color-bar legend using the smallplot argument
## in the list of image.plot.args ##
NCEP.vis.area(wx.data=wx.extent, layer='2000-11-01 18', show.pts=TRUE,
draw.contours=TRUE, cols=terrain.colors(64), transparency=.6,
title.args=list(main="Example: select layer by datetime"),
interp.loess.args=list(span=0.5),
image.plot.args=list(legend.args=list(text='Kelvin', cex=1.15, padj=-1, adj=-.25),
smallplot=c(0.8475, 0.875, 0.20, 0.8)))
###########################################################
## This function can also show a layer after aggregation ##
###########################################################
## Calculate the average hourly temperature from the data
## obtained above ##
wx.ag <- NCEP.aggregate(wx.data=wx.extent, YEARS=FALSE, MONTHS=FALSE,
HOURS=TRUE, DAYS=FALSE, fxn='mean')
## Now plot the mean temperature at midnight ##
## Note the adjustment of axis labels
## Note also the adjustment of the point type
NCEP.vis.area(wx=wx.ag, layer=1, interp.loess.args=list(span=0.5),
title.args=list(main='Example: aggregated layer', xlab='Long [degrees]',
ylab='Lat [degrees]'), points.args=list(pch=19))
## Now produce the same plot as above ##
## This time, change the font size used in the
## contour labels ##
NCEP.vis.area(wx=wx.ag, layer=1, interp.loess.args=list(span=0.5),
title.args=list(main='Example: aggregated layer', xlab='Long [degrees]',
ylab='Lat [degrees]'), points.args=list(pch=19),
contour.args=list(labcex=.6))
## Notice how you can plot an aggregated layer by specifying
## it explicitly ##
NCEP.vis.area(wx=wx.ag, layer="XXXX-XX-XX 18", interp.loess.args=list(span=0.5),
title.args=list(main='Example: aggregated layer', xlab='Long [degrees]',
ylab='Lat [degrees]'), points.args=list(pch=19),
contour.args=list(labcex=.6))
}
Run the code above in your browser using DataLab