Learn R Programming

rNOMADS (version 1.0.0)

GetModelRunHour: Get the time and date for the most recent GFS model run

Description

Determine the most recent GFS model run to a given date and time. This ensures that the forecast to download is the most accurate and up to date.

Usage

GetModelRunHour(model.date = Sys.time(), fcst.date = Sys.time(), 
    url.to.check = c(
    "http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_hd.pl?dir=%2Fgfs.", 
    "%2Fmaster"), 
    attempts = 10)

Arguments

model.date
The date when the GFS model was run, in POSIX format.
fcst.date
The date to get the weather forecast for, in POSIX format.
url.to.check
The URL that points to the model download page.
attempts
How many times to try contacting the model download page before giving up.

Value

  • model.hourWhat GMT time the latest model run took place for the date specified in model.date.
  • url.testedThe URL that was checked to determine that the model hour is valid
  • fcst.tdiffTime difference between model date and forecast date (i.e. how far in the future the forecast is from the model run that's available) in hours
  • fcst.backThe model forecast run immediately before the requested forecast date
  • fcst.foreThe model forecast run immediately after the requested forecast date.

Details

GribGrab calls GetModelRunHour to determine which model files to download. model.date and fcst.date are in POSIX format (use as.POSIXct).

References

http://nomads.ncep.noaa.gov/

See Also

GribGrab

Examples

Run this code
#Get the latest model run
model.date <- Sys.time() 

#Get the forecast 6 hours from now - addition is defined in seconds
fcst.date <- model.date + 6 * 3600 

#Figure out what model files to download
model.params <- GetModelRunHour(model.date = model.date, fcst.date = fcst.date)

print(model.params$model.hour) #When the GFS model was run last
print(model.params$fcst.back) #The forecast hour before the requested forecast date
print(model.params$fcst.fore) #The forecast hour after the requested forecast date

Run the code above in your browser using DataLab