Skip to content

Commit

Permalink
version 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycbowman authored and cran-robot committed Oct 30, 2014
1 parent 0ecdaef commit 87d3629
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 28 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: rNOMADS
Type: Package
Title: An interface to the NOAA Operational Model Archive and
Distribution System
Version: 2.0.3
Date: 2014-10-13
Version: 2.0.4
Date: 2014-10-30
Authors@R: c(person(given="Daniel C.",family="Bowman", role=c("aut", "cre"),
email="daniel.bowman@unc.edu"))
Depends: R (>= 3.1.1)
Expand All @@ -17,10 +17,10 @@ URL: https://r-forge.r-project.org/projects/rnomads/ (subversion
(GrADS-DODS examples)
http://www.unc.edu/~haksaeng/rNOMADS/rNOMADS_grib_examples.pdf
(grib examples)
Packaged: 2014-10-13 04:01:06 UTC; dantayaga
Packaged: 2014-10-30 16:49:43 UTC; bowman
Maintainer: Daniel C. Bowman <daniel.bowman@unc.edu>
MailingList: rnomads-user@lists.r-forge.r-project.org
Author: Daniel C. Bowman [aut, cre]
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-10-13 08:09:18
Date/Publication: 2014-10-30 19:34:56
12 changes: 6 additions & 6 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
71de9873f46079ae0bacaced8f924f8c *DESCRIPTION
5c62a403e3b02eb7d9a0f87392f8f7fb *DESCRIPTION
8b54e5a89fbda3af5e077053d40bec76 *NAMESPACE
1ea11698dd31813d2a7c591c6021c631 *NEWS
8abbabb4c5e982216309d093bd0d635e *NEWS
7c5fca27d886b469d97698afa0a9ffe5 *R/GetArchiveGrib.R
5a643620d3c671f016d3b037106877d7 *R/GetDODS.R
8020a4b69d6501b25feac2416f654dc4 *R/GetDODS.R
cfb79120a31c49156f63e668f7c80428 *R/GetRealTimeGrib.R
19eb65157610abefb202413aed4d0ce8 *R/Models.R
1942ca1b3a124a616e620b75fe734d26 *R/RNomadsTools.R
cff8d18f447cb30b4ca79718d8134fc8 *R/ReadGrib.R
b6964c6927a28e96302311336685d4d0 *R/RNomadsTools.R
987f1ef4e08f89fee97ad6946fa9b218 *R/ReadGrib.R
655d7615473825378142c4b6aac9cedd *man/ArchiveGribGrab.Rd
ca122cdc954c5e0fa0977d46cc3c2cbe *man/BuildProfile.Rd
0bdff541e2fbd21d7b2e205fca3e8656 *man/CheckNOMADSArchive.Rd
Expand All @@ -28,4 +28,4 @@ fac12ae053b5a476a7e12b4a8fe10043 *man/RTModelProfile.Rd
b4dd595a80d66cc9be93e53a3a4da0c1 *man/ReadGrib.Rd
6a2249cbb7db7acd1dcfad27a924b3cd *man/SanitizeURL.Rd
d0f6d0412e8764aa61fa837812c61d28 *man/WebCrawler.Rd
2f406397a9de22966fb85f056c172340 *man/rNOMADS-package.Rd
f2cf64980e5e2f11bc86c33646d5dbe3 *man/rNOMADS-package.Rd
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,8 @@ This is still experimental and may not work well.
Added the High Resolution Rapid Refresh model.
Fixed some model abbreviation and title mismatches in existing models, removed models no longer on NCEP.
Made it possible for GetDODS to accept multiple variables

2.0.4
Fixed date handing in DODSGrab.
It now returns actual forecast dates instead of numbers.
Fixed an insidious bug in BuildProfile that constructed profiles located over places not specified by the user.
12 changes: 10 additions & 2 deletions R/GetDODS.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ DODSGrab <- function(model.url, model.run, variables, time, lon, lat, levels = N
# the forecast (when the model was for), the variable (what kind of data), the level (where in the atmosphere or the Earth, vertically)
# the longitude, the latitude, and the value of the variable.

prev.digits <- options("digits")
options("digits" = 8)

model.data <- list(
model.run.date = NULL,
forecast.date = NULL,
Expand Down Expand Up @@ -197,8 +200,13 @@ DODSGrab <- function(model.url, model.run, variables, time, lon, lat, levels = N
levels.out <- as.numeric(unlist(strsplit(data.txt[grep("^lev,", data.txt) + 1], split = ",")))
}
t.ind <- grep("^time,", data.txt)
times <- as.numeric(unlist(strsplit(data.txt[t.ind + 1], split = ",")))


prev.digits <- options("digits")
options("digits" = 15)
num.times <- as.numeric(unlist(strsplit(data.txt[t.ind + 1], split = ",")))
options("digits" = prev.digits$digits)
times <- as.POSIXlt(as.Date(num.times - 2, origin = "1-1-1"), tz = "GMT") + 3600 * 24 * (num.times - floor(num.times))

#Extract data values

val.txt <- data.txt[2:(t.ind - 1)]
Expand Down
13 changes: 7 additions & 6 deletions R/RNomadsTools.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,20 @@ BuildProfile <- function(gridded.data, lon, lat, spatial.average) {
dim = c(length(gridded.data$levels), length(gridded.data$variables)))
#Project to Cartesian grid
lons <- t(array(rep(gridded.data$x, length(gridded.data$y)), dim = dim(gridded.data$z)[3:4]))
lats <- array(rep(rev(gridded.data$y), length(gridded.data$x)), dim = dim(gridded.data$z)[3:4])
lats <- array(rep(rev(gridded.data$y), length(gridded.data$x)), dim = rev(dim(gridded.data$z)[3:4]))
#lats <- array(rep(gridded.data$y, length(gridded.data$x)), dim = dim(gridded.data$z)[3:4])
proj <- GEOmap::setPROJ(type = 2, LAT0 = lat, LON0 = lon)
cart.pts <- GEOmap::GLOB.XY(as.vector(lats), as.vector(lons), proj)
cart.dist <- array(sqrt(cart.pts$x^2 + cart.pts$y^2), dim = c(length(gridded.data$x), length(gridded.data$y)))
cart.pts <- GEOmap::GLOB.XY(lats, lons, proj)
if(spatial.average) { #Average of 4 nearest points
for(k in seq_len(length(gridded.data$levels))) {
for(j in seq_len(length(gridded.data$variables))) {
layer.img <- cbind(cart.pts$x, cart.pts$y, as.vector(gridded.data$z[k,j,,]))
layer.img <- t(rbind(as.vector(cart.pts$x), as.vector(cart.pts$y[nrow(cart.pts$y):1,]), as.vector(t(gridded.data$z[k,j,,]))))
profile.data[k, j] <- MBA::mba.points(layer.img, cbind(0, 0))[[1]][3]
}
}
} else { #Nearest grid node
node.ind <- which(cart.dist == min(cart.dist), arr.ind = TRUE)
cart.dist <- sqrt(cart.pts$x^2 + cart.pts$y^2)
node.ind <- which(cart.dist[nrow(cart.dist):1,] == min(cart.dist), arr.ind = TRUE)
profile.data <- gridded.data$z[,,node.ind[1], node.ind[2]]
spatial.average.method <- "Nearest Node"

Expand Down Expand Up @@ -152,7 +153,7 @@ ModelGrid <- function(model.data, resolution, grid.type = "latlon", levels = NUL
warning("There appears to be more than one model run date in your model grid!")
}

fcst.date <- unique(model.data$forecast.date)
fcst.date <- as.POSIXlt(unique(model.data$forecast.date), tz = "GMT")

if(length(fcst.date) > 1) {
warning("There appears to be more than one model run date in your model grid!")
Expand Down
28 changes: 20 additions & 8 deletions R/ReadGrib.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ GribInfo <- function(grib.file, file.type = "grib2") {
# $GRID - Information on the model grid, only available in grib2

if(file.type == "grib2") {
test <- tryCatch(system('wgrib2', ignore.stdout=TRUE, ignore.stderr = TRUE))
if(test != 8) {
op <- options("warn")
options(warn = -1)
test <- tryCatch(system('wgrib2', intern = TRUE))
options(op)
if(attr(test, "status") != 8) {
stop("wgrib2 does not appear to be installed, or it is not on the PATH variable.
You can find wgrib2 here: http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/.
If the binaries don't work, try compiling from source.")
}
inv <- system(paste0("wgrib2 ", grib.file, " -inv -"), intern = TRUE)
grid <- system(paste0("wgrib2 ", grib.file, " -grid"), intern = TRUE)
} else if (file.type == "grib1") {
test <- tryCatch(system('wgrib', ignore.stdout=TRUE, ignore.stderr = TRUE))
if(test != 8) {
op <- options("warn")
options(warn = -1)
test <- tryCatch(system('wgrib', intern = TRUE))
options(op)
if(attr(test, "status") != 8) {
stop("wgrib does not appear to be installed, or it is not on the PATH variable.
You can find wgrib here: http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html.")
}
Expand Down Expand Up @@ -51,8 +57,11 @@ ReadGrib <- function(file.name, levels, variables, file.type = "grib2", missing.
#Get specified data from grib file

if(file.type == "grib2") {
test <- tryCatch(system('wgrib2', ignore.stdout=TRUE, ignore.stderr = TRUE))
if(test != 8) {
op <- options("warn")
options(warn = -1)
test <- tryCatch(system('wgrib2', intern = TRUE))
options(op)
if(attr(test, "status") != 8) {
stop("wgrib2 does not appear to be installed, or it is not on the PATH variable.
You can find wgrib2 here: http://www.cpc.ncep.noaa.gov/products/wesley/wgrib2/.
If the binaries don't work, try compiling from source.")
Expand Down Expand Up @@ -111,8 +120,11 @@ ReadGrib <- function(file.name, levels, variables, file.type = "grib2", missing.
grib.type = file.type
)
} else if (file.type == "grib1") {
test <- tryCatch(system('wgrib', ignore.stdout=TRUE, ignore.stderr = TRUE))
if(test != 8) {
op <- options("warn")
options(warn = -1)
test <- tryCatch(system('wgrib', intern = TRUE))
options(op)
if(attr(test, "status") != 8) {
stop("wgrib does not appear to be installed, or it is not on the PATH variable.
You can find wgrib here: http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html.
It is also available as an Ubuntu package.")
Expand Down
4 changes: 2 additions & 2 deletions man/rNOMADS-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The package will also attempt to call another external routine called \code{wgri
\tabular{ll}{
Package: \tab rNOMADS\cr
Type: \tab Package\cr
Version: \tab 2.0.2\cr
Date: \tab 2014-09-02\cr
Version: \tab 2.0.4\cr
Date: \tab 2014-10-30\cr
License: \tab GPL v3\cr
}}
\author{
Expand Down

0 comments on commit 87d3629

Please sign in to comment.