meteoForecast
meteoForecast
is a package to access outputs from Numerical Weather Prediction models both in raster format and as a time series for a location.
The current version works with these services:
New services will be added gradually, using this collection of meteorological data sources as reference.
This package has been developed in the framework of the European Project PVCROPS.
Installation
The development version is available at GitHub:
## install.packages("devtools")
devtools::install_github("meteoForecast", "oscarperpinan")
The stable version is available at CRAN:
install.packages('meteoForecast')
Usage
library(meteoForecast)
Load varsMG
, varsOM
and varsGFS
to know about the variables available in
each service:
data(varsMG)
head(varsMG)
data(varsOM)
head(varsOM)
data(varsGFS)
head(varsGFS)
grepVar
will help you to find the variable you need.
grepVar('cloud', service = 'gfs')
[1] "Temperature_low_cloud_top" "Pressure_middle_cloud_top" [3] "Temperature_middle_cloud_top" "Total_cloud_cover_middle_cloud" [5] "Cloud_Work_Function" "Pressure_low_cloud_bottom" [7] "Pressure_convective_cloud_top" "Pressure_convective_cloud_bottom" [9] "Total_cloud_cover_high_cloud" "Total_cloud_cover" [11] "Pressure_low_cloud_top" "Pressure_high_cloud_top" [13] "Pressure_middle_cloud_bottom" "Cloud_mixing_ratio" [15] "Pressure_high_cloud_bottom" "Total_cloud_cover_convective_cloud" [17] "Cloud_water" "Total_cloud_cover_entire_atmosphere" [19] "Total_cloud_cover_low_cloud" "Temperature_high_cloud_top"
Services
Each function admits an argument named service
to choose the
service. After loading meteoForecast
the default service is
Meteogalicia as reported with:
mfService()
[1] "meteogalicia"
You can choose a different service (for the running session) using
mfService
with the name of the service.
mfService('gfs')
Option service changed to gfs
mfService('meteogalicia')
Option service changed to meteogalicia
Basic information about services
mfProj4
provides the projection of a service:
mfProj4('nam')
[1] "+proj=lcc +lat_1=25 +lat_0=25 +lon_0=-95 +k_0=1 +x_0=0 +y_0=0 +a=6367470.21484375 +b=6367470.21484375 +units=km +no_defs "
mfExtent
provides the extent of a service (using the classExtent
defined by the packageraster
):
mfExtent('meteogalicia', resolution = 36)
class : Extent xmin : -49.18259 xmax : 18.789 ymin : 24.03791 ymax : 56.06608
Raster Data
getRaster
gets a forecast output inside a bounding box and provides a multilayer raster data using theRasterBrick
class defined in the packageraster
.wrf <- getRaster(var = 'temp', day = '2014-01-25', run = '00')
library(rasterVis) levelplot(wrf, layers = 10:21)
getRasterDays
usesgetRaster
to download the results cast each day comprised betweenstart
andend
using the 00UTC run.wrfDays <- getRasterDays('cft', start = '2014-01-01', end = '2014-01-05', box = c(-2, 35, 2, 40)) hovmoller(wrfDays, par.settings = BTCTheme, interpolate = TRUE, panel = panel.levelplot.raster)
Point Data
getPoint
, getPointDays
, and getPointRuns
get data for a
certain location and produce a time series using the zoo
class.
getPoint
## temperature (Kelvin) forecast from meteogalicia tempK <- getPoint(c(0, 40), vars = 'temp') ## Cell does not coincide exactly with request attr(tempK, 'lat') attr(tempK, 'lon') ## Units conversion tempC <- tempK - 273
xyplot(tempC)
getPointDays
## Time sequence radDays <- getPointDays(c(0, 40), start = '2013-01-01', end = '2013-01-15') xyplot(radDays)
getPointRuns
## Variability between runs radRuns <- getPointRuns(c(0, 40), start = '2013-01-01', end = '2013-01-15') xyplot(radRuns, superpose = TRUE)
## variability around the average
radAv <- rowMeans(radRuns)
radVar <- sweep(radRuns, 1, radAv)
xyplot(radVar, superpose = TRUE)