使用rNOMADS访问历史天气模型数据
我对访问历史NOAA模型数据感兴趣,并一直在使用R 关于此软件包的大多数教程都侧重于当前数据,例如,此优秀教程:使用rNOMADS访问历史天气模型数据,r,weather,noaa,rnoaa,R,Weather,Noaa,Rnoaa,我对访问历史NOAA模型数据感兴趣,并一直在使用R 关于此软件包的大多数教程都侧重于当前数据,例如,此优秀教程: 库(rNOMADS) #我家附近的地方 我对这个包裹不太熟悉。但你似乎没有太多机会接触到过去的数据。例如,可能是您试图使用getclosestforecast获取数据的地方。据我所知,你没有过去10天的数据。我想访问北美中尺度预报系统(NAM)——据我所知,NOAA保持着2004年的记录——以表明我不太了解这个数据包。但你似乎没有太多机会接触到过去的数据。例如,可能是您试图使用ge
库(rNOMADS)
#我家附近的地方
我对这个包裹不太熟悉。但你似乎没有太多机会接触到过去的数据。例如,可能是您试图使用getclosestforecast
获取数据的地方。据我所知,你没有过去10天的数据。我想访问北美中尺度预报系统(NAM)——据我所知,NOAA保持着2004年的记录——以表明我不太了解这个数据包。但你似乎没有太多机会接触到过去的数据。例如,可能是您试图使用getclosestforecast
获取数据的地方。据我所知,你没有过去10天的数据。我希望访问北美中尺度预报系统(NAM)——据我所知,NOAA保持着从2004年至今的记录
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."))
#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
forecast.date <- as.POSIXlt("2005-05-05", tz = "UTC")
forecast.date <- as.POSIXlt("2017-05-05", tz = "UTC")