Skip to content

Commit

Permalink
version 2.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycbowman authored and cran-robot committed Oct 24, 2017
1 parent 2234d4d commit 102a237
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 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.3.6
Date: 2017-05-01
Version: 2.3.7
Date: 2017-10-23
Authors@R: c(person(given="Daniel C.",family="Bowman", role=c("aut", "cre"),
email="danny.c.bowman@gmail.com"))
Depends: R (>= 3.3.2), rvest (>= 0.3.2)
Expand All @@ -18,7 +18,7 @@ URL: <https://bovineaerospace.wordpress.com/category/r/ >,
<https://r-forge.r-project.org/projects/rnomads/ >,
<https://www.r-project.org >
NeedsCompilation: no
Packaged: 2017-05-02 03:53:26 UTC; dantayaga
Packaged: 2017-10-23 12:39:58 UTC; dantayaga
Author: Daniel C. Bowman [aut, cre]
Repository: CRAN
Date/Publication: 2017-05-02 05:52:07 UTC
Date/Publication: 2017-10-24 13:04:31 UTC
8 changes: 4 additions & 4 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
959779f81594dc1da897785b6f3bc226 *DESCRIPTION
635994d1af3696c88e6498e3d5aa601e *DESCRIPTION
390e84088e5d6fef202002db75860464 *NAMESPACE
f11739e2cc8ace839899a1ae06657e4f *NEWS
8a9885061cb4b4e1cb8b90d49e870382 *NEWS
25d1b075adf63d775b2003a6b13f7f3c *R/GetArchiveGrib.R
3d3616ae851730c99ca81b34c9add562 *R/GetDODS.R
573e507bae1e1f85f4ff251ecff230dc *R/GetRealTimeGrib.R
350c74c638277ac783906247a4a8fb4c *R/Models.R
9a4cd02bb95fe1bb070ee928915afdd1 *R/RNomadsTools.R
58a4fe422ee36b47281dcb7ddb02ea77 *R/ReadGrib.R
f0b987c015c12db7b612298db5cc7889 *R/ReadGrib.R
52f408d5e1ed74804c5d5a4408a11e40 *R/onAttach.R
e1094799c652a311619b92483183a5fc *inst/CITATION
81c30cc1ca803cde5a9e254641a31d46 *man/ArchiveGribGrab.Rd
Expand All @@ -27,7 +27,7 @@ df43cf3706870565770577a17e4ec5a1 *man/NOMADSArchiveList.Rd
261b6cc4586df17ae4723977b94a6267 *man/NOMADSRealTimeList.Rd
6518b5982569da84448dbe13263fb7de *man/ParseModelPage.Rd
eadc8897225fe1915cb3a846e37fcc73 *man/PlotWindProfile.Rd
6c442fcdbdce2687e746c683b22b18f2 *man/ReadGrib.Rd
1d8571c81e1e843e50dcd7c96b14d581 *man/ReadGrib.Rd
6a2249cbb7db7acd1dcfad27a924b3cd *man/SanitizeURL.Rd
06484a9ba0065e89fd135171582882df *man/SubsetNOMADS.Rd
4d432124140779c440551f2c3890cdc6 *man/WebCrawler.Rd
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ A variety of minor bug fixes and improvements:
-Thought I fixed an issue with pre-subsetting grib files via lat/lon using wgrib2 on windows machines, but one user is still having issues.
Decided to release anyway but keep looking into the problem (can't reproduce it on my Windows machine, which now works fine)

2-3.7
Added an option to choose which forecast to read in using ReadGrib.
This makes reading historic wave watch grib2 files a lot faster, for example.
20 changes: 17 additions & 3 deletions R/ReadGrib.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ GribInfo <- function(grib.file, file.type = "grib2") {
inv <- system(paste0("wgrib ", grib.file), " -s", intern = TRUE)
grid <- NULL
} else {
stop(paste0("Did not recognise file type ", file.type, ". Please use \"grib2\" or \"grib.\""))
stop(paste0("Did not recognise file type ", file.type, ". Please use \"grib2\" or \"grib1\"."))
}
return(list(inventory = inv, grid = grid))
}

ReadGrib <- function(file.names, levels, variables, domain = NULL, domain.type = "latlon", file.type = "grib2", missing.data = NULL) {
ReadGrib <- function(file.names, levels, variables, forecasts = NULL, domain = NULL, domain.type = "latlon", file.type = "grib2", missing.data = NULL) {
#This is a function to read forecast data from Grib files
#INPUTS
# FILE.NAMES - Vector of grib file names
# VARIABLES - data to extract
# LEVELS - which levels to extract data from
# FORECASTS - A string indicating the forecast to extract. Default NULL: return everything
# DOMAIN - Region to extract data from, in c(LEFT LON, RIGHT LON, TOP LAT, BOTTOM LAT), west negative
# DOMAIN.TYPE - Either "latlon" (default), where the domain is a latitude/longitude box, or "index", where the model is subsetted based on the node index
# FILE.TYPE - whether this is a grib1 or a grib2 file
Expand Down Expand Up @@ -94,12 +95,25 @@ ReadGrib <- function(file.names, levels, variables, domain = NULL, domain.type =
} else {
match.str <- paste0(match.str, ")")
}

match.str.lst <- strsplit(match.str, split = "")[[1]]
match.str <- paste(match.str.lst[1:(length(match.str.lst) - 1)], collapse = "")

if(length(forecasts) > 0 & !is.null(forecasts)) {
match.str <- paste(match.str, "):(", sep = "")
for(fcst in forecasts) {
match.str <- paste(match.str, fcst, "|", sep = "")
}
} else {
match.str <- paste0(match.str, ")")
}

match.str.lst <- strsplit(match.str, split = "")[[1]]
match.str <- paste(match.str, '"', sep = "")
match.str <- paste(match.str.lst[1:(length(match.str.lst) - 1)], collapse = "")
match.str <- paste(match.str, ")\"", sep = "")


print(match.str)
if(!is.null(missing.data) & !is.numeric(missing.data)) {
warning(paste("Your value", missing.data, " for missing data does not appear to be a number!"))
}
Expand Down
6 changes: 5 additions & 1 deletion man/ReadGrib.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Note that \code{wgrib2} must be installed for \code{ReadGrib} to work for curren
}
\usage{
ReadGrib(file.names, levels, variables,
domain = NULL, domain.type = "latlon",
forecasts = NULL, domain = NULL, domain.type = "latlon",
file.type = "grib2", missing.data = NULL)
}

Expand All @@ -25,6 +25,10 @@ The path and file name of the grib files to read.
}
\item{variables}{
The variables to extract.
}
\item{forecasts}{
Names of forecasts to extract.
If \code{NULL}, include everything.
}
\item{domain}{
Include model nodes in the specified region: \code{c(LEFT LON, RIGHT LON, NORTH LAT, SOUTH LAT)}.
Expand Down

0 comments on commit 102a237

Please sign in to comment.