1

I am in interested in accessing historical NOAA model data, and have been using the rNOMADS package in R.

Most tutorials on this package focus on current data, for example this excellent one:

https://bovineaerospace.wordpress.com/2014/05/28/downloading-weather-sea-ice-and-wave-model-data-with-the-rnomads-package-in-r/

library(rNOMADS)
#A location near my house
lat <- 35.828304
lon <- -79.107467

#Find the latest Global Forecast System model run
model.urls <- GetDODSDates("gfs_0p50")
latest.model <- tail(model.urls$url, 1)
model.runs <- GetDODSModelRuns(latest.model)
latest.model.run <- tail(model.runs$model.run, 1)

#Figure out which forecasts to use
forecast.date <- as.POSIXlt(Sys.time(), tz = "UTC") 
abbrev <- "gfs_0p50"
## Not run:
forecasts <- GetClosestForecasts(abbrev = abbrev, forecast.date)

#Get nearest model nodes
lons <- seq(0, 359.5, by = 0.5)
lats <- seq(-90, 90, by = 0.5)
lon.diff <- abs(lon + 360 - lons)
lat.diff <- abs(lat - lats)
model.lon.ind <- which(lon.diff == min(lon.diff)) - 1 #NOMADS indexes at 0
model.lat.ind <- which(lat.diff == min(lat.diff)) - 1

#Subset model
time <- c(0,0) #Model status at initialization
lon.inds <- c(model.lon.ind - 2, model.lon.ind + 2)
lat.inds <- c(model.lat.ind - 2, model.lat.ind + 2)
variables <- c("ugrd10m", "vgrd10m") #E-W and N-S wind

wind.data <- DODSGrab(latest.model, latest.model.run, variables,
                      time, lon.inds, lat.inds)

profile <- BuildProfile(wind.data, lon, lat, spatial.average = TRUE, points = 4)

#Present results!
print(paste("At", profile[[1]]$forecast.date, "the East-West winds at Briar Chapel were going", sprintf("%.2f", profile[[1]]$profile.data[1, which(profile[[1]]$variables == "ugrd10m"), 1]),
            "meters per second, and the north-south winds were going", sprintf("%.2f", profile[[1]]$profile.data[1, which(profile[[1]]$variables == "vgrd10m"), 1]),
            "meters per second."))

This works fine on current model data. But I'd like historical data for a specific date and location

I tried to use the function "GetClosestForcasts" which seems to be what I need to do for historical data. But I get an error when running this code straight out of the vignette:

#Figure out which forecasts to use
forecast.date <- as.POSIXlt(Sys.time(), tz = "UTC") 
abbrev <- "gfs_0p50"
## Not run:
forecasts <- GetClosestForecasts(abbrev = abbrev, forecast.date)


Error in stringr::str_match_all(url.to.use, "\\d{10}")[[1]][1, 1] : 
  subscript out of bounds

Ideally, what I would like to do would be give both of these specific dates

forecast.date <- as.POSIXlt("2005-05-05", tz = "UTC")
forecast.date <- as.POSIXlt("2017-05-05", tz = "UTC")

And be able to run the same example as above for these dates and location, returning surface model data wind speed, temperature, and precipitation

Vint
  • 413
  • 6
  • 17
  • I do not know this package well. But it seems that you do not have access to past data much. For instance, https://nomads.ncep.noaa.gov:9090/dods/gfs_0p50 is probably the place you are trying to get data using `GetClosestForecasts`. As far as I see the link, you do not have data from last 10 days. – jazzurro Jan 09 '20 at 01:38
  • I'm looking to access the North American Mesoscale Forecast System (NAM) -https://www.ncdc.noaa.gov/data-access/model-data/model-datasets/north-american-mesoscale-forecast-system-nam - and as I understand it, NOAA maintains records going back to 2004- to present – Vint Jan 09 '20 at 12:26

0 Answers0