Skip to content

Commit

Permalink
Updated docs/links
Browse files Browse the repository at this point in the history
Primary changes are to update the links to the ECMWF documentation as
many links no longer go to working pages. Removed references to the
GRIB API as that has not been in development for some time. Made a
change to the environment variable used to point to the GRIB
defintion files. This would only affect Windows as the same change
was already implemented in ECCODES. With Windows still not working,
it is not likely this change will impact many users.
  • Loading branch information
nawendt committed Jan 14, 2021
1 parent f2b3384 commit 1c39a0b
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 40 deletions.
14 changes: 7 additions & 7 deletions R/grib_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#'
#' The \code{filter} parameter controls which keys will be filtered out of the
#' results. More information can be found in the
#' \href{https://software.ecmwf.int/wiki/display/GRIB/grib_api.h+File+Reference}{
#' GRIB API Reference}. Below are the options used in this package:
#' \href{https://confluence.ecmwf.int/display/ECC/ecCodes+API+Reference}{
#' ECCODES API Reference}. Below are the options used in this package:
#'
#' \itemize{ \item "none": no keys filtered \item "readonly": skip readonly keys
#' \item "optional": skip optional keys \item "edition": skip edition-specific
Expand All @@ -20,7 +20,7 @@
#' the keys available in a GRIB file using pre-defined groups of related keys.
#' To get a full set of keys, extract a \code{gribMessage} and view the
#' \code{names}. More information about GRIB key namespaces can be found
#' \href{https://software.ecmwf.int/wiki/display/GRIB/GRIB+API+Frequently+Asked+Questions+FAQ}{
#' \href{https://confluence.ecmwf.int/display/UDOC/What+are+namespaces+-+ecCodes+GRIB+FAQ}{
#' here}. The \code{namespace} options used in this package are described below:
#'
#' \itemize{ \item "ls": most commonly used keys \item "parameter": keys related
Expand All @@ -35,10 +35,10 @@
#' location is in \code{share/grib_api/definitions} directory in the GRIB API
#' root. Any locally defined paramters will not likely be displayed correctly
#' without first overriding the parameter definitions manually. You can read
#' more information about creating your own local definitions in the
#' \href{https://software.ecmwf.int/wiki/display/OPTR/GRIB+API\%3A+Library+and+Tools}{
#' GRIB API Training Material}. Once your own definitions are created, be sure
#' to set the \code{GRIB_DEFINITION_PATH} environment variable to the location
#' more information about creating your own local definitions
#' \href{https://confluence.ecmwf.int/display/UDOC/Creating+your+own+local+definitions+-+ecCodes+GRIB+FAQ}{
#' here}. Once your own definitions are created, be sure
#' to set the \code{ECCODES_DEFINITION_PATH} environment variable to the location
#' of your local defintions before using this function to display the contents.
#'
#' @param gribObj GRIB class object.
Expand Down
15 changes: 6 additions & 9 deletions R/gribr.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
#' The package is designed so that data is kept in R's intuitive data structures
#' and can be easily projected using your preferred plotting package.
#'
#' @section Notice: This package depends on installing the
#' \href{https://software.ecmwf.int/wiki/display/GRIB/Home}{ECMWF GRIB API}.
#' It is important to install the requisite libraries to ensure full
#' functionality (e.g., jasper/openjpeg for GRIB2). Be aware that ECMWF has
#' plans to move the GRIB API into their
#' \href{https://software.ecmwf.int/wiki/display/ECC}{EC CODES} package in the
#' future. This package will follow suit once the EC CODES package is out of
#' beta testing and ready to supplant the GRIB API.
#' @section Notice: This package depends on installing the ECMWF library called
#' \href{https://confluence.ecmwf.int/display/ECC/ecCodes+Home}{ECCODES}.
#' It is important to install the requisite libraries
#' (e.g., jasper/openjpeg for GRIB2) prior to building ECCODES to ensure
#' full functionality.
#'
#' @section gribr Functions:
#'
Expand All @@ -26,7 +23,7 @@
#' of the use of the GRIB API, this is possible. Using this package as a
#' template of sort, one could create new functions that work to expand on the
#' current capabilities. The
#' \href{https://software.ecmwf.int/wiki/display/GRIB/GRIB+API+examples}{GRIB
#' \href{https://confluence.ecmwf.int/display/ECC/GRIB+examples}{ECCODES
#' API examples} are good place to see the basic implementations in C. Beyond
#' that, this package is hosted on
#' \href{https://github.com/nawendt/gribr}{GitHub} where you will not only
Expand Down
10 changes: 5 additions & 5 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.onLoad <- function(libname, pkgname) {
# Windows will be binary distributions most of the time
# Need to set GRIB_DEFINITION_PATH to avoid crash if it
# Need to set ECCODES_DEFINITION_PATH to avoid crash if it
# is not already set
if (.Platform$OS.type == "windows") {
if (Sys.getenv("GRIB_DEFINITION_PATH") == "") {
if (Sys.getenv("ECCODES_DEFINITION_PATH") == "") {
normPath <- normalizePath(system.file("extdata", "definitions",
package = "gribr"), mustWork = FALSE)
if (normPath == "") {
warning("R was unable to set GRIB_DEFINITION_PATH. Please set manually.")
warning("R was unable to set ECCODES_DEFINITION_PATH. Please set manually.")
} else {
Sys.setenv(GRIB_DEFINITION_PATH = normPath)
Sys.setenv(ECCODES_DEFINITION_PATH = normPath)
Sys.setenv(GRIBR_MOD = 1)
}
}
Expand All @@ -20,7 +20,7 @@
# Clean up if .onLoad made mods to env
if (.Platform$OS.type == "windows") {
if (Sys.getenv("GRIBR_MOD") == 1) {
Sys.unsetenv("GRIB_DEFINITION_PATH")
Sys.unsetenv("ECCODES_DEFINITION_PATH")
Sys.unsetenv("GRIBR_MOD")
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ conda install -c conda-forge r-gribr
```

### Windows Install Options
While a native Windows ecCodes library that will work with R is not available, there are ways to run gribr on Windows. The first option is to use the [Windows 10 Linux Subsystem](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide). Simply follow the [instructions](https://cran.r-project.org/bin/linux/ubuntu/) to install the latest R as you would on any other Linux system. Any other necessary libraries should be available on the package manager. Build gribr as usual and enjoy using it on Windows.
While a native Windows ecCodes library that will work with R is not available, there are ways to run gribr on Windows. The first option is to use the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/). Simply follow the [instructions](https://cran.r-project.org/bin/linux/ubuntu/) to install the latest R as you would on any other Linux system. Any other necessary libraries should be available on the package manager. Build gribr as usual and enjoy using it on Windows.

The second option is to use gribr via [Cygwin](https://cygwin.org/). A Cygwin build of R is available through their package manager. Simply make sure to also install the dev versions of the libraries that you will need. This will likely include libraries that the R package proj4 depends on. You will have to install ecCodes from source for this. From there, install gribr from R CMD INSTALL taking care to include all the correct configure-vars. If you build ecCodes with PNG or JPEG support, you'll need to add the appropriate linker flags.

Expand Down
14 changes: 7 additions & 7 deletions man/grib_list.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 6 additions & 9 deletions man/gribr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/gribr_internals.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ int skip_keys(const char* keyName, int keyType, int err) {
SEXP getListElement(SEXP list, const char *str) {
int i;
SEXP elmt = R_NilValue, names = getAttrib(list, R_NamesSymbol);
for (i = 0; i < length(list); i++)
for (i = 0; i < length(list); i++) {
if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) {
elmt = VECTOR_ELT(list, i);
break;
}
return elmt;
}
return elmt;
}

SEXP gribr_is_multi_message(SEXP fileHandle) {
Expand Down

0 comments on commit 1c39a0b

Please sign in to comment.